[Beignet] [PATCH 1/4] Add a option which could set the benchmark unitsi properly.

Meng Mengmeng mengmeng.meng at intel.com
Tue Nov 17 19:42:27 PST 2015


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 <mengmeng.meng at intel.com>
---
 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 e21c936..92abf54 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 88983a7..951d8e6 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 2177cfe..befca6b 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 92dffc9..ad132d7 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 debed09..35e2e0d 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 431f42a..855e215 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 e3aa5bd..6e64f5f 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 9e3d155..bc33afd 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 cda7545..6ecbaf7 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 ddfaaee..44c1dba 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)
-- 
1.9.1



More information about the Beignet mailing list