1

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.

1 Answers1

2

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

DAXaholic
  • 33,312
  • 6
  • 76
  • 74
  • Thank you, I tried this method: warning: unknown OpenCL extension 'cl_amd_printf' - ignoring... :( It's strange, probably is working different the compilation because before of the loop or first instruction of the loop is an error in build(). In different place printf() work perfectly. – Gustavo Aponte Jun 27 '20 at 08:51