From 2fb0545e09c92cec8d4e80e93316dee309a27fc5 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sun, 21 Jun 2020 13:25:06 +0100 Subject: Add fixed benchmarks --- benchmarks/CHStone/adpcm/adpcm.c | 82 +++++++++++++++++------------------ benchmarks/CHStone/mips/mips.c | 89 ++++++++++++++++++++++++++++++++++++-- benchmarks/CHStone/sha/sha_coqup.c | 4 -- 3 files changed, 125 insertions(+), 50 deletions(-) diff --git a/benchmarks/CHStone/adpcm/adpcm.c b/benchmarks/CHStone/adpcm/adpcm.c index 613b1bd..7cf81d1 100755 --- a/benchmarks/CHStone/adpcm/adpcm.c +++ b/benchmarks/CHStone/adpcm/adpcm.c @@ -62,7 +62,6 @@ /* */ /* */ /*************************************************************************/ -#include int encode (int, int); void decode (int); @@ -250,23 +249,23 @@ encode (int xin1, int xin2) int i; const int *h_ptr; int *tqmf_ptr, *tqmf_ptr1; - long int xa, xb; + int xa, xb; int decis; /* transmit quadrature mirror filters implemented here */ h_ptr = h; tqmf_ptr = tqmf; - xa = (long) (*tqmf_ptr++) * (*h_ptr++); - xb = (long) (*tqmf_ptr++) * (*h_ptr++); + xa = (int) (*tqmf_ptr++) * (*h_ptr++); + xb = (int) (*tqmf_ptr++) * (*h_ptr++); /* main multiply accumulate loop for samples and coefficients */ for (i = 0; i < 10; i++) { - xa += (long) (*tqmf_ptr++) * (*h_ptr++); - xb += (long) (*tqmf_ptr++) * (*h_ptr++); + xa += (int) (*tqmf_ptr++) * (*h_ptr++); + xb += (int) (*tqmf_ptr++) * (*h_ptr++); } /* final mult/accumulate */ - xa += (long) (*tqmf_ptr++) * (*h_ptr++); - xb += (long) (*tqmf_ptr) * (*h_ptr++); + xa += (int) (*tqmf_ptr++) * (*h_ptr++); + xb += (int) (*tqmf_ptr) * (*h_ptr++); /* update delay line tqmf */ tqmf_ptr1 = tqmf_ptr - 2; @@ -298,7 +297,7 @@ encode (int xin1, int xin2) /* computes quantized difference signal */ /* for invqbl, truncate by 2 lsbs, so mode = 3 */ - dlt = ((long) detl * qq4_code4_table[il >> 2]) >> 15; + dlt = ((int) detl * qq4_code4_table[il >> 2]) >> 15; /* logscl: updates logarithmic quant. scale factor in low sub band */ nbl = logscl (il, nbl); @@ -354,12 +353,12 @@ encode (int xin1, int xin2) { ih = 1; /* 0,1 are neg codes */ } - decis = (564L * (long) deth) >> 12L; + decis = (564L * (int) deth) >> 12L; if (abs (eh) > decis) ih--; /* mih = 2 case */ /* compute the quantized difference signal, higher sub-band*/ - dh = ((long) deth * qq2_code2_table[ih]) >> 15L; + dh = ((int) deth * qq2_code2_table[ih]) >> 15L; /* logsch: update logarithmic quantizer scale factor in hi sub-band*/ nbh = logsch (ih, nbh); @@ -401,7 +400,7 @@ void decode (int input) { int i; - long int xa1, xa2; /* qmf accumulators */ + int xa1, xa2; /* qmf accumulators */ const int *h_ptr; int *ac_ptr, *ac_ptr1, *ad_ptr, *ad_ptr1; @@ -420,10 +419,10 @@ decode (int input) dec_sl = dec_spl + dec_szl; /* compute quantized difference signal for adaptive predic */ - dec_dlt = ((long) dec_detl * qq4_code4_table[ilr >> 2]) >> 15; + dec_dlt = ((int) dec_detl * qq4_code4_table[ilr >> 2]) >> 15; /* compute quantized difference signal for decoder output */ - dl = ((long) dec_detl * qq6_code6_table[il]) >> 15; + dl = ((int) dec_detl * qq6_code6_table[il]) >> 15; rl = dl + dec_sl; @@ -467,7 +466,7 @@ decode (int input) dec_sh = dec_sph + dec_szh; /* in-place compute the quantized difference signal */ - dec_dh = ((long) dec_deth * qq2_code2_table[ih]) >> 15L; + dec_dh = ((int) dec_deth * qq2_code2_table[ih]) >> 15L; /* logsch: update logarithmic quantizer scale factor in hi sub band */ dec_nbh = logsch (ih, dec_nbh); @@ -506,17 +505,17 @@ decode (int input) h_ptr = h; ac_ptr = accumc; ad_ptr = accumd; - xa1 = (long) xd *(*h_ptr++); - xa2 = (long) xs *(*h_ptr++); + xa1 = (int) xd *(*h_ptr++); + xa2 = (int) xs *(*h_ptr++); /* main multiply accumulate loop for samples and coefficients */ for (i = 0; i < 10; i++) { - xa1 += (long) (*ac_ptr++) * (*h_ptr++); - xa2 += (long) (*ad_ptr++) * (*h_ptr++); + xa1 += (int) (*ac_ptr++) * (*h_ptr++); + xa2 += (int) (*ad_ptr++) * (*h_ptr++); } /* final mult/accumulate */ - xa1 += (long) (*ac_ptr) * (*h_ptr++); - xa2 += (long) (*ad_ptr) * (*h_ptr++); + xa1 += (int) (*ac_ptr) * (*h_ptr++); + xa2 += (int) (*ad_ptr) * (*h_ptr++); /* scale by 2^14 */ xout1 = xa1 >> 14; @@ -581,10 +580,10 @@ int filtez (int *bpl, int *dlt) { int i; - long int zl; - zl = (long) (*bpl++) * (*dlt++); + int zl; + zl = (int) (*bpl++) * (*dlt++); for (i = 1; i < 6; i++) - zl += (long) (*bpl++) * (*dlt++); + zl += (int) (*bpl++) * (*dlt++); return ((int) (zl >> 14)); /* x2 here */ } @@ -595,11 +594,11 @@ filtez (int *bpl, int *dlt) int filtep (int rlt1, int al1, int rlt2, int al2) { - long int pl, pl2; + int pl, pl2; pl = 2 * rlt1; - pl = (long) al1 *pl; + pl = (int) al1 *pl; pl2 = 2 * rlt2; - pl += (long) al2 *pl2; + pl += (int) al2 *pl2; return ((int) (pl >> 15)); } @@ -608,14 +607,14 @@ int quantl (int el, int detl) { int ril, mil; - long int wd, decis; + int wd, decis; /* abs of difference signal */ wd = abs (el); /* determine mil based on decision levels and detl gain */ for (mil = 0; mil < 30; mil++) { - decis = (decis_levl[mil] * (long) detl) >> 15L; + decis = (decis_levl[mil] * (int) detl) >> 15L; if (wd <= decis) break; } @@ -633,8 +632,8 @@ quantl (int el, int detl) int logscl (int il, int nbl) { - long int wd; - wd = ((long) nbl * 127L) >> 7L; /* leak factor 127/128 */ + int wd; + wd = ((int) nbl * 127L) >> 7L; /* leak factor 127/128 */ nbl = (int) wd + wl_code_table[il >> 2]; if (nbl < 0) nbl = 0; @@ -674,7 +673,7 @@ upzero (int dlt, int *dlti, int *bli) { for (i = 0; i < 6; i++) { - if ((long) dlt * dlti[i] >= 0) + if ((int) dlt * dlti[i] >= 0) wd2 = 128; else wd2 = -128; @@ -697,13 +696,13 @@ upzero (int dlt, int *dlti, int *bli) int uppol2 (int al1, int al2, int plt, int plt1, int plt2) { - long int wd2, wd4; + int wd2, wd4; int apl2; - wd2 = 4L * (long) al1; - if ((long) plt * plt1 >= 0L) + wd2 = 4L * (int) al1; + if ((int) plt * plt1 >= 0L) wd2 = -wd2; /* check same sign */ wd2 = wd2 >> 7; /* gain of 1/128 */ - if ((long) plt * plt2 >= 0L) + if ((int) plt * plt2 >= 0L) { wd4 = wd2 + 128; /* same sign case */ } @@ -711,7 +710,7 @@ uppol2 (int al1, int al2, int plt, int plt1, int plt2) { wd4 = wd2 - 128; } - apl2 = wd4 + (127L * (long) al2 >> 7L); /* leak factor of 127/128 */ + apl2 = wd4 + (127L * (int) al2 >> 7L); /* leak factor of 127/128 */ /* apl2 is limited to +-.75 */ if (apl2 > 12288) @@ -727,10 +726,10 @@ uppol2 (int al1, int al2, int plt, int plt1, int plt2) int uppol1 (int al1, int apl2, int plt, int plt1) { - long int wd2; + int wd2; int wd3, apl1; - wd2 = ((long) al1 * 255L) >> 8L; /* leak factor of 255/256 */ - if ((long) plt * plt1 >= 0L) + wd2 = ((int) al1 * 255L) >> 8L; /* leak factor of 255/256 */ + if ((int) plt * plt1 >= 0L) { apl1 = (int) wd2 + 192; /* same sign case */ } @@ -754,7 +753,7 @@ int logsch (int ih, int nbh) { int wd; - wd = ((long) nbh * 127L) >> 7L; /* leak factor 127/128 */ + wd = ((int) nbh * 127L) >> 7L; /* leak factor 127/128 */ nbh = wd + wh_code_table[ih]; if (nbh < 0) nbh = 0; @@ -877,6 +876,5 @@ main () main_result += 1; } } - printf ("%d\n", main_result); return main_result; } diff --git a/benchmarks/CHStone/mips/mips.c b/benchmarks/CHStone/mips/mips.c index 09591fe..7352e81 100755 --- a/benchmarks/CHStone/mips/mips.c +++ b/benchmarks/CHStone/mips/mips.c @@ -34,7 +34,90 @@ * agents, transferees, successors, and assigns. * */ -#include + +/* ++--------------------------------------------------------------------------+ +| CHStone : a suite of benchmark programs for C-based High-Level Synthesis | +| ======================================================================== | +| | +| * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda, | +| H. Takada and K. Ishii | +| Nagoya University, Japan | +| | +| * Remark : | +| 1. This source code is modified to unify the formats of the benchmark | +| programs in CHStone. | +| 2. Test vectors are added for CHStone. | +| 3. If "main_result" is 0 at the end of the program, the program is | +| correctly executed. | +| 4. Please follow the copyright of each benchmark program. | ++--------------------------------------------------------------------------+ +*/ +/* + * Copyright (C) 2008 + * Y. Hara, H. Tomiyama, S. Honda, H. Takada and K. Ishii + * Nagoya University, Japan + * All rights reserved. + * + * Disclaimer of Warranty + * + * These software programs are available to the user without any license fee or + * royalty on an "as is" basis. The authors disclaims any and all warranties, + * whether express, implied, or statuary, including any implied warranties or + * merchantability or of fitness for a particular purpose. In no event shall the + * copyright-holder be liable for any incidental, punitive, or consequential damages + * of any kind whatsoever arising from the use of these programs. This disclaimer + * of warranty extends to the user of these programs and user's customers, employees, + * agents, transferees, successors, and assigns. + * + */ +const unsigned int imem[44] = { + 0x8fa40000, // [0x00400000] lw $4, 0($29) ; 175: lw $a0 0($sp) # argc + 0x27a50004, // [0x00400004] addiu $5, $29, 4 ; 176: addiu $a1 $sp 4 # argv + 0x24a60004, // [0x00400008] addiu $6, $5, 4 ; 177: addiu $a2 $a1 4 # envp + 0x00041080, // [0x0040000c] sll $2, $4, 2 ; 178: sll $v0 $a0 2 + 0x00c23021, // [0x00400010] addu $6, $6, $2 ; 179: addu $a2 $a2 $v0 + 0x0c100016, // [0x00400014] jal 0x00400058 [main] ; 180: jal main + 0x00000000, // [0x00400018] nop ; 181: nop + 0x3402000a, // [0x0040001c] ori $2, $0, 10 ; 183: li $v0 10 + 0x0000000c, // [0x00400020] syscall ; 184: syscall # syscall 10 (exit) + 0x3c011001, // [0x00400024] lui $1, 4097 [A] ; 4: la $t0,A ; C&S + 0x34280000, // [0x00400028] ori $8, $1, 0 [A] + 0x00044880, // [0x0040002c] sll $9, $4, 2 ; 5: sll $t1,$a0,2 + 0x01094821, // [0x00400030] addu $9, $8, $9 ; 6: addu $t1,$t0,$t1 + 0x8d2a0000, // [0x00400034] lw $10, 0($9) ; 7: lw $t2,($t1) + 0x00055880, // [0x00400038] sll $11, $5, 2 ; 8: sll $t3,$a1,2 + 0x010b5821, // [0x0040003c] addu $11, $8, $11 ; 9: addu $t3,$t0,$t3 + 0x8d6c0000, // [0x00400040] lw $12, 0($11) ; 10: lw $t4,($t3) + 0x018a682a, // [0x00400044] slt $13, $12, $10 ; 11: slt $t5,$t4,$t2 + 0x11a00003, // [0x00400048] beq $13, $0, 12 [L1-0x00400048] ; 12: beq $t5,$zero,L1 + 0xad2c0000, // [0x0040004c] sw $12, 0($9) ; 13: sw $t4,($t1) + 0xad6a0000, // [0x00400050] sw $10, 0($11) ; 14: sw $t2,($t3) + 0x03e00008, // [0x00400054] jr $31 ; 15: jr $ra ; L1 + 0x27bdfff4, // [0x00400058] addiu $29, $29, -12 ; 17: addiu $sp,$sp,-12 ; main + 0xafbf0008, // [0x0040005c] sw $31, 8($29) ; 18: sw $ra,8($sp) + 0xafb10004, // [0x00400060] sw $17, 4($29) ; 19: sw $s1,4($sp) + 0xafb00000, // [0x00400064] sw $16, 0($29) ; 20: sw $s0,0($sp) + 0x24100000, // [0x00400068] addiu $16, $0, 0 ; 21: addiu $s0,$zero,0 + 0x2a080008, // [0x0040006c] slti $8, $16, 8 ; 22: slti $t0,$s0,8 ; L5 + 0x1100000b, // [0x00400070] beq $8, $0, 44 [L2-0x00400070] ; 23: beq $t0,$zero,L2 + 0x26110001, // [0x00400074] addiu $17, $16, 1 ; 24: addiu $s1,$s0,1 + 0x2a280008, // [0x00400078] slti $8, $17, 8 ; 25: slti $t0,$s1,8 ; L4 + 0x11000006, // [0x0040007c] beq $8, $0, 24 [L3-0x0040007c] ; 26: beq $t0,$zero,L3 + 0x26040000, // [0x00400080] addiu $4, $16, 0 ; 27: addiu $a0,$s0,0 + 0x26250000, // [0x00400084] addiu $5, $17, 0 ; 28: addiu $a1,$s1,0 + 0x0c100009, // [0x00400088] jal 0x00400024 [compare_swap] ; 29: jal compare_swap + 0x26310001, // [0x0040008c] addiu $17, $17, 1 ; 30: addiu $s1,$s1,1 + 0x0810001e, // [0x00400090] j 0x00400078 [L4] ; 31: j L4 + 0x26100001, // [0x00400094] addiu $16, $16, 1 ; 32: addiu $s0,$s0,1 ; L3 + 0x0810001b, // [0x00400098] j 0x0040006c [L5] ; 33: j L5 + 0x8fbf0008, // [0x0040009c] lw $31, 8($29) ; 34: lw $ra,8($sp) ; L2 + 0x8fb10004, // [0x004000a0] lw $17, 4($29) ; 35: lw $s1,4($sp) + 0x8fb00000, // [0x004000a4] lw $16, 0($29) ; 36: lw $s0,0($sp) + 0x27bd000c, // [0x004000a8] addiu $29, $29, 12 ; 37: addiu $sp,$sp,12 + 0x03e00008, // [0x004000ac] jr $31 ; 38: jr $ra +}; + int main_result; #define R 0 @@ -80,7 +163,6 @@ int main_result; #define SLTI 10 #define SLTIU 11 -#include "imem.h" /* +--------------------------------------------------------------------------+ | * Test Vectors (added for CHStone) | @@ -97,7 +179,7 @@ const int outData[8] = { -17, -9, 0, 3, 5, 11, 22, 38 }; int main () { - long long hilo; + int hilo; int reg[32]; int Hi = 0; int Lo = 0; @@ -300,7 +382,6 @@ main () main_result += (dmem[j] != outData[j]); } - printf ("%d\n", main_result); return main_result; } } diff --git a/benchmarks/CHStone/sha/sha_coqup.c b/benchmarks/CHStone/sha/sha_coqup.c index eea3a8a..3c4d7c8 100755 --- a/benchmarks/CHStone/sha/sha_coqup.c +++ b/benchmarks/CHStone/sha/sha_coqup.c @@ -24,8 +24,6 @@ /* NIST's proposed modification to SHA of 7/11/94 may be */ /* activated by defining USE_MODIFIED_SHA */ -#include - /* NIST Secure Hash Algorithm */ /* heavily modified from Peter C. Gutmann's implementation */ @@ -1348,10 +1346,8 @@ main () for (i = 0; i < 5; i++) { - printf("%d: %x == %x\n", i, sha_info_digest[i], outData[i]); main_result += (sha_info_digest[i] != outData[i]); } - printf ("%d\n", main_result); return main_result; } -- cgit