diff --git a/crc/crc16_t10dif_copy_perf.c b/crc/crc16_t10dif_copy_perf.c index 01c8038..17cba6b 100644 --- a/crc/crc16_t10dif_copy_perf.c +++ b/crc/crc16_t10dif_copy_perf.c @@ -39,13 +39,11 @@ #ifdef CACHED_TEST // Cached test, loop many times over small dataset # define TEST_LEN 8*1024 -# define TEST_LOOPS 4000000 # define TEST_TYPE_STR "_warm" #else // Uncached test. Pull from large mem base. # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN (2 * GT_L3_CACHE) -# define TEST_LOOPS 100 # define TEST_TYPE_STR "_cold" #endif @@ -57,10 +55,9 @@ int main(int argc, char *argv[]) { - int i; void *src, *dst; uint16_t crc; - struct perf start, stop; + struct perf start; printf("crc16_t10dif_copy_perf:\n"); @@ -77,15 +74,10 @@ int main(int argc, char *argv[]) fflush(0); memset(src, 0, TEST_LEN); - crc = crc16_t10dif_copy(TEST_SEED, dst, src, TEST_LEN); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - crc = crc16_t10dif_copy(TEST_SEED, dst, src, TEST_LEN); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, crc = + crc16_t10dif_copy(TEST_SEED, dst, src, TEST_LEN)); printf("crc16_t10dif_copy" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * i); + perf_print(start, (long long)TEST_LEN); printf("finish 0x%x\n", crc); return 0; diff --git a/crc/crc16_t10dif_op_perf.c b/crc/crc16_t10dif_op_perf.c index 0b46199..9b91ef3 100644 --- a/crc/crc16_t10dif_op_perf.c +++ b/crc/crc16_t10dif_op_perf.c @@ -40,14 +40,12 @@ #ifdef CACHED_TEST // Cached test, loop many times over small dataset # define NBLOCKS 100 -# define TEST_LOOPS 1000000 # define TEST_TYPE_STR "_warm" #else // Uncached test. Pull from large mem base. # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN (2 * GT_L3_CACHE) # define NBLOCKS (TEST_LEN / BLKSIZE) -# define TEST_LOOPS 100 # define TEST_TYPE_STR "_cold" #endif @@ -66,13 +64,25 @@ struct blk_ext { uint16_t crc; }; +void crc16_t10dif_copy_perf(struct blk *blks, struct blk *blkp, struct blk_ext *blks_ext, + struct blk_ext *blkp_ext, uint16_t * crc) +{ + int i; + for (i = 0, blkp = blks, blkp_ext = blks_ext; i < NBLOCKS; i++) { + *crc = crc16_t10dif_copy(TEST_SEED, blkp_ext->data, blkp->data, + sizeof(blks->data)); + blkp_ext->crc = *crc; + blkp++; + blkp_ext++; + } +} + int main(int argc, char *argv[]) { - int i, j; uint16_t crc; struct blk *blks, *blkp; struct blk_ext *blks_ext, *blkp_ext; - struct perf start, stop; + struct perf start; printf("crc16_t10dif_streaming_insert_perf:\n"); @@ -95,19 +105,11 @@ int main(int argc, char *argv[]) fflush(0); // Copy and insert test - perf_start(&start); - for (j = 0; j < TEST_LOOPS; j++) { - for (i = 0, blkp = blks, blkp_ext = blks_ext; i < NBLOCKS; i++) { - crc = crc16_t10dif_copy(TEST_SEED, blkp_ext->data, blkp->data, - sizeof(blks->data)); - blkp_ext->crc = crc; - blkp++; - blkp_ext++; - } - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, + crc16_t10dif_copy_perf(blks, blkp, blks_ext, blkp_ext, &crc)); + printf("crc16_t10pi_op_copy_insert" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)sizeof(blks->data) * NBLOCKS * TEST_LOOPS); + perf_print(start, (long long)sizeof(blks->data) * NBLOCKS); printf("finish 0x%x\n", crc); return 0; diff --git a/crc/crc16_t10dif_perf.c b/crc/crc16_t10dif_perf.c index 9fddb49..7b7c0bc 100644 --- a/crc/crc16_t10dif_perf.c +++ b/crc/crc16_t10dif_perf.c @@ -39,13 +39,11 @@ #ifdef CACHED_TEST // Cached test, loop many times over small dataset # define TEST_LEN 8*1024 -# define TEST_LOOPS 4000000 # define TEST_TYPE_STR "_warm" #else // Uncached test. Pull from large mem base. # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN (2 * GT_L3_CACHE) -# define TEST_LOOPS 100 # define TEST_TYPE_STR "_cold" #endif @@ -57,10 +55,9 @@ int main(int argc, char *argv[]) { - int i; void *buf; uint16_t crc; - struct perf start, stop; + struct perf start; printf("crc16_t10dif_perf:\n"); @@ -73,14 +70,9 @@ int main(int argc, char *argv[]) fflush(0); memset(buf, 0, TEST_LEN); - crc = crc16_t10dif(TEST_SEED, buf, TEST_LEN); - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - crc = crc16_t10dif(TEST_SEED, buf, TEST_LEN); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, crc = crc16_t10dif(TEST_SEED, buf, TEST_LEN)); printf("crc16_t10dif" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * i); + perf_print(start, (long long)TEST_LEN); printf("finish 0x%x\n", crc); return 0; diff --git a/crc/crc32_gzip_refl_perf.c b/crc/crc32_gzip_refl_perf.c index 4a3f2cd..ad3d86f 100644 --- a/crc/crc32_gzip_refl_perf.c +++ b/crc/crc32_gzip_refl_perf.c @@ -39,13 +39,11 @@ #ifdef CACHED_TEST // Cached test, loop many times over small dataset # define TEST_LEN 8*1024 -# define TEST_LOOPS 400000 # define TEST_TYPE_STR "_warm" #else // Uncached test. Pull from large mem base. # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN (2 * GT_L3_CACHE) -# define TEST_LOOPS 100 # define TEST_TYPE_STR "_cold" #endif @@ -57,10 +55,9 @@ int main(int argc, char *argv[]) { - int i; void *buf; uint32_t crc; - struct perf start, stop; + struct perf start; printf("crc32_gzip_refl_perf:\n"); @@ -73,14 +70,9 @@ int main(int argc, char *argv[]) fflush(0); memset(buf, 0, TEST_LEN); - crc = crc32_gzip_refl(TEST_SEED, buf, TEST_LEN); - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - crc = crc32_gzip_refl(TEST_SEED, buf, TEST_LEN); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_gzip_refl(TEST_SEED, buf, TEST_LEN)); printf("crc32_gzip_refl" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * i); + perf_print(start, (long long)TEST_LEN); printf("finish 0x%x\n", crc); @@ -88,14 +80,10 @@ int main(int argc, char *argv[]) printf("Start timed tests\n"); fflush(0); - crc = crc32_gzip_refl_base(TEST_SEED, buf, TEST_LEN); - perf_start(&start); - for (i = 0; i < (TEST_LOOPS / 100 + 1); i++) { - crc = crc32_gzip_refl_base(TEST_SEED, buf, TEST_LEN); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, crc = + crc32_gzip_refl_base(TEST_SEED, buf, TEST_LEN)); printf("crc32_gzip_refl_base" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * i); + perf_print(start, (long long)TEST_LEN); printf("finish 0x%x\n", crc); diff --git a/crc/crc32_ieee_perf.c b/crc/crc32_ieee_perf.c index c6c7495..f6ffbbe 100644 --- a/crc/crc32_ieee_perf.c +++ b/crc/crc32_ieee_perf.c @@ -39,13 +39,11 @@ #ifdef CACHED_TEST // Cached test, loop many times over small dataset # define TEST_LEN 8*1024 -# define TEST_LOOPS 400000 # define TEST_TYPE_STR "_warm" #else // Uncached test. Pull from large mem base. # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN (2 * GT_L3_CACHE) -# define TEST_LOOPS 100 # define TEST_TYPE_STR "_cold" #endif @@ -57,10 +55,9 @@ int main(int argc, char *argv[]) { - int i; void *buf; uint32_t crc; - struct perf start, stop; + struct perf start; printf("crc32_ieee_perf:\n"); @@ -73,14 +70,9 @@ int main(int argc, char *argv[]) fflush(0); memset(buf, 0, TEST_LEN); - crc = crc32_ieee(TEST_SEED, buf, TEST_LEN); - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - crc = crc32_ieee(TEST_SEED, buf, TEST_LEN); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_ieee(TEST_SEED, buf, TEST_LEN)); printf("crc32_ieee" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * i); + perf_print(start, (long long)TEST_LEN); printf("finish 0x%x\n", crc); return 0; diff --git a/crc/crc32_iscsi_perf.c b/crc/crc32_iscsi_perf.c index 2770099..d768cdf 100644 --- a/crc/crc32_iscsi_perf.c +++ b/crc/crc32_iscsi_perf.c @@ -39,13 +39,11 @@ #ifdef CACHED_TEST // Cached test, loop many times over small dataset # define TEST_LEN 8*1024 -# define TEST_LOOPS 1000000 # define TEST_TYPE_STR "_warm" #else // Uncached test. Pull from large mem base. # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN (2 * GT_L3_CACHE) -# define TEST_LOOPS 500 # define TEST_TYPE_STR "_cold" #endif @@ -57,10 +55,9 @@ int main(int argc, char *argv[]) { - int i; void *buf; uint32_t crc; - struct perf start, stop; + struct perf start; printf("crc32_iscsi_perf:\n"); @@ -73,14 +70,9 @@ int main(int argc, char *argv[]) fflush(0); memset(buf, 0, TEST_LEN); - crc = crc32_iscsi(buf, TEST_LEN, TEST_SEED); - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - crc = crc32_iscsi(buf, TEST_LEN, TEST_SEED); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_iscsi(buf, TEST_LEN, TEST_SEED)); printf("crc32_iscsi" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * i); + perf_print(start, (long long)TEST_LEN); printf("finish 0x%x\n", crc); return 0; diff --git a/crc/crc64_funcs_perf.c b/crc/crc64_funcs_perf.c index 04135bf..4ad1cc1 100644 --- a/crc/crc64_funcs_perf.c +++ b/crc/crc64_funcs_perf.c @@ -39,13 +39,11 @@ #ifdef CACHED_TEST // Cached test, loop many times over small dataset # define TEST_LEN 8*1024 -# define TEST_LOOPS 400000 # define TEST_TYPE_STR "_warm" #else // Uncached test. Pull from large mem base. # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN (2 * GT_L3_CACHE) -# define TEST_LOOPS 100 # define TEST_TYPE_STR "_cold" #endif @@ -74,10 +72,10 @@ func_case_t test_funcs[] = { int main(int argc, char *argv[]) { - int i, j; + int j; void *buf; uint64_t crc; - struct perf start, stop; + struct perf start; func_case_t *test_func; if (posix_memalign(&buf, 1024, TEST_LEN)) { @@ -93,14 +91,10 @@ int main(int argc, char *argv[]) printf("Start timed tests\n"); fflush(0); - crc = test_func->crc64_func_call(TEST_SEED, buf, TEST_LEN); - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - crc = test_func->crc64_func_call(TEST_SEED, buf, TEST_LEN); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, crc = + test_func->crc64_func_call(TEST_SEED, buf, TEST_LEN)); printf("%s" TEST_TYPE_STR ": ", test_func->note); - perf_print(stop, start, (long long)TEST_LEN * i); + perf_print(start, (long long)TEST_LEN); printf("finish 0x%lx\n", crc); } diff --git a/erasure_code/erasure_code_base_perf.c b/erasure_code/erasure_code_base_perf.c index abfa3f8..9587788 100644 --- a/erasure_code/erasure_code_base_perf.c +++ b/erasure_code/erasure_code_base_perf.c @@ -38,7 +38,6 @@ // Cached test, loop many times over small dataset # define TEST_SOURCES 32 # define TEST_LEN(m) ((128*1024 / m) & ~(64-1)) -# define TEST_LOOPS(m) (100*m) # define TEST_TYPE_STR "_warm" #else # ifndef TEST_CUSTOM @@ -46,30 +45,64 @@ # define TEST_SOURCES 32 # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64-1)) -# define TEST_LOOPS(m) (10) # define TEST_TYPE_STR "_cold" # else # define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS(m) 1000 -# endif # endif #endif #define MMAX TEST_SOURCES #define KMAX TEST_SOURCES +#define BAD_MATRIX -1 + typedef unsigned char u8; +void ec_encode_perf(int m, int k, u8 * a, u8 * g_tbls, u8 ** buffs) +{ + ec_init_tables(k, m - k, &a[k * k], g_tbls); + ec_encode_data_base(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); +} + +int ec_decode_perf(int m, int k, u8 * a, u8 * g_tbls, u8 ** buffs, u8 * src_in_err, + u8 * src_err_list, int nerrs, u8 ** temp_buffs) +{ + int i, j, r; + u8 b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; + u8 *recov[TEST_SOURCES]; + + // Construct b by removing error rows + for (i = 0, r = 0; i < k; i++, r++) { + while (src_in_err[r]) + r++; + recov[i] = buffs[r]; + for (j = 0; j < k; j++) + b[k * i + j] = a[k * r + j]; + } + + if (gf_invert_matrix(b, d, k) < 0) + return BAD_MATRIX; + + for (i = 0; i < nerrs; i++) + for (j = 0; j < k; j++) + c[k * i + j] = d[k * src_err_list[i] + j]; + + // Recover data + ec_init_tables(k, nerrs, c, g_tbls); + ec_encode_data_base(TEST_LEN(m), k, nerrs, g_tbls, recov, temp_buffs); + + return 0; +} + int main(int argc, char *argv[]) { - int i, j, rtest, m, k, nerrs, r; + int i, j, m, k, nerrs, check; void *buf; u8 *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; - u8 a[MMAX * KMAX], b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; + u8 a[MMAX * KMAX]; u8 g_tbls[KMAX * TEST_SOURCES * 32], src_in_err[TEST_SOURCES]; - u8 src_err_list[TEST_SOURCES], *recov[TEST_SOURCES]; - struct perf start, stop; + u8 src_err_list[TEST_SOURCES]; + struct perf start; // Pick test parameters m = 14; @@ -112,46 +145,21 @@ int main(int argc, char *argv[]) buffs[i][j] = rand(); gf_gen_rs_matrix(a, m, k); - ec_init_tables(k, m - k, &a[k * k], g_tbls); - ec_encode_data_base(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); // Start encode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Make parity vects - ec_init_tables(k, m - k, &a[k * k], g_tbls); - ec_encode_data_base(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, ec_encode_perf(m, k, a, g_tbls, buffs)); printf("erasure_code_base_encode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (m) * rtest); + perf_print(start, (long long)(TEST_LEN(m)) * (m)); // Start decode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) - r++; - recov[i] = buffs[r]; - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } + BENCHMARK(&start, BENCHMARK_TIME, check = + ec_decode_perf(m, k, a, g_tbls, buffs, src_in_err, src_err_list, nerrs, + temp_buffs)); - if (gf_invert_matrix(b, d, k) < 0) { - printf("BAD MATRIX\n"); - return -1; - } - - for (i = 0; i < nerrs; i++) - for (j = 0; j < k; j++) - c[k * i + j] = d[k * src_err_list[i] + j]; - - // Recover data - ec_init_tables(k, nerrs, c, g_tbls); - ec_encode_data_base(TEST_LEN(m), k, nerrs, g_tbls, recov, temp_buffs); + if (check == BAD_MATRIX) { + printf("BAD MATRIX\n"); + return check; } - perf_stop(&stop); for (i = 0; i < nerrs; i++) { if (0 != memcmp(temp_buffs[i], buffs[src_err_list[i]], TEST_LEN(m))) { @@ -161,7 +169,7 @@ int main(int argc, char *argv[]) } printf("erasure_code_base_decode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (k + nerrs) * rtest); + perf_print(start, (long long)(TEST_LEN(m)) * (k + nerrs)); printf("done all: Pass\n"); return 0; diff --git a/erasure_code/erasure_code_perf.c b/erasure_code/erasure_code_perf.c index 0451a5f..c4cad88 100644 --- a/erasure_code/erasure_code_perf.c +++ b/erasure_code/erasure_code_perf.c @@ -38,7 +38,6 @@ // Cached test, loop many times over small dataset # define TEST_SOURCES 32 # define TEST_LEN(m) ((128*1024 / m) & ~(64-1)) -# define TEST_LOOPS(m) (10000*m) # define TEST_TYPE_STR "_warm" #else # ifndef TEST_CUSTOM @@ -46,30 +45,64 @@ # define TEST_SOURCES 32 # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64-1)) -# define TEST_LOOPS(m) (50*m) # define TEST_TYPE_STR "_cold" # else # define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS(m) 1000 -# endif # endif #endif #define MMAX TEST_SOURCES #define KMAX TEST_SOURCES +#define BAD_MATRIX -1 + typedef unsigned char u8; +void ec_encode_perf(int m, int k, u8 * a, u8 * g_tbls, u8 ** buffs) +{ + ec_init_tables(k, m - k, &a[k * k], g_tbls); + ec_encode_data(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); +} + +int ec_decode_perf(int m, int k, u8 * a, u8 * g_tbls, u8 ** buffs, u8 * src_in_err, + u8 * src_err_list, int nerrs, u8 ** temp_buffs) +{ + int i, j, r; + u8 b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; + u8 *recov[TEST_SOURCES]; + + // Construct b by removing error rows + for (i = 0, r = 0; i < k; i++, r++) { + while (src_in_err[r]) + r++; + recov[i] = buffs[r]; + for (j = 0; j < k; j++) + b[k * i + j] = a[k * r + j]; + } + + if (gf_invert_matrix(b, d, k) < 0) + return BAD_MATRIX; + + for (i = 0; i < nerrs; i++) + for (j = 0; j < k; j++) + c[k * i + j] = d[k * src_err_list[i] + j]; + + // Recover data + ec_init_tables(k, nerrs, c, g_tbls); + ec_encode_data(TEST_LEN(m), k, nerrs, g_tbls, recov, temp_buffs); + + return 0; +} + int main(int argc, char *argv[]) { - int i, j, rtest, m, k, nerrs, r; + int i, j, m, k, nerrs, check; void *buf; u8 *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; - u8 a[MMAX * KMAX], b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; + u8 a[MMAX * KMAX]; u8 g_tbls[KMAX * TEST_SOURCES * 32], src_in_err[TEST_SOURCES]; - u8 src_err_list[TEST_SOURCES], *recov[TEST_SOURCES]; - struct perf start, stop; + u8 src_err_list[TEST_SOURCES]; + struct perf start; // Pick test parameters m = 14; @@ -112,46 +145,21 @@ int main(int argc, char *argv[]) buffs[i][j] = rand(); gf_gen_rs_matrix(a, m, k); - ec_init_tables(k, m - k, &a[k * k], g_tbls); - ec_encode_data(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); // Start encode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Make parity vects - ec_init_tables(k, m - k, &a[k * k], g_tbls); - ec_encode_data(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, ec_encode_perf(m, k, a, g_tbls, buffs)); printf("erasure_code_encode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (m) * rtest); + perf_print(start, (long long)(TEST_LEN(m)) * (m)); // Start decode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) - r++; - recov[i] = buffs[r]; - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } + BENCHMARK(&start, BENCHMARK_TIME, check = + ec_decode_perf(m, k, a, g_tbls, buffs, src_in_err, src_err_list, nerrs, + temp_buffs)); - if (gf_invert_matrix(b, d, k) < 0) { - printf("BAD MATRIX\n"); - return -1; - } - - for (i = 0; i < nerrs; i++) - for (j = 0; j < k; j++) - c[k * i + j] = d[k * src_err_list[i] + j]; - - // Recover data - ec_init_tables(k, nerrs, c, g_tbls); - ec_encode_data(TEST_LEN(m), k, nerrs, g_tbls, recov, temp_buffs); + if (check == BAD_MATRIX) { + printf("BAD MATRIX\n"); + return check; } - perf_stop(&stop); for (i = 0; i < nerrs; i++) { if (0 != memcmp(temp_buffs[i], buffs[src_err_list[i]], TEST_LEN(m))) { @@ -161,7 +169,7 @@ int main(int argc, char *argv[]) } printf("erasure_code_decode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (k + nerrs) * rtest); + perf_print(start, (long long)(TEST_LEN(m)) * (k + nerrs)); printf("done all: Pass\n"); return 0; diff --git a/erasure_code/erasure_code_update_perf.c b/erasure_code/erasure_code_update_perf.c index a74ff1d..55a91a1 100644 --- a/erasure_code/erasure_code_update_perf.c +++ b/erasure_code/erasure_code_update_perf.c @@ -53,7 +53,6 @@ // Cached test, loop many times over small dataset # define TEST_SOURCES 32 # define TEST_LEN(m) ((128*1024 / m) & ~(64-1)) -# define TEST_LOOPS(m) (10000*m) # define TEST_TYPE_STR "_warm" #else # ifndef TEST_CUSTOM @@ -61,13 +60,9 @@ # define TEST_SOURCES 32 # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64-1)) -# define TEST_LOOPS(m) (50*m) # define TEST_TYPE_STR "_cold" # else # define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS(m) 1000 -# endif # endif #endif @@ -87,17 +82,65 @@ void dump(unsigned char *buf, int len) printf("\n"); } +void encode_update_test_ref(int m, int k, u8 * g_tbls, u8 ** buffs, u8 * a) +{ + ec_init_tables(k, m - k, &a[k * k], g_tbls); + REF_FUNCTION(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); +} + +void encode_update_test(int m, int k, u8 * g_tbls, u8 ** perf_update_buffs, u8 * a) +{ + // Make parity vects + ec_init_tables(k, m - k, &a[k * k], g_tbls); + for (int i = 0; i < k; i++) { + FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, + perf_update_buffs[i], &perf_update_buffs[k]); + } +} + +int decode_test(int m, int k, u8 ** update_buffs, u8 ** recov, u8 * a, u8 * src_in_err, + u8 * src_err_list, int nerrs, u8 * g_tbls, u8 ** perf_update_buffs) +{ + int i, j, r; + u8 b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; + // Construct b by removing error rows + for (i = 0, r = 0; i < k; i++, r++) { + while (src_in_err[r]) + r++; + recov[i] = update_buffs[r]; + for (j = 0; j < k; j++) + b[k * i + j] = a[k * r + j]; + } + + if (gf_invert_matrix(b, d, k) < 0) { + printf("BAD MATRIX\n"); + return -1; + } + + for (i = 0; i < nerrs; i++) + for (j = 0; j < k; j++) + c[k * i + j] = d[k * src_err_list[i] + j]; + + // Recover data + ec_init_tables(k, nerrs, c, g_tbls); + for (i = 0; i < k; i++) { + FUNCTION_UNDER_TEST(TEST_LEN(m), k, nerrs, i, g_tbls, recov[i], + perf_update_buffs); + } + return 0; +} + int main(int argc, char *argv[]) { - int i, j, rtest, m, k, nerrs, r; + int i, j, check, m, k, nerrs; void *buf; u8 *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; u8 *update_buffs[TEST_SOURCES]; u8 *perf_update_buffs[TEST_SOURCES]; - u8 a[MMAX * KMAX], b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; + u8 a[MMAX * KMAX]; u8 g_tbls[KMAX * TEST_SOURCES * 32], src_in_err[TEST_SOURCES]; u8 src_err_list[TEST_SOURCES], *recov[TEST_SOURCES]; - struct perf start, stop; + struct perf start; // Pick test parameters k = 10; @@ -160,13 +203,9 @@ int main(int argc, char *argv[]) } gf_gen_rs_matrix(a, m, k); - ec_init_tables(k, m - k, &a[k * k], g_tbls); - REF_FUNCTION(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); - for (i = 0; i < k; i++) { - FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, update_buffs[i], - &update_buffs[k]); - } + encode_update_test_ref(m, k, g_tbls, buffs, a); + encode_update_test(m, k, g_tbls, update_buffs, a); for (i = 0; i < m - k; i++) { if (0 != memcmp(update_buffs[k + i], buffs[k + i], TEST_LEN(m))) { printf("\nupdate_buffs%d :", i); @@ -178,58 +217,34 @@ int main(int argc, char *argv[]) } #ifdef DO_REF_PERF - REF_FUNCTION(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); // Start encode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Make parity vects - ec_init_tables(k, m - k, &a[k * k], g_tbls); - REF_FUNCTION(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, encode_update_test_ref(m, k, g_tbls, buffs, a)); printf(xstr(REF_FUNCTION) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (m) * rtest); + perf_print(start, (long long)(TEST_LEN(m)) * (m)); #endif - for (i = 0; i < k; i++) { - FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, perf_update_buffs[i], - &perf_update_buffs[k]); - } + // Start encode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Make parity vects - ec_init_tables(k, m - k, &a[k * k], g_tbls); - for (i = 0; i < k; i++) { - FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, - perf_update_buffs[i], &perf_update_buffs[k]); - } - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, + encode_update_test(m, k, g_tbls, perf_update_buffs, a)); printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (m) * rtest); + perf_print(start, (long long)(TEST_LEN(m)) * (m)); // Start encode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Make parity vects - ec_init_tables(k, m - k, &a[k * k], g_tbls); - FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, 0, g_tbls, perf_update_buffs[0], - &perf_update_buffs[k]); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, + // Make parity vects + ec_init_tables(k, m - k, &a[k * k], g_tbls); + FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, 0, g_tbls, perf_update_buffs[0], + &perf_update_buffs[k])); printf(xstr(FUNCTION_UNDER_TEST) "_single_src" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (m - k + 1) * rtest); + perf_print(start, (long long)(TEST_LEN(m)) * (m - k + 1)); // Start encode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Make parity vects - FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, 0, g_tbls, perf_update_buffs[0], - &perf_update_buffs[k]); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, + // Make parity vects + FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, 0, g_tbls, perf_update_buffs[0], + &perf_update_buffs[k])); printf(xstr(FUNCTION_UNDER_TEST) "_single_src_simple" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (m - k + 1) * rtest); + perf_print(start, (long long)(TEST_LEN(m)) * (m - k + 1)); for (i = k; i < m; i++) { memset(update_buffs[i], 0, TEST_LEN(m)); // initialize the destination buffer to be zero for update function @@ -238,68 +253,26 @@ int main(int argc, char *argv[]) FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, update_buffs[i], &update_buffs[k]); } - // Construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) - r++; - recov[i] = update_buffs[r]; - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - if (gf_invert_matrix(b, d, k) < 0) { - printf("BAD MATRIX\n"); + decode_test(m, k, update_buffs, recov, a, src_in_err, src_err_list, + nerrs, g_tbls, temp_buffs); + BENCHMARK(&start, BENCHMARK_TIME, check = + decode_test(m, k, update_buffs, recov, a, src_in_err, src_err_list, + nerrs, g_tbls, perf_update_buffs)); + if (check) { + printf("BAD_MATRIX\n"); return -1; } - for (i = 0; i < nerrs; i++) - for (j = 0; j < k; j++) - c[k * i + j] = d[k * src_err_list[i] + j]; - - // Recover data - ec_init_tables(k, nerrs, c, g_tbls); - for (i = 0; i < k; i++) { - FUNCTION_UNDER_TEST(TEST_LEN(m), k, nerrs, i, g_tbls, recov[i], temp_buffs); - } - // Start decode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) - r++; - recov[i] = update_buffs[r]; - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix(b, d, k) < 0) { - printf("BAD MATRIX\n"); - return -1; - } - - for (i = 0; i < nerrs; i++) - for (j = 0; j < k; j++) - c[k * i + j] = d[k * src_err_list[i] + j]; - - // Recover data - ec_init_tables(k, nerrs, c, g_tbls); - for (i = 0; i < k; i++) { - FUNCTION_UNDER_TEST(TEST_LEN(m), k, nerrs, i, g_tbls, recov[i], - perf_update_buffs); - } - } - perf_stop(&stop); - for (i = 0; i < nerrs; i++) { if (0 != memcmp(temp_buffs[i], update_buffs[src_err_list[i]], TEST_LEN(m))) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); + printf("Fail error recovery (%d, %d, %d) - \n", m, k, nerrs); return -1; } } printf(xstr(FUNCTION_UNDER_TEST) "_decode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (k + nerrs) * rtest); + perf_print(start, (long long)(TEST_LEN(m)) * (k + nerrs)); printf("done all: Pass\n"); return 0; diff --git a/erasure_code/gf_vect_dot_prod_1tbl.c b/erasure_code/gf_vect_dot_prod_1tbl.c index 8ce2fc5..1d23eb6 100644 --- a/erasure_code/gf_vect_dot_prod_1tbl.c +++ b/erasure_code/gf_vect_dot_prod_1tbl.c @@ -38,7 +38,6 @@ // Cached test, loop many times over small dataset # define TEST_SOURCES 10 # define TEST_LEN 8*1024 -# define TEST_LOOPS 4000 # define TEST_TYPE_STR "_warm" #else # ifndef TEST_CUSTOM @@ -46,13 +45,9 @@ # define TEST_SOURCES 10 # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN GT_L3_CACHE / TEST_SOURCES -# define TEST_LOOPS 10 # define TEST_TYPE_STR "_cold" # else # define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif # endif #endif @@ -99,12 +94,26 @@ void gf_vect_dot_prod_ref(int len, int vlen, u8 * v, u8 ** src, u8 * dest) } } +void gf_vect_dot_prod_mult(int len, int vlen, u8 * v, u8 ** src, u8 * dest) +{ + int i, j; + u8 s; + for (i = 0; i < len; i++) { + s = 0; + for (j = 0; j < vlen; j++) { + s ^= gf_mul_table[v[j] * 256 + src[j][i]]; + } + dest[i] = s; + } + +} + int main(void) { - int i, j, k; - u8 s, vec[TEST_SOURCES], dest1[TEST_LEN], dest2[TEST_LEN]; + int i, j; + u8 vec[TEST_SOURCES], dest1[TEST_LEN], dest2[TEST_LEN]; u8 *matrix[TEST_SOURCES]; - struct perf start, stop; + struct perf start; mk_gf_field(); mk_gf_mul_table(gf_mul_table); @@ -122,38 +131,15 @@ int main(void) } - gf_vect_dot_prod_ref(TEST_LEN, TEST_SOURCES, vec, matrix, dest1); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) - gf_vect_dot_prod_ref(TEST_LEN, TEST_SOURCES, vec, matrix, dest1); - - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, + gf_vect_dot_prod_ref(TEST_LEN, TEST_SOURCES, vec, matrix, dest1)); printf("gf_vect_dot_prod_2tbl" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * i); + perf_print(start, (long long)TEST_LEN * (TEST_SOURCES + 1)); - // Warm up mult tables - for (i = 0; i < TEST_LEN; i++) { - s = 0; - for (j = 0; j < TEST_SOURCES; j++) { - s ^= gf_mul_table[vec[j] * 256 + matrix[j][i]]; - } - dest2[i] = s; - } - - perf_start(&start); - for (k = 0; k < TEST_LOOPS; k++) { - for (i = 0; i < TEST_LEN; i++) { - s = 0; - for (j = 0; j < TEST_SOURCES; j++) { - s ^= gf_mul_table[vec[j] * 256 + matrix[j][i]]; - } - dest2[i] = s; - } - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, + gf_vect_dot_prod_mult(TEST_LEN, TEST_SOURCES, vec, matrix, dest2)); printf("gf_vect_dot_prod_1tbl" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * k); + perf_print(start, (long long)TEST_LEN * (TEST_SOURCES + 1)); // Compare with reference function if (0 != memcmp(dest1, dest2, TEST_LEN)) { diff --git a/erasure_code/gf_vect_dot_prod_perf.c b/erasure_code/gf_vect_dot_prod_perf.c index c6bf0b2..bd2b555 100644 --- a/erasure_code/gf_vect_dot_prod_perf.c +++ b/erasure_code/gf_vect_dot_prod_perf.c @@ -45,7 +45,6 @@ // Cached test, loop many times over small dataset # define TEST_SOURCES 10 # define TEST_LEN 8*1024 -# define TEST_LOOPS 40000 # define TEST_TYPE_STR "_warm" #else # ifndef TEST_CUSTOM @@ -53,13 +52,9 @@ # define TEST_SOURCES 10 # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64-1)) -# define TEST_LOOPS 100 # define TEST_TYPE_STR "_cold" # else # define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif # endif #endif @@ -88,13 +83,24 @@ void dump_matrix(unsigned char **s, int k, int m) printf("\n"); } +void vect_dot_prod_perf(void (*fun_ptr) + (int, int, unsigned char *, unsigned char **, unsigned char *), + u8 * g, u8 * g_tbls, u8 ** buffs, u8 * dest_ref) +{ + int j; + for (j = 0; j < TEST_SOURCES; j++) + gf_vect_mul_init(g[j], &g_tbls[j * 32]); + + (*fun_ptr) (TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); +} + int main(int argc, char *argv[]) { int i, j; void *buf; u8 g[TEST_SOURCES], g_tbls[TEST_SOURCES * 32], *dest, *dest_ref; u8 *temp_buff, *buffs[TEST_SOURCES]; - struct perf start, stop; + struct perf start; printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d\n", TEST_SOURCES, TEST_LEN); @@ -138,36 +144,20 @@ int main(int argc, char *argv[]) for (i = 0; i < TEST_SOURCES; i++) g[i] = rand(); - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - #ifdef DO_REF_PERF - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, + vect_dot_prod_perf(&gf_vect_dot_prod_base, g, g_tbls, buffs, dest_ref) + ); printf("gf_vect_dot_prod_base" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * i); + perf_print(start, (long long)TEST_LEN * (TEST_SOURCES + 1)); +#else + vect_dot_prod_perf(&gf_vect_dot_prod_base, g, g_tbls, buffs, dest_ref); #endif - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, + vect_dot_prod_perf(&FUNCTION_UNDER_TEST, g, g_tbls, buffs, dest)); printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * i); + perf_print(start, (long long)TEST_LEN * (TEST_SOURCES + 1)); if (0 != memcmp(dest_ref, dest, TEST_LEN)) { printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test\n"); diff --git a/erasure_code/gf_vect_mul_perf.c b/erasure_code/gf_vect_mul_perf.c index 90ec797..58194cc 100644 --- a/erasure_code/gf_vect_mul_perf.c +++ b/erasure_code/gf_vect_mul_perf.c @@ -37,7 +37,6 @@ #ifdef CACHED_TEST // Cached test, loop many times over small dataset # define TEST_LEN 8*1024 -# define TEST_LOOPS 4000000 # define TEST_TYPE_STR "_warm" #else # ifndef TEST_CUSTOM @@ -45,13 +44,9 @@ # define TEST_SOURCES 10 # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ # define TEST_LEN GT_L3_CACHE / 2 -# define TEST_LOOPS 1000 # define TEST_TYPE_STR "_cold" # else # define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif # endif #endif @@ -59,16 +54,19 @@ typedef unsigned char u8; +void gf_vect_mul_perf(u8 a, u8 * gf_const_tbl, u8 * buff1, u8 * buff2) +{ + gf_vect_mul_init(a, gf_const_tbl); + gf_vect_mul(TEST_LEN, gf_const_tbl, buff1, buff2); +} + int main(int argc, char *argv[]) { - int i; u8 *buff1, *buff2, gf_const_tbl[64], a = 2; - struct perf start, stop; + struct perf start; printf("gf_vect_mul_perf:\n"); - gf_vect_mul_init(a, gf_const_tbl); - // Allocate large mem region buff1 = (u8 *) malloc(TEST_LEN); buff2 = (u8 *) malloc(TEST_LEN); @@ -80,20 +78,13 @@ int main(int argc, char *argv[]) memset(buff1, 0, TEST_LEN); memset(buff2, 0, TEST_LEN); - gf_vect_mul(TEST_LEN, gf_const_tbl, buff1, buff2); - printf("Start timed tests\n"); fflush(0); - gf_vect_mul(TEST_LEN, gf_const_tbl, buff1, buff2); - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - gf_vect_mul_init(a, gf_const_tbl); - gf_vect_mul(TEST_LEN, gf_const_tbl, buff1, buff2); - } - perf_stop(&stop); + BENCHMARK(&start, BENCHMARK_TIME, gf_vect_mul_perf(a, gf_const_tbl, buff1, buff2)); + printf("gf_vect_mul" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * i); + perf_print(start, (long long)TEST_LEN); return 0; } diff --git a/examples/ec/ec_piggyback_example.c b/examples/ec/ec_piggyback_example.c index eb2d374..e19abc0 100644 --- a/examples/ec/ec_piggyback_example.c +++ b/examples/ec/ec_piggyback_example.c @@ -334,16 +334,12 @@ int main(int argc, char *argv[]) ec_encode_data(len / 2, k2, p2, g_tbls, frag_ptrs, parity_ptrs); if (benchmark) { - struct perf start, stop; - unsigned long long iterations = (1ull << 32) / (m * len); - perf_start(&start); - for (i = 0; i < iterations; i++) { - ec_encode_data(len / 2, k2, p2, g_tbls, frag_ptrs, - parity_ptrs); - } - perf_stop(&stop); + struct perf start; + BENCHMARK(&start, BENCHMARK_TIME, + ec_encode_data(len / 2, k2, p2, g_tbls, frag_ptrs, + parity_ptrs)); printf("ec_piggyback_encode_std: "); - perf_print(stop, start, iterations * m2 * len / 2); + perf_print(start, m2 * len / 2); } } else { // Sparse matrix optimization - use fact that input matrix is sparse @@ -380,18 +376,14 @@ int main(int argc, char *argv[]) &parity_ptrs[p]); if (benchmark) { - struct perf start, stop; - unsigned long long iterations = (1ull << 32) / (m * len); - perf_start(&start); - for (i = 0; i < iterations; i++) { - ec_encode_data(len / 2, k, p, g_tbls_faster, frag_ptrs, - parity_ptrs); - ec_encode_data(len / 2, k2, p, &g_tbls[k2 * p * 32], frag_ptrs, - &parity_ptrs[p]); - } - perf_stop(&stop); + struct perf start; + BENCHMARK(&start, BENCHMARK_TIME, + ec_encode_data(len / 2, k, p, g_tbls_faster, frag_ptrs, + parity_ptrs); + ec_encode_data(len / 2, k2, p, &g_tbls[k2 * p * 32], + frag_ptrs, &parity_ptrs[p])); printf("ec_piggyback_encode_sparse: "); - perf_print(stop, start, iterations * m2 * len / 2); + perf_print(start, m2 * len / 2); } } @@ -429,16 +421,12 @@ int main(int argc, char *argv[]) ec_encode_data(len / 2, k2, nerrs2, g_tbls, recover_srcs, recover_outp); if (benchmark) { - struct perf start, stop; - unsigned long long iterations = (1ull << 32) / (k * len); - perf_start(&start); - for (i = 0; i < iterations; i++) { - ec_encode_data(len / 2, k2, nerrs2, g_tbls, recover_srcs, - recover_outp); - } - perf_stop(&stop); + struct perf start; + BENCHMARK(&start, BENCHMARK_TIME, + ec_encode_data(len / 2, k2, nerrs2, g_tbls, recover_srcs, + recover_outp)); printf("ec_piggyback_decode: "); - perf_print(stop, start, iterations * (k2 + nerrs2) * len / 2); + perf_print(start, (k2 + nerrs2) * len / 2); } // Check that recovered buffers are the same as original printf(" check recovery of block {"); diff --git a/igzip/igzip_build_hash_table_perf.c b/igzip/igzip_build_hash_table_perf.c index c4891db..c402c91 100644 --- a/igzip/igzip_build_hash_table_perf.c +++ b/igzip/igzip_build_hash_table_perf.c @@ -7,7 +7,6 @@ #include "test.h" #define DICT_LEN 32*1024 -#define ITERATIONS 100000 extern void isal_deflate_hash(struct isal_zstream *stream, uint8_t * dict, int dict_len); @@ -21,7 +20,7 @@ void create_rand_data(uint8_t * data, uint32_t size) int main(int argc, char *argv[]) { - int i, iterations = ITERATIONS; + int time = BENCHMARK_TIME; struct isal_zstream stream; uint8_t dict[DICT_LEN]; uint32_t dict_len = DICT_LEN; @@ -29,18 +28,12 @@ int main(int argc, char *argv[]) stream.level = 0; create_rand_data(dict, dict_len); - struct perf start, stop; - perf_start(&start); - - for (i = 0; i < iterations; i++) { - isal_deflate_hash(&stream, dict, dict_len); - } - - perf_stop(&stop); + struct perf start; + BENCHMARK(&start, time, isal_deflate_hash(&stream, dict, dict_len)); printf("igzip_build_hash_table_perf:\n"); - printf(" in_size=%u iter=%d ", dict_len, i); - perf_print(stop, start, (long long)dict_len * i); + printf(" in_size=%u ", dict_len); + perf_print(start, (long long)dict_len); return 0; } diff --git a/igzip/igzip_file_perf.c b/igzip/igzip_file_perf.c index 0863386..c04ed24 100644 --- a/igzip/igzip_file_perf.c +++ b/igzip/igzip_file_perf.c @@ -37,10 +37,6 @@ #include "test.h" #define BUF_SIZE 1024 -#define MIN_TEST_LOOPS 10 -#ifndef RUN_MEM_SIZE -# define RUN_MEM_SIZE 500000000 -#endif int level_size_buf[10] = { #ifdef ISAL_DEF_LVL0_DEFAULT @@ -95,8 +91,6 @@ int level_size_buf[10] = { #endif }; -struct isal_zstream stream; - int usage(void) { fprintf(stderr, @@ -104,7 +98,7 @@ int usage(void) " -h help\n" " -X use compression level X with 0 <= X <= 1\n" " -b input buffer size, 0 buffers all the input\n" - " -i number of iterations (at least 1)\n" + " -i