Use first platform and actually copy A and B to device, actually fixing this
This commit is contained in:
parent
7e58dc842b
commit
6ef61b6de1
2 changed files with 7 additions and 5 deletions
2
Makefile
2
Makefile
|
@ -1,2 +1,2 @@
|
|||
hello: main.cpp
|
||||
g++ -o hello -lOpenCL main.cpp
|
||||
g++ -o hello main.cpp -lOpenCL
|
||||
|
|
10
main.cpp
10
main.cpp
|
@ -1,3 +1,5 @@
|
|||
#define CL_TARGET_OPENCL_VERSION 120
|
||||
|
||||
#include <utility>
|
||||
#include <CL/cl.hpp>
|
||||
#include <cstdio>
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue