From 6ef61b6de1f38f490cec7594e0dbd33dec233f63 Mon Sep 17 00:00:00 2001 From: Darren VanBuren Date: Mon, 11 Feb 2019 13:53:25 -0800 Subject: [PATCH] Use first platform and actually copy A and B to device, actually fixing this --- Makefile | 2 +- main.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 50b5f12..7702b13 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ hello: main.cpp - g++ -o hello -lOpenCL main.cpp + g++ -o hello main.cpp -lOpenCL diff --git a/main.cpp b/main.cpp index 7771ea3..282cae1 100644 --- a/main.cpp +++ b/main.cpp @@ -1,3 +1,5 @@ +#define CL_TARGET_OPENCL_VERSION 120 + #include #include #include @@ -40,7 +42,7 @@ int main(void) { std::cerr << "Platform #" << i << " Name: " << platformName << std::endl; } - cl_context_properties cprops[3] = { CL_CONTEXT_PLATFORM, (cl_context_properties)(platformList[1])(), 0 }; + cl_context_properties cprops[3] = { CL_CONTEXT_PLATFORM, (cl_context_properties)(platformList[0])(), 0 }; cl::Context context(CL_DEVICE_TYPE_GPU, cprops, NULL, NULL, &err); checkErr(err, "Context::Context()"); @@ -89,8 +91,8 @@ int main(void) { checkErr(err, "Kernel::Kernel()"); deviceC = cl::Buffer(context, CL_MEM_WRITE_ONLY, memSizeC, NULL, &err); - deviceA = cl::Buffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, memSizeA, NULL, &err); - deviceB = cl::Buffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, memSizeB, NULL, &err); + deviceA = cl::Buffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, memSizeA, hostA, &err); + deviceB = cl::Buffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, memSizeB, hostB, &err); size_t localWorkSize[2], globalWorkSize[2]; @@ -113,7 +115,7 @@ int main(void) { event.wait(); err = queue.enqueueReadBuffer(deviceC, CL_TRUE, 0, memSizeC, hostC); - checkErr(err, "CommandQueue::enqueueReadBuffer"); + checkErr(err, "CommandQueue::enqueueReadBuffer()"); // Verification int matches = 0;