From fd6f695622cbfd07c8c847a049000256fb245967 Mon Sep 17 00:00:00 2001 From: Joel Luth Date: Wed, 8 May 2019 22:39:44 -0500 Subject: [PATCH 01/10] print parameters in output For clarity in how the test was run, print the buffer size and latency count parameters in the test output --- main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.c b/main.c index 6205555..503d6fe 100644 --- a/main.c +++ b/main.c @@ -502,6 +502,7 @@ int main(void) printf("\n"); printf("==========================================================================\n"); printf("== Memory bandwidth tests ==\n"); + printf("== size Bytes: %d ==\n", bufsize); printf("== ==\n"); printf("== Note 1: 1MB = 1000000 bytes ==\n"); printf("== Note 2: Results for 'copy' tests show how many bytes can be ==\n"); @@ -560,6 +561,8 @@ int main(void) printf("\n"); printf("==========================================================================\n"); printf("== Memory latency test ==\n"); + printf("== latbench_size Bytes: %d ==\n", latbench_size); + printf("== latbench_count: %d ==\n", latbench_count); printf("== ==\n"); printf("== Average time is measured for random memory accesses in the buffers ==\n"); printf("== of different sizes. The larger is the buffer, the more significant ==\n"); From 352f49e19f7669f0c135b4d134e012f0afefdd01 Mon Sep 17 00:00:00 2001 From: Joel Luth Date: Wed, 8 May 2019 23:29:50 -0500 Subject: [PATCH 02/10] add arguments add arguments for buffer size, latency size, latency count. Use the #deifnes as defaults --- main.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 503d6fe..734c8e5 100644 --- a/main.c +++ b/main.c @@ -49,6 +49,8 @@ # define LATBENCH_COUNT 10000000 #endif +char *progname; + #ifdef __linux__ static void *mmap_framebuffer(size_t *fbsize) { @@ -480,12 +482,29 @@ int latency_bench(int size, int count, int use_hugepage) return 1; } -int main(void) +int main(int argc, char *argv[]) { - int latbench_size = SIZE * 2, latbench_count = LATBENCH_COUNT; + int ch; + int latbench_size = SIZE * 2, latbench_count = LATBENCH_COUNT; + size_t bufsize = SIZE; + + progname = argv[0]; + while ((ch = getopt(argc, argv, "c:l:s:")) != -1) { + switch (ch) { + case 'c': + latbench_count = atoi(optarg); + break; + case 'l': + latbench_size = atoi(optarg); + break; + case 's': + bufsize = atoi(optarg); + break; + } + } + int64_t *srcbuf, *dstbuf, *tmpbuf; void *poolbuf; - size_t bufsize = SIZE; #ifdef __linux__ size_t fbsize = 0; int64_t *fbbuf = mmap_framebuffer(&fbsize); From 32f0c71dfa9950d59a9b6fd4bfb2175cce08cde3 Mon Sep 17 00:00:00 2001 From: Joel Luth Date: Wed, 8 May 2019 23:38:32 -0500 Subject: [PATCH 03/10] make blocksize an argument --- main.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 734c8e5..3384443 100644 --- a/main.c +++ b/main.c @@ -487,10 +487,14 @@ int main(int argc, char *argv[]) int ch; int latbench_size = SIZE * 2, latbench_count = LATBENCH_COUNT; size_t bufsize = SIZE; + int blocksize = BLOCKSIZE; progname = argv[0]; - while ((ch = getopt(argc, argv, "c:l:s:")) != -1) { + while ((ch = getopt(argc, argv, "b:c:l:s:")) != -1) { switch (ch) { + case 'b': + blocksize = atoi(optarg); + break; case 'c': latbench_count = atoi(optarg); break; @@ -508,7 +512,7 @@ int main(int argc, char *argv[]) #ifdef __linux__ size_t fbsize = 0; int64_t *fbbuf = mmap_framebuffer(&fbsize); - fbsize = (fbsize / BLOCKSIZE) * BLOCKSIZE; + fbsize = (fbsize / blocksize) * blocksize; #endif printf("tinymembench v" VERSION " (simple benchmark for memory throughput and latency)\n"); @@ -516,12 +520,13 @@ int main(int argc, char *argv[]) poolbuf = alloc_four_nonaliased_buffers((void **)&srcbuf, bufsize, (void **)&dstbuf, bufsize, - (void **)&tmpbuf, BLOCKSIZE, + (void **)&tmpbuf, blocksize, NULL, 0); printf("\n"); printf("==========================================================================\n"); printf("== Memory bandwidth tests ==\n"); - printf("== size Bytes: %d ==\n", bufsize); + printf("== size Bytes: %d ==\n", bufsize); + printf("== blocksize Bytes: %d ==\n", blocksize); printf("== ==\n"); printf("== Note 1: 1MB = 1000000 bytes ==\n"); printf("== Note 2: Results for 'copy' tests show how many bytes can be ==\n"); @@ -534,13 +539,13 @@ int main(int argc, char *argv[]) printf("== brackets ==\n"); printf("==========================================================================\n\n"); - bandwidth_bench(dstbuf, srcbuf, tmpbuf, bufsize, BLOCKSIZE, " ", c_benchmarks); + bandwidth_bench(dstbuf, srcbuf, tmpbuf, bufsize, blocksize, " ", c_benchmarks); printf(" ---\n"); - bandwidth_bench(dstbuf, srcbuf, tmpbuf, bufsize, BLOCKSIZE, " ", libc_benchmarks); + bandwidth_bench(dstbuf, srcbuf, tmpbuf, bufsize, blocksize, " ", libc_benchmarks); bench_info *bi = get_asm_benchmarks(); if (bi->f) { printf(" ---\n"); - bandwidth_bench(dstbuf, srcbuf, tmpbuf, bufsize, BLOCKSIZE, " ", bi); + bandwidth_bench(dstbuf, srcbuf, tmpbuf, bufsize, blocksize, " ", bi); } #ifdef __linux__ @@ -571,7 +576,7 @@ int main(int argc, char *argv[]) srcbuf = fbbuf; if (bufsize > fbsize) bufsize = fbsize; - bandwidth_bench(dstbuf, srcbuf, tmpbuf, bufsize, BLOCKSIZE, " ", bi); + bandwidth_bench(dstbuf, srcbuf, tmpbuf, bufsize, blocksize, " ", bi); } #endif From d40febf15b7c6b5dca09803c561bb61cd0263e33 Mon Sep 17 00:00:00 2001 From: Joel Luth Date: Wed, 8 May 2019 23:40:02 -0500 Subject: [PATCH 04/10] try to get text to line up --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 3384443..186f487 100644 --- a/main.c +++ b/main.c @@ -585,8 +585,8 @@ int main(int argc, char *argv[]) printf("\n"); printf("==========================================================================\n"); printf("== Memory latency test ==\n"); - printf("== latbench_size Bytes: %d ==\n", latbench_size); - printf("== latbench_count: %d ==\n", latbench_count); + printf("== latbench_size Bytes: %d ==\n", latbench_size); + printf("== latbench_count: %d ==\n", latbench_count); printf("== ==\n"); printf("== Average time is measured for random memory accesses in the buffers ==\n"); printf("== of different sizes. The larger is the buffer, the more significant ==\n"); From 727253b18ea416d62d9016bbe6522fe7707ef43c Mon Sep 17 00:00:00 2001 From: Joel Luth Date: Wed, 8 May 2019 23:47:30 -0500 Subject: [PATCH 05/10] add usage function --- main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 186f487..61bc379 100644 --- a/main.c +++ b/main.c @@ -482,6 +482,18 @@ int latency_bench(int size, int count, int use_hugepage) return 1; } +static void +usage() +{ + fprintf(stderr, "usage: %s [-s buffer size -b blocksize -l latency max size -c latency count]\n", + progname); + fprintf(stderr, "\t-b Memory blocksize in Bytes <%d>\n", BLOCKSIZE); + fprintf(stderr, "\t-s Memory buffer size in Bytes <%d>\n", SIZE); + fprintf(stderr, "\t-l Latency test maximum buffer size in Bytes <%d>\n", SIZE * 2); + fprintf(stderr, "\t-c Latency count <%d>\n", LATBENCH_COUNT); + exit(EXIT_FAILURE); +} + int main(int argc, char *argv[]) { int ch; @@ -490,7 +502,7 @@ int main(int argc, char *argv[]) int blocksize = BLOCKSIZE; progname = argv[0]; - while ((ch = getopt(argc, argv, "b:c:l:s:")) != -1) { + while ((ch = getopt(argc, argv, "hb:c:l:s:")) != -1) { switch (ch) { case 'b': blocksize = atoi(optarg); @@ -504,6 +516,8 @@ int main(int argc, char *argv[]) case 's': bufsize = atoi(optarg); break; + case 'h': + usage(); } } From 6fd8638a95938483bb7224c7bb635a5823c34ba0 Mon Sep 17 00:00:00 2001 From: Joel Luth Date: Wed, 8 May 2019 23:52:18 -0500 Subject: [PATCH 06/10] increment version --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 451f34d..7c1f9ff 100644 --- a/version.h +++ b/version.h @@ -1 +1 @@ -#define VERSION "0.4.9" +#define VERSION "0.5.0" From a7e1be6e2dcfa6b80499dc08883c5845154fc93b Mon Sep 17 00:00:00 2001 From: Joel Luth Date: Thu, 9 May 2019 19:03:20 -0500 Subject: [PATCH 07/10] Include unistd.h for all *nix clang-8 complained about this missing when building in a FreeBSD cross-compiler --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 61bc379..372e0ed 100644 --- a/main.c +++ b/main.c @@ -28,8 +28,10 @@ #include #include -#ifdef __linux__ +#if !defined(_WIN64) && !defined(_WIN32) #include +#endif +#ifdef __linux__ #include #include #include From 93e69c9a6261c5291f9e8226884d6dbe7f124ba3 Mon Sep 17 00:00:00 2001 From: Joel Luth Date: Thu, 9 May 2019 20:34:43 -0500 Subject: [PATCH 08/10] fix printf format for size_t clang-8 complains about this --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 372e0ed..184ebec 100644 --- a/main.c +++ b/main.c @@ -541,7 +541,7 @@ int main(int argc, char *argv[]) printf("\n"); printf("==========================================================================\n"); printf("== Memory bandwidth tests ==\n"); - printf("== size Bytes: %d ==\n", bufsize); + printf("== size Bytes: %zu ==\n", bufsize); printf("== blocksize Bytes: %d ==\n", blocksize); printf("== ==\n"); printf("== Note 1: 1MB = 1000000 bytes ==\n"); From be3bde48dcc5d7b68147a4a6891cc8ec3056d179 Mon Sep 17 00:00:00 2001 From: Joel Luth Date: Sun, 2 Jun 2019 15:25:23 -0500 Subject: [PATCH 09/10] revert version for ssvb PR repo owner should select the version number if accepted --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 7c1f9ff..451f34d 100644 --- a/version.h +++ b/version.h @@ -1 +1 @@ -#define VERSION "0.5.0" +#define VERSION "0.4.9" From 2187554f1fdfdf7cf2610f3f675d71dd96c6692b Mon Sep 17 00:00:00 2001 From: Joel Luth Date: Sun, 2 Jun 2019 15:32:03 -0500 Subject: [PATCH 10/10] restore version to 0.5.0 I plan to increment version to 0.5.0 for this change --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 451f34d..7c1f9ff 100644 --- a/version.h +++ b/version.h @@ -1 +1 @@ -#define VERSION "0.4.9" +#define VERSION "0.5.0"