HPCE / hpce-2017-cw5

1 stars 6 forks source link

OpenCL enqueueReadBuffer not copying back to host memory #37

Closed vinaymaniam closed 6 years ago

vinaymaniam commented 6 years ago

I am implementing Mining and Random Projection in OpenCL. For random projection i was notified that output is incorrect, and for mining it never achieves a solution.

Upon further inspection, I found that there appears to be a problem occurring with memory transfer either to or from the gpu. More specifically, I tested this by initialising my c++ vector to all 0xFFFFFFFFFFFFFFFFull, and unconditionally set the value to 0 in the OpenCL kernel.

std::vector<uint64_t> vOut(N_PARALLEL, 0xFFFFFFFFFFFFFFFFull);
queue.enqueueWriteBuffer(buffResult, CL_TRUE, 0, hpce_result, &vOut[0]);
 .
 .
 queue.enqueueNDRangeKernel(kernel, offset, globalSize, localSize); 
 .
 .
queue.enqueueReadBuffer(buffResult, CL_TRUE, 0, hpce_result, &vOut[0]);

I have been quite careful in following the steps outlined in coursework 3, and the sizes allocated for each buffer are correct(8 * number of elements in vector for uint64_t), so I was wondering if the problem was to do with something non code related.

I copied the opencl_sdk folder from coursework 3 and made the following modifications to the makefile:

LDFLAGS += -Lopencl_sdk/lib/windows/x86_64 LDLIBS += -ltbb -lOpenCL

Any insight would be greatly appreciated

vinaymaniam commented 6 years ago

Nevermind, turns out there were clSetKernelArg errors which wouldn't show up because I forgot to #define __CL_ENABLE_EXCEPTIONS...