diff options
author | Chuanbo Weng <chuanbo.weng@intel.com> | 2015-02-03 10:27:22 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-02-06 12:46:22 +0800 |
commit | 25a6a17a4ec46427ac29a0f0b4ce765c440864c7 (patch) | |
tree | 2a9f902f2509a6f70717f269febc915495f53139 /utests | |
parent | a1ae5876623858957c3841edf7d0f79bc193ad3a (diff) |
Refine benchmark output.
Change output measurement from time to bandwidth, so we can compare
all benchmark results easily. And change return type of benchmark
from int to double, because int is not precise enough.
v2: Change output measurement from time to bandwidth.
Signed-off-by: Chuanbo Weng <chuanbo.weng@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'utests')
-rw-r--r-- | utests/utest.hpp | 8 | ||||
-rw-r--r-- | utests/utest_helper.cpp | 6 | ||||
-rw-r--r-- | utests/utest_helper.hpp | 2 | ||||
-rw-r--r-- | utests/vload_bench.cpp | 6 |
4 files changed, 13 insertions, 9 deletions
diff --git a/utests/utest.hpp b/utests/utest.hpp index b028b64f..7ae8b876 100644 --- a/utests/utest.hpp +++ b/utests/utest.hpp @@ -30,6 +30,7 @@ #include "utest_exception.hpp" #include <vector> #include <iostream> +#include <iomanip> /*! struct for statistics */ struct RStatistics @@ -135,10 +136,10 @@ struct UTest #define BENCHMARK(EXPR) \ do { \ - int ret = 0;\ + double ret = 0;\ try { \ ret = EXPR; \ - std::cout << " [Result: " << ret << "] [SUCCESS]" << std::endl; \ + std::cout << " [Result: " << std::fixed<< std::setprecision(3) << ret << " GB/S] [SUCCESS]" << std::endl; \ UTest::retStatistics.passCount += 1; \ } \ catch (Exception e) { \ @@ -147,5 +148,8 @@ struct UTest UTest::retStatistics.failCount++; \ } \ } while (0) + +#define BANDWIDTH(BYTES, MSEC) \ + ((double)(BYTES)) / ((MSEC) * 1e6); #endif /* __UTEST_UTEST_HPP__ */ diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp index 591054e9..d3c378e9 100644 --- a/utests/utest_helper.cpp +++ b/utests/utest_helper.cpp @@ -681,7 +681,7 @@ int cl_INT_ULP(int int_number) return 0; } -int time_subtract(struct timeval *y, struct timeval *x, struct timeval *result) +double time_subtract(struct timeval *y, struct timeval *x, struct timeval *result) { if ( x->tv_sec > y->tv_sec ) return -1; @@ -699,6 +699,6 @@ int time_subtract(struct timeval *y, struct timeval *x, struct timeval *result) } } - int msec = 1000.0*(y->tv_sec - x->tv_sec) + (y->tv_usec - x->tv_usec)/1000.0; + double msec = 1000.0*(y->tv_sec - x->tv_sec) + (y->tv_usec - x->tv_usec)/1000.0; return msec; -}
\ No newline at end of file +} diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp index 5d8e835c..6d097662 100644 --- a/utests/utest_helper.hpp +++ b/utests/utest_helper.hpp @@ -231,7 +231,7 @@ extern float cl_FLT_ULP(float float_number); extern int cl_INT_ULP(int int_number); /* subtract the time */ -int time_subtract(struct timeval *y, struct timeval *x, struct timeval *result); +double time_subtract(struct timeval *y, struct timeval *x, struct timeval *result); #endif /* __UTEST_HELPER_HPP__ */ diff --git a/utests/vload_bench.cpp b/utests/vload_bench.cpp index a7703fcd..ddfaaee7 100644 --- a/utests/vload_bench.cpp +++ b/utests/vload_bench.cpp @@ -34,8 +34,8 @@ static double vload_bench(const char *kernelFunc, uint32_t N, uint32_t offset, b OCL_FINISH(); gettimeofday(&end, NULL); double elapsed = (end.tv_sec - start.tv_sec) * 1e6 + (end.tv_usec - start.tv_usec); - double bandwidth = (globals[0] * (N_ITERATIONS) * sizeof(T) * N) / elapsed; - printf("\t%2.1fGB/S\n", bandwidth/1000.); + double bandwidth = (globals[0] * (N_ITERATIONS) * sizeof(T) * N) / (elapsed * 1000.); + printf("\t%2.1fGB/S\n", bandwidth); return bandwidth; } else { // Check result @@ -71,7 +71,7 @@ VLOAD_TEST(float, float) #endif #define VLOAD_BENCH(T, kT) \ -static int vload_bench_ ##kT(void) \ +static double vload_bench_ ##kT(void) \ { \ uint8_t vectorSize[] = {2, 3, 4, 8, 16}; \ double totBandwidth = 0; \ |