From d3975a55ce6cffdcccbb0c8bd430f9784b110e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz> Date: Sat, 19 Mar 2016 17:32:37 +0100 Subject: [PATCH] Added benchmarks for allocation and deallocation of arrays --- tests/benchmarks/array-operations.h | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/benchmarks/array-operations.h b/tests/benchmarks/array-operations.h index c9d99e8f42..11f5bd9ff4 100644 --- a/tests/benchmarks/array-operations.h +++ b/tests/benchmarks/array-operations.h @@ -91,6 +91,50 @@ benchmarkArrayOperations( Benchmark & benchmark, "CPU->GPU", copyAssignHostCuda, "GPU->CPU", copyAssignCudaHost ); + + auto setValueHost = [&]() { + hostArray.setValue( 3.0 ); + }; + auto setValueCuda = [&]() { + deviceArray.setValue( 3.0 ); + }; + benchmark.setOperation( "setValue", datasetSize ); + benchmark.time( reset1, + "CPU", setValueHost, + "GPU", setValueCuda ); + + + auto setSizeHost = [&]() { + hostArray.setSize( size ); + }; + auto setSizeCuda = [&]() { + deviceArray.setSize( size ); + }; + auto resetSize1 = [&]() { + hostArray.reset(); + deviceArray.reset(); + }; + benchmark.setOperation( "allocation (setSize)", datasetSize ); + benchmark.time( resetSize1, + "CPU", setSizeHost, + "GPU", setSizeCuda ); + + + auto resetSizeHost = [&]() { + hostArray.reset(); + }; + auto resetSizeCuda = [&]() { + deviceArray.reset(); + }; + auto setSize1 = [&]() { + hostArray.setSize( size ); + deviceArray.setSize( size ); + }; + benchmark.setOperation( "deallocation (reset)", datasetSize ); + benchmark.time( setSize1, + "CPU", resetSizeHost, + "GPU", resetSizeCuda ); + return true; } -- GitLab