Gustavo Aponte
Gustavo Aponte

Reputation: 11

PyOpenCL problem with printf build in kernel

When execute my program in python, I have a problem with a build only in "cl.device_type.GPU" but "cl.device_type.CPU" don't have problems

import pyopencl as cl
Mi_Contexto=cl.Context(devices=[cl.get_platforms()[0].get_devices(device_type=cl.device_type.GPU)[0]])

Mi_Cola_de_comandos=cl.CommandQueue(Mi_Contexto)

Mi_programa=cl.Program(Mi_Contexto,'''
__kernel void threads_in_pyopencl(void){
printf("HOLA\\n");
while(1<10){}
}
''').build(options=[])

*Exception has occurred: RuntimeError clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE

Build on <pyopencl.Device 'AMD Radeon Pro 555 Compute Engine' on 'Apple' at 0x1021c00>:

SC failed. No reason given. (options: -I /usr/local/lib/python3.7/site-packages/pyopencl/cl) (source saved as /var/folders/cj/v6tpwrhj58j0jc2s0zgmp1wr0000gn/T/tmpmqfa6yow.cl) File "/Users/gustavo/Python projects/PyOpenCL mis programas/threads/PyOpenCL threads.py", line 15, in ''').build(options=[])*

So, I changed to the next kernel, with the same flag "cl.device_type.GPU" and the problem disappeared. I don't know what is the problem

Mi_programa=cl.Program(Mi_Contexto,'''
__kernel void threads_in_pyopencl(void){
while(1<10){}
printf("HOLA\\n");
}
''').build(options=[])

P.D. I have Mac OS Catalina without conda, I installed PyOpenCL with pip.

Upvotes: 1

Views: 438

Answers (1)

DAXaholic
DAXaholic

Reputation: 35318

I can't verify it as I do not have an AMD / Radeon card but I guess you have to enable the proper extension with

#pragma OPENCL EXTENSION cl_amd_printf : enable

See also the following answer

Upvotes: 2

Related Questions