This version LGTM, will push latter. Thanks.
On Tue, Feb 03, 2015 at 10:27:22AM +0800, Chuanbo Weng wrote: > 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 <[email protected]> > --- > benchmark/benchmark_read_buffer.cpp | 6 ++++-- > benchmark/benchmark_read_image.cpp | 6 ++++-- > benchmark/benchmark_use_host_ptr_buffer.cpp | 6 ++++-- > benchmark/enqueue_copy_buf.cpp | 6 ++++-- > utests/utest.hpp | 8 ++++++-- > utests/utest_helper.cpp | 6 +++--- > utests/utest_helper.hpp | 2 +- > utests/vload_bench.cpp | 6 +++--- > 8 files changed, 29 insertions(+), 17 deletions(-) > > diff --git a/benchmark/benchmark_read_buffer.cpp > b/benchmark/benchmark_read_buffer.cpp > index 31a1f59..431f42a 100644 > --- a/benchmark/benchmark_read_buffer.cpp > +++ b/benchmark/benchmark_read_buffer.cpp > @@ -1,7 +1,7 @@ > #include "utests/utest_helper.hpp" > #include <sys/time.h> > > -int benchmark_read_buffer(void) > +double benchmark_read_buffer(void) > { > struct timeval start,stop; > > @@ -43,7 +43,9 @@ int benchmark_read_buffer(void) > free(buf_data[0]); > buf_data[0] = NULL; > > - return time_subtract(&stop, &start, 0); > + double elapsed = time_subtract(&stop, &start, 0); > + > + return BANDWIDTH(sz * sizeof(float) * 2 * 100, elapsed); > } > > MAKE_BENCHMARK_FROM_FUNCTION(benchmark_read_buffer); > diff --git a/benchmark/benchmark_read_image.cpp > b/benchmark/benchmark_read_image.cpp > index 48aa987..e3aa5bd 100644 > --- a/benchmark/benchmark_read_image.cpp > +++ b/benchmark/benchmark_read_image.cpp > @@ -2,7 +2,7 @@ > #include "utests/utest_helper.hpp" > #include <sys/time.h> > > -int benchmark_read_image(void) > +double benchmark_read_image(void) > { > struct timeval start,stop; > > @@ -61,7 +61,9 @@ int benchmark_read_image(void) > free(buf_data[0]); > buf_data[0] = NULL; > > - return time_subtract(&stop, &start, 0); > + double elapsed = time_subtract(&stop, &start, 0); > + > + return BANDWIDTH(sz * sizeof(float) * 2 * 100, elapsed); > } > > MAKE_BENCHMARK_FROM_FUNCTION(benchmark_read_image); > diff --git a/benchmark/benchmark_use_host_ptr_buffer.cpp > b/benchmark/benchmark_use_host_ptr_buffer.cpp > index 80b6c5c..9e3d155 100644 > --- a/benchmark/benchmark_use_host_ptr_buffer.cpp > +++ b/benchmark/benchmark_use_host_ptr_buffer.cpp > @@ -1,7 +1,7 @@ > #include "utests/utest_helper.hpp" > #include <sys/time.h> > > -int benchmark_use_host_ptr_buffer(void) > +double benchmark_use_host_ptr_buffer(void) > { > struct timeval start,stop; > > @@ -32,7 +32,9 @@ int benchmark_use_host_ptr_buffer(void) > free(buf_data[0]); > buf_data[0] = NULL; > > - return time_subtract(&stop, &start, 0); > + double elapsed = time_subtract(&stop, &start, 0); > + > + return BANDWIDTH(n*sizeof(uint32_t)*100*2, elapsed); > } > > MAKE_BENCHMARK_FROM_FUNCTION(benchmark_use_host_ptr_buffer); > diff --git a/benchmark/enqueue_copy_buf.cpp b/benchmark/enqueue_copy_buf.cpp > index f012cf7..549c8b1 100644 > --- a/benchmark/enqueue_copy_buf.cpp > +++ b/benchmark/enqueue_copy_buf.cpp > @@ -28,7 +28,7 @@ void test_copy_buf(size_t sz, size_t src_off, size_t > dst_off, size_t cb) > src_off, dst_off, cb*sizeof(char), 0, NULL, NULL)); > } > > -int enqueue_copy_buf(void) > +double enqueue_copy_buf(void) > { > size_t i; > const size_t sz = 127 *1023 * 1023; > @@ -41,7 +41,9 @@ int enqueue_copy_buf(void) > } > > gettimeofday(&stop,0); > - return time_subtract(&stop, &start, 0); > + double elapsed = time_subtract(&stop, &start, 0); > + > + return BANDWIDTH(sz * sizeof(char) * 10, elapsed); > } > > MAKE_BENCHMARK_FROM_FUNCTION(enqueue_copy_buf); > diff --git a/utests/utest.hpp b/utests/utest.hpp > index b028b64..7ae8b87 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 591054e..d3c378e 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 5d8e835..6d09766 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 a7703fc..ddfaaee 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; \ > -- > 1.9.1 > > _______________________________________________ > Beignet mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/beignet _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
