2013-02-04 25 views
0

我無法讓內核在兩個不同的OpenCL平臺上運行。在平臺上的唯一區別是一個的OpenCL 1.1和其他1.2這樣:PyOpenCL enqueue_copy在不同設備上運行時掛起

代碼工作在這個裝置上(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) 

目標設備(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) 

我跟蹤了我認爲的掛在下面的代碼來源:

# 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) 

有一請注意兩臺設備之間沒有代碼更改,兩臺設備都運行PyOpenCL 2013.1。我錯過了什麼嗎?任何建議,非常感謝。

回答

0

原來問題是一個線程問題。我正在使用線程模塊產生的第二個線程來調用我的pyopencl。我相信問題是我用來調用pyopencl的上下文是在主線程上創建的,我認爲這導致了某種問題。

要解決我只是做了一定要聲明我的背景下,隊列和2號線,而不是在主線程創建的程序。

1

嘗試將.wait()添加到program.run。這將決定它是否實際上是懸掛的程序。

+0

我嘗試添加一個'.wait()''到program.run'以及從調用'program.run'接收的'event'對象,但該方案仍然在enqueue_copy'的'第一呼叫掛起(我在兩次調用之間使用了一個「print」)。 – Justin

+0

如果不運行內核,掛起是否也會發生? –

+0

是的。原來是pyopencl之外的線程問題。 – Justin

相關問題