Control: retitle -1 pocl: nested(?) dlopen fails
Control: reassign -1 libpocl2 1.5-2
Control: affects -1 src:libgpuarray python3-pyopencl
ocl-icd-libopencl1 dlopen()s ICDs (at
https://sources.debian.org/src/ocl-icd/2.2.12-4/ocl_icd_loader.c/#L184).
With pocl 1.5, this dlopen() fails in some conditions (returns a NULL
pointer). dlerror says the problem is "undefined symbol: clRetainEvent".
After such a failure, libopencl1 ignores that ICD but keeps looking for
others. If there aren't any (i.e. pocl is the only ICD installed), it
returns a "no platforms found" error, hence the above test failures.
This is a regression: it does not happen with pocl from testing (1.4).
These fail:
- pygpu (libgpuarray Python interface) - import
pygpu.gpuarray;pygpu.gpuarray.init('opencl0:0')
- libgpuarray C interface - program 2 below
- pyopencl - import pyopencl;pyopencl.get_platforms()
These succeed:
- direct C++ calls, including clRetainEvent - program 1 below
- clinfo
- beignet-dev's tester - /usr/lib/x86_64-linux-gnu/beignet/utest_run
These failures are all cases where the code trying to dlopen() pocl was
itself dlopen()ed: Python dlopen()s C extensions (such as pyopencl and
pygpu) on import, and libgpuarray dlopen()s libopencl.
$ gdb --args python3 -c "import pyopencl;pyopencl.get_platforms()"
[standard notice]
Reading symbols from python3...
(No debugging symbols found in python3)
(gdb) break _load_icd
Function "_load_icd" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (_load_icd) pending.
(gdb) run
Starting program: /usr/bin/python3 -c import\
pyopencl\;pyopencl.get_platforms\(\)
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, _load_icd (lib_path=0xe1cbc0 "libpocl.so.2.5.0", num_icds=0)
at ocl_icd_loader.c:237
237 ocl_icd_loader.c: No such file or directory.
(gdb) break dlopen
Breakpoint 2 at 0x7ffff7dd22a0: file dlopen.c, line 75.
(gdb) c
Continuing.
Breakpoint 2, __dlopen (file=file@entry=0xe1cbc0 "libpocl.so.2.5.0",
mode=mode@entry=1) at dlopen.c:75
75 dlopen.c: No such file or directory.
(gdb) finish
Run till exit from #0 __dlopen (file=file@entry=0xe1cbc0
"libpocl.so.2.5.0",
mode=mode@entry=1) at dlopen.c:75
0x00007ffff77d97eb in _load_icd (lib_path=0xe1cbc0 "libpocl.so.2.5.0",
num_icds=0) at ocl_icd_loader.c:237
237 ocl_icd_loader.c: No such file or directory.
Value returned is $1 = (void *) 0x0
(gdb) print dlerror()
$2 = 0xd9c600 "/usr/lib/x86_64-linux-gnu/libpocl.so.2.5.0: undefined
symbol: clRetainEvent"
(gdb) quit
Test program 1 - compile with -lOpenCL
#include <CL/opencl.h>
#include <cstdio>
int main(){
cl_uint num_platforms;
cl_int err;
err=clGetPlatformIDs(0,NULL,&num_platforms);
std::printf("%i %i",err,num_platforms);
cl_int status;
cl_device_id device;
clGetDeviceIDs(NULL,CL_DEVICE_TYPE_ALL,1,&device,NULL);
char device_name[101];
device_name[100]=0;
clGetDeviceInfo(device,CL_DEVICE_NAME,100,device_name,NULL);
cl_context ctx = clCreateContext(NULL, 1, &device, NULL, NULL, &status);
cl_event event1 = clCreateUserEvent(ctx,NULL);
std::printf("\n%i\n",clRetainEvent(event1));
}
Test program 2 - compile with -lgpuarray
#include <gpuarray/buffer.h>
#include <cstdio>
int main(){
gpucontext_props *p;
gpucontext *p2 = NULL;
int err;
gpucontext_props_new(&p);
gpucontext_props_alloc_cache(p,0,0x100000);
err = gpucontext_props_opencl_dev(p,0,0);
std::printf("%i %p",err,p);
err=gpucontext_init(&p2,"opencl",p);
std::printf("%i %p",err,p2);
}