Skip to content

Commit

Permalink
Use stricter host buffer alignment (64B) required by modern CPUs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pioto1225 authored and krrishnarraj committed Nov 25, 2024
1 parent 99caa48 commit f66ac42
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/transfer_bandwidth.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <clpeak.h>
#include <cstdlib>

int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, device_info_t &devInfo)
{
Expand All @@ -17,7 +18,7 @@ int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog,

try
{
arr = new float[numItems];
arr = static_cast<float *>(aligned_alloc(64, numItems * sizeof(float)));
memset(arr, 0, numItems * sizeof(float));
cl::Buffer clBuffer = cl::Buffer(ctx, (CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR), (numItems * sizeof(float)));

Expand Down Expand Up @@ -324,7 +325,7 @@ int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog,
log->xmlCloseTag(); // transfer_bandwidth

if (arr)
delete[] arr;
std::free(arr);
}
catch (cl::Error &error)
{
Expand All @@ -335,7 +336,7 @@ int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog,

if (arr)
{
delete[] arr;
std::free(arr);
}
return -1;
}
Expand Down

0 comments on commit f66ac42

Please sign in to comment.