Skip to content

Commit

Permalink
include reduce into duration measurement
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetyusufoglu committed Nov 13, 2024
1 parent 862a390 commit 054be06
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions benchmarks/babelstream/src/babelStreamMainTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ void testKernels()
std::vector<double> bytesReadWriteMB;
if(kernelsToBeExecuted == KernelsToRun::All)
{
// Verify the results for all 5 babelstream kernels
// Verify the results for init and 4 babelstream kernels
// Find sum of the errors as sum of the differences from expected values
DataType initVal{static_cast<DataType>(0.0)};
DataType sumErrC{initVal}, sumErrB{initVal}, sumErrA{initVal};
Expand Down Expand Up @@ -453,6 +453,7 @@ void testKernels()
// A specific work-division is used for dotKernel
auto const workDivDot = WorkDiv{Vec{gridBlockExtent}, Vec{blockThreadExtent}, Vec::all(1)};

float result{0.0f};
measureKernelExec(
[&]()
{
Expand All @@ -464,15 +465,13 @@ void testKernels()
bufAccInputBPtr,
alpaka::getPtrNative(bufAccSumPerBlock),
static_cast<alpaka::Idx<Acc>>(arraySize));
alpaka::memcpy(queue, bufHostSumPerBlock, bufAccSumPerBlock, gridBlockExtent);
alpaka::wait(queue);
DataType const* sumPtr = std::data(bufHostSumPerBlock);
result = std::reduce(sumPtr, sumPtr + gridBlockExtent, 0.0f);
},
"DotKernel");

alpaka::memcpy(queue, bufHostSumPerBlock, bufAccSumPerBlock, gridBlockExtent);
alpaka::wait(queue);

DataType const* sumPtr = std::data(bufHostSumPerBlock);
float const result = std::reduce(sumPtr, sumPtr + gridBlockExtent, 0.0f);

float const expectedSum = static_cast<float>(static_cast<DataType>(arraySize) * expectedA * expectedB);

// Dot product should be identical to arraySize*valA*valB
Expand Down

0 comments on commit 054be06

Please sign in to comment.