Question

I'm having trouble getting a kernel to run on two different OpenCL platforms. The only difference in the platforms is one is OpenCL 1.1 and the other 1.2 as such:

Code works on this device (OS X 10.8):

===============================================================
('Platform name:', 'Apple')
('Platform profile:', 'FULL_PROFILE')
('Platform vendor:', 'Apple')
('Platform version:', 'OpenCL 1.2 (Sep 20 2012 17:42:28)')
---------------------------------------------------------------
('Device name:', 'Intel(R) Core(TM) i5-3427U CPU @ 1.80GHz')
('Device type:', 'CPU')
('Device memory: ', 8192L, 'MB')
('Device max clock speed:', 1800, 'MHz')
('Device compute units:', 4)

Target device (Ubuntu 11.04):

===============================================================
('Platform name:', 'NVIDIA CUDA')
('Platform profile:', 'FULL_PROFILE')
('Platform vendor:', 'NVIDIA Corporation')
('Platform version:', 'OpenCL 1.1 CUDA 4.2.1')
---------------------------------------------------------------
('Device name:', 'Tesla M2050')
('Device type:', 'GPU')
('Device memory: ', 3071, 'MB')
('Device max clock speed:', 1147, 'MHz')
('Device compute units:', 14)
===============================================================
('Platform name:', 'NVIDIA CUDA')
('Platform profile:', 'FULL_PROFILE')
('Platform vendor:', 'NVIDIA Corporation')
('Platform version:', 'OpenCL 1.1 CUDA 4.2.1')
---------------------------------------------------------------
('Device name:', 'Tesla M2050')
('Device type:', 'GPU')
('Device memory: ', 3071, 'MB')
('Device max clock speed:', 1147, 'MHz')
('Device compute units:', 14)

I've traced what I believe to the source of the hang to the following code:

# set up 
host_array = numpy.array(arr)
device_buffer = pyopencl.Buffer(context, pyopencl.mem_flags.WRITE_ONLY, host_array.nbytes)

# run the kernel
program.run(queue, host_array.shape, None, device_buffer)

# copy the results back --- this call causes the code to hang ----
pyopencl.enqueue_copy(queue, host_array, device_buffer)

There are no code changes between the two devices and both devices are running PyOpenCL 2013.1. Am I missing something? Any suggestion is much appreciated.

Was it helpful?

Solution 2

Turns out the problem was a threading issue. I was using a 2nd thread spawned with the threading module to make my pyopencl calls. I believe the problem was that the context I was using to call pyopencl was created on the main thread and I think this was causing some sort of issue.

To fix I just made sure to declare my context, queue, and created program on the 2nd thread instead of on the primary thread.

OTHER TIPS

Try adding a .wait() to the program.run. This will determine if it's actually the program that's hanging.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top