CLTests: Add test for USE_HOST_PTR; fix build warnings

This commit is contained in:
2025-11-08 02:07:43 -04:00
parent bc56c83fad
commit b460c8b2d3
5 changed files with 183 additions and 16 deletions
+5 -3
View File
@@ -1,3 +1,4 @@
#define CL_TARGET_OPENCL_VERSION 300
#include <CL/cl.h>
#include <iostream>
#include <vector>
@@ -32,8 +33,9 @@ int main() {
cl_context ctx = clCreateContext(nullptr, 1, &dev, nullptr, nullptr, &err);
CHECK(err, "clCreateContext");
cl_command_queue q = clCreateCommandQueue(ctx, dev, 0, &err);
CHECK(err, "clCreateCommandQueue");
cl_queue_properties queueProps[] = {CL_QUEUE_PROPERTIES, 0, 0};
cl_command_queue q = clCreateCommandQueueWithProperties(ctx, dev, queueProps, &err);
CHECK(err, "clCreateCommandQueueWithProperties");
// Create program and kernel
const size_t srcLen = std::strlen(kernelSrc);
@@ -97,7 +99,7 @@ int main() {
// Validate
bool ok = true;
for (size_t i = 0; i < N; ++i)
if (outPtr[i] != 142 + i) ok = false;
if (outPtr[i] != static_cast<int>(142 + i)) ok = false;
std::cout << (ok ? "✅ GPU saw host writes (zero-copy confirmed)\n"
: "❌ GPU did not see host writes (copying or staging occurred)\n");