From f66ac4229980e78978cfceb5bbacc93b9f0da48f Mon Sep 17 00:00:00 2001 From: Piotr Lopatka Date: Sun, 24 Nov 2024 16:56:43 +0000 Subject: [PATCH] Use stricter host buffer alignment (64B) required by modern CPUs. --- src/transfer_bandwidth.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/transfer_bandwidth.cpp b/src/transfer_bandwidth.cpp index 1b4e084..f889d23 100644 --- a/src/transfer_bandwidth.cpp +++ b/src/transfer_bandwidth.cpp @@ -1,4 +1,5 @@ #include +#include int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, device_info_t &devInfo) { @@ -17,7 +18,7 @@ int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, try { - arr = new float[numItems]; + arr = static_cast(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))); @@ -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) { @@ -335,7 +336,7 @@ int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, if (arr) { - delete[] arr; + std::free(arr); } return -1; }