Program stuck at clGetPlatformIDs

Hi, this is the first time trying to develop something with openCL. I’m currently running into a problem when trying to follow the hello world by Erik Smistad (I cannot provide a link), where the program gets stuck at line on line 42 while trying to get the the platform_id. I’ve tried debugging the program with gdb to see where it got stuck. Am I doing something wrong?

Code snippet
#define CL_TARGET_OPENCL_VERSION 300
#include <CL/cl.h>

...

// Get device and platform info
cl_platform_id platform_id = NULL;
cl_device_id device_id = NULL;
cl_uint ret_num_devices;
cl_uint ret_num_platforms;
cl_int ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms);
ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_DEFAULT, 1, &device_id, &ret_num_devices);
GDB
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
^C
Program received signal SIGINT, Interrupt.
futex_wait (private=0, expected=1, futex_word=0x7ffff7fc3878) at ../sysdeps/nptl/futex-internal.h:146
146	  int err = lll_futex_timed_wait (futex_word, expected, NULL, private);
(gdb) backtrace
#0  futex_wait (private=0, expected=1, futex_word=0x7ffff7fc3878) at ../sysdeps/nptl/futex-internal.h:146
#1  futex_wait_simple (private=0, expected=1, futex_word=0x7ffff7fc3878) at ../sysdeps/nptl/futex-internal.h:177
#2  __pthread_once_slow (once_control=0x7ffff7fc3878, init_routine=0x7ffff7fc0940) at pthread_once.c:105
#3  0x00007ffff7fbd4a3 in clGetExtensionFunctionAddress () from /opt/intel/oneapi/compiler/2023.0.0/linux/lib/libOpenCL.so
#4  0x00007ffff7fbc6e7 in ?? () from /opt/intel/oneapi/compiler/2023.0.0/linux/lib/libOpenCL.so
#5  0x00007ffff7fc0bd9 in ?? () from /opt/intel/oneapi/compiler/2023.0.0/linux/lib/libOpenCL.so
#6  0x00007ffff7e215bf in __pthread_once_slow (once_control=0x7ffff7fc3878, init_routine=0x7ffff7fc0940) at pthread_once.c:116
#7  0x00007ffff7fbd4a3 in clGetExtensionFunctionAddress () from /opt/intel/oneapi/compiler/2023.0.0/linux/lib/libOpenCL.so
#8  0x00007ffff7f824c6 in khrIcdVendorAdd (libraryName=libraryName@entry=0x555555564540 "/opt/intel/oneapi/compiler/2023.0.0/linux/lib/libOpenCL.so")
    at /usr/src/debug/rocm-opencl-runtime/ROCm-OpenCL-Runtime-rocm-5.4.3/khronos/icd/loader/icd.c:99
#9  0x00007ffff7f82990 in khrIcdOsVendorsEnumerate () at /usr/src/debug/rocm-opencl-runtime/ROCm-OpenCL-Runtime-rocm-5.4.3/khronos/icd/loader/linux/icd_linux.c:129
#10 0x00007ffff7e215bf in __pthread_once_slow (once_control=0x7ffff7f88010 <initialized>, init_routine=0x7ffff7f827c0 <khrIcdOsVendorsEnumerate>) at pthread_once.c:116
#11 0x00007ffff7e216b5 in ___pthread_once (once_control=<optimized out>, init_routine=<optimized out>) at pthread_once.c:143
#12 0x00007ffff7f82a55 in khrIcdOsVendorsEnumerateOnce () at /usr/src/debug/rocm-opencl-runtime/ROCm-OpenCL-Runtime-rocm-5.4.3/khronos/icd/loader/linux/icd_linux.c:163
#13 khrIcdInitialize () at /usr/src/debug/rocm-opencl-runtime/ROCm-OpenCL-Runtime-rocm-5.4.3/khronos/icd/loader/icd.c:35
#14 clGetPlatformIDs (num_entries=1, platforms=0x7fffffffd830, num_platforms=0x7fffffffd814) at /usr/src/debug/rocm-opencl-runtime/ROCm-OpenCL-Runtime-rocm-5.4.3/khronos/icd/loader/icd_dispatch.c:38
#15 0x000055555555543e in main ()

CL/cl.h with openCL version 3 ???

The compiler kept complaining about a missing opencl version and the nessage said it will default to version 3, So I set it myself to silence the warning. Is there something wrong with using this version?

Just to be sure, I’ve tried the OpenCL versions 1 and 2, but it’s still getting stuck on the same line of the backtrace

I looked a bit closer into the backtrace and found the issue. I have an AMD CPU+GPU and I had intel-oneapi-compiler-shared-opencl-cpu installed as part of a machine learning dependency. In my case I was able to resolve this issue by uninstalling the package.

pacman -R intel-oneapi-compiler-shared-opencl-cpu

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.