From d4d20820bd41a88a1a0abe7c32ee11c1328f2c1c Mon Sep 17 00:00:00 2001 From: Meng Mengmeng Date: Fri, 20 Nov 2015 06:25:34 +0800 Subject: Add a option which could set the benchmark unit properly. For benchmarks, the units are varied e.g. GB/S, FPS, score and so on. So we need to make a choice for every benchmark. Signed-off-by: Meng Mengmeng Reviewed-by: Ruiling Song --- benchmark/benchmark_copy_buf.cpp | 2 +- benchmark/benchmark_copy_buffer.cpp | 2 +- benchmark/benchmark_copy_buffer_to_image.cpp | 2 +- benchmark/benchmark_copy_image.cpp | 2 +- benchmark/benchmark_copy_image_to_buffer.cpp | 2 +- benchmark/benchmark_read_buffer.cpp | 2 +- benchmark/benchmark_read_image.cpp | 2 +- benchmark/benchmark_use_host_ptr_buffer.cpp | 2 +- utests/utest.hpp | 12 ++++++------ utests/vload_bench.cpp | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/benchmark/benchmark_copy_buf.cpp b/benchmark/benchmark_copy_buf.cpp index e21c936f..92abf547 100644 --- a/benchmark/benchmark_copy_buf.cpp +++ b/benchmark/benchmark_copy_buf.cpp @@ -48,4 +48,4 @@ double benchmark_copy_buf(void) return BANDWIDTH(sz * sizeof(char) * 100, elapsed); } -MAKE_BENCHMARK_FROM_FUNCTION(benchmark_copy_buf); +MAKE_BENCHMARK_FROM_FUNCTION(benchmark_copy_buf, "GB/S"); diff --git a/benchmark/benchmark_copy_buffer.cpp b/benchmark/benchmark_copy_buffer.cpp index 88983a79..951d8e6c 100644 --- a/benchmark/benchmark_copy_buffer.cpp +++ b/benchmark/benchmark_copy_buffer.cpp @@ -48,7 +48,7 @@ double benchmark_copy_buffer_ ##T(void) \ return BANDWIDTH(sz * sizeof(M) * 2 * 100, elapsed); \ } \ \ -MAKE_BENCHMARK_FROM_FUNCTION_KEEP_PROGRAM(benchmark_copy_buffer_ ##T,true); +MAKE_BENCHMARK_FROM_FUNCTION_KEEP_PROGRAM(benchmark_copy_buffer_ ##T, true, "GB/S"); BENCH_COPY_BUFFER(uchar,"bench_copy_buffer_uchar",unsigned char) BENCH_COPY_BUFFER(ushort,"bench_copy_buffer_ushort",unsigned short) diff --git a/benchmark/benchmark_copy_buffer_to_image.cpp b/benchmark/benchmark_copy_buffer_to_image.cpp index 2177cfe0..befca6b7 100644 --- a/benchmark/benchmark_copy_buffer_to_image.cpp +++ b/benchmark/benchmark_copy_buffer_to_image.cpp @@ -63,4 +63,4 @@ double benchmark_copy_buffer_to_image(void) return BANDWIDTH(sz * 100, elapsed); } -MAKE_BENCHMARK_FROM_FUNCTION(benchmark_copy_buffer_to_image); +MAKE_BENCHMARK_FROM_FUNCTION(benchmark_copy_buffer_to_image, "GB/S"); diff --git a/benchmark/benchmark_copy_image.cpp b/benchmark/benchmark_copy_image.cpp index 92dffc91..ad132d7a 100644 --- a/benchmark/benchmark_copy_image.cpp +++ b/benchmark/benchmark_copy_image.cpp @@ -63,7 +63,7 @@ double benchmark_copy_image_ ##T(void) \ return BANDWIDTH(sz * sizeof(M)*2 * 100, elapsed); \ } \ \ -MAKE_BENCHMARK_FROM_FUNCTION_KEEP_PROGRAM(benchmark_copy_image_ ##T,true); +MAKE_BENCHMARK_FROM_FUNCTION_KEEP_PROGRAM(benchmark_copy_image_ ##T, true, "GB/S"); BENCH_COPY_IMAGE(uchar,unsigned char,CL_UNSIGNED_INT8) BENCH_COPY_IMAGE(ushort,unsigned short,CL_UNSIGNED_INT16) diff --git a/benchmark/benchmark_copy_image_to_buffer.cpp b/benchmark/benchmark_copy_image_to_buffer.cpp index debed093..35e2e0d2 100644 --- a/benchmark/benchmark_copy_image_to_buffer.cpp +++ b/benchmark/benchmark_copy_image_to_buffer.cpp @@ -61,4 +61,4 @@ double benchmark_copy_image_to_buffer(void) return BANDWIDTH(sz * 100, elapsed); } -MAKE_BENCHMARK_FROM_FUNCTION(benchmark_copy_image_to_buffer); +MAKE_BENCHMARK_FROM_FUNCTION(benchmark_copy_image_to_buffer, "GB/S"); diff --git a/benchmark/benchmark_read_buffer.cpp b/benchmark/benchmark_read_buffer.cpp index 431f42aa..855e2156 100644 --- a/benchmark/benchmark_read_buffer.cpp +++ b/benchmark/benchmark_read_buffer.cpp @@ -48,4 +48,4 @@ double benchmark_read_buffer(void) return BANDWIDTH(sz * sizeof(float) * 2 * 100, elapsed); } -MAKE_BENCHMARK_FROM_FUNCTION(benchmark_read_buffer); +MAKE_BENCHMARK_FROM_FUNCTION(benchmark_read_buffer, "GB/S"); diff --git a/benchmark/benchmark_read_image.cpp b/benchmark/benchmark_read_image.cpp index e3aa5bd0..6e64f5fb 100644 --- a/benchmark/benchmark_read_image.cpp +++ b/benchmark/benchmark_read_image.cpp @@ -66,4 +66,4 @@ double benchmark_read_image(void) return BANDWIDTH(sz * sizeof(float) * 2 * 100, elapsed); } -MAKE_BENCHMARK_FROM_FUNCTION(benchmark_read_image); +MAKE_BENCHMARK_FROM_FUNCTION(benchmark_read_image, "GB/S"); diff --git a/benchmark/benchmark_use_host_ptr_buffer.cpp b/benchmark/benchmark_use_host_ptr_buffer.cpp index 9e3d1551..bc33afd6 100644 --- a/benchmark/benchmark_use_host_ptr_buffer.cpp +++ b/benchmark/benchmark_use_host_ptr_buffer.cpp @@ -37,4 +37,4 @@ double benchmark_use_host_ptr_buffer(void) return BANDWIDTH(n*sizeof(uint32_t)*100*2, elapsed); } -MAKE_BENCHMARK_FROM_FUNCTION(benchmark_use_host_ptr_buffer); +MAKE_BENCHMARK_FROM_FUNCTION(benchmark_use_host_ptr_buffer, "GB/S"); diff --git a/utests/utest.hpp b/utests/utest.hpp index cda75459..6ecbaf79 100644 --- a/utests/utest.hpp +++ b/utests/utest.hpp @@ -101,12 +101,12 @@ struct UTest static const UTest __##FN##__(__ANON__##FN##__, #FN, true); /*! Turn a function into a unit performance test */ -#define MAKE_BENCHMARK_FROM_FUNCTION_KEEP_PROGRAM(FN, KEEP_PROGRAM) \ - static void __ANON__##FN##__(void) { BENCHMARK(FN()); } \ +#define MAKE_BENCHMARK_FROM_FUNCTION_KEEP_PROGRAM(FN, KEEP_PROGRAM, ...) \ + static void __ANON__##FN##__(void) { BENCHMARK(FN(), __VA_ARGS__); } \ static const UTest __##FN##__(__ANON__##FN##__, #FN, true, false, !(KEEP_PROGRAM)); -#define MAKE_BENCHMARK_FROM_FUNCTION(FN) \ - static void __ANON__##FN##__(void) { BENCHMARK(FN()); } \ +#define MAKE_BENCHMARK_FROM_FUNCTION(FN, ...) \ + static void __ANON__##FN##__(void) { BENCHMARK(FN(), __VA_ARGS__); } \ static const UTest __##FN##__(__ANON__##FN##__, #FN, true); @@ -138,12 +138,12 @@ struct UTest } \ } while (0) -#define BENCHMARK(EXPR) \ +#define BENCHMARK(EXPR, ...) \ do { \ double ret = 0;\ try { \ ret = EXPR; \ - std::cout << " [Result: " << std::fixed<< std::setprecision(3) << ret << " GB/S] [SUCCESS]" << std::endl; \ + std::cout << " [Result: " << std::fixed<< std::setprecision(3) << ret << " " << __VA_ARGS__ << "] [SUCCESS]" << std::endl; \ UTest::retStatistics.passCount += 1; \ } \ catch (Exception e) { \ diff --git a/utests/vload_bench.cpp b/utests/vload_bench.cpp index ddfaaee7..44c1dba7 100644 --- a/utests/vload_bench.cpp +++ b/utests/vload_bench.cpp @@ -89,7 +89,7 @@ static double vload_bench_ ##kT(void) \ } \ return totBandwidth/j;\ }\ -MAKE_BENCHMARK_FROM_FUNCTION_KEEP_PROGRAM(vload_bench_ ##kT, true) +MAKE_BENCHMARK_FROM_FUNCTION_KEEP_PROGRAM(vload_bench_ ##kT, true, "GB/S") #ifdef BUILD_BENCHMARK VLOAD_BENCH(uint8_t, uchar) -- cgit v1.2.3