Use first platform and actually copy A and B to device, actually fixing this

This commit is contained in:
Darren VanBuren 2019-02-11 13:53:25 -08:00
parent 7e58dc842b
commit 6ef61b6de1
2 changed files with 7 additions and 5 deletions

View file

@ -1,2 +1,2 @@
hello: main.cpp hello: main.cpp
g++ -o hello -lOpenCL main.cpp g++ -o hello main.cpp -lOpenCL

View file

@ -1,3 +1,5 @@
#define CL_TARGET_OPENCL_VERSION 120
#include <utility> #include <utility>
#include <CL/cl.hpp> #include <CL/cl.hpp>
#include <cstdio> #include <cstdio>
@ -40,7 +42,7 @@ int main(void) {
std::cerr << "Platform #" << i << " Name: " << platformName << std::endl; 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); cl::Context context(CL_DEVICE_TYPE_GPU, cprops, NULL, NULL, &err);
checkErr(err, "Context::Context()"); checkErr(err, "Context::Context()");
@ -89,8 +91,8 @@ int main(void) {
checkErr(err, "Kernel::Kernel()"); checkErr(err, "Kernel::Kernel()");
deviceC = cl::Buffer(context, CL_MEM_WRITE_ONLY, memSizeC, NULL, &err); 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); 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, NULL, &err); deviceB = cl::Buffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, memSizeB, hostB, &err);
size_t localWorkSize[2], globalWorkSize[2]; size_t localWorkSize[2], globalWorkSize[2];
@ -113,7 +115,7 @@ int main(void) {
event.wait(); event.wait();
err = queue.enqueueReadBuffer(deviceC, CL_TRUE, 0, memSizeC, hostC); err = queue.enqueueReadBuffer(deviceC, CL_TRUE, 0, memSizeC, hostC);
checkErr(err, "CommandQueue::enqueueReadBuffer"); checkErr(err, "CommandQueue::enqueueReadBuffer()");
// Verification // Verification
int matches = 0; int matches = 0;