Brandon Amos <[email protected]> writes: > Hi all, I'm really interested in the pyopencl project and on integrating > with clBLAS [0], as discussed in a previous thread [1], > and I'm currently working on building a Python C extension to > use pyopencl objects with clBLAS. > > However, I'm very new to building Python C extensions, > and I'm new to writing Python C extensions, and > the interoperability documentation [2] mentions pyopencl objects > contain `from_int_ptr()` and `int_ptr`, but unfortunately > no examples are given. > > So, as a first step to help me learn about build a Python C extension > to interoperate with pyopencl, and to help anybody else, > I've created a project on GitHub [3] to show a simple usage. > It's still very much a work in progress and needs a lot of cleaning. > > I'm sending this message to ask for help with a segfault I'm getting when > calling `clGetContextInfo`. > `example-usage.py` [4] shows the example I'm using to obtain a pyopencl > context, queue, and buffer. > The `int_ptr` fields are passed to `peb.c::peb_example_method()` [5], > the context segfaults when passed to `clGetContextInfo`, which > I added as a check because `clCreateProgramWithSource` was segfaulting. > > I've added `printf("Calling. %p %d\n", &m_context, m_context);` > to `pyopencl::wrap_cl.hpp::context::data` to print the address and > first 32 bits of the context that's being returned to python. > Then, in `peb.c` I added `printf("%p %d\n", ctx, (int) ctx);`. > This may be misleading, but the following output shows > the memory addresses differing (red flag), but the first 32 bits > being the same. > > > [peb::example-usage.py] 0x1d722b8 > [pyopencl::wrap_cl.hpp::context::data] Calling. 0x1b55130 30876344 > 1 > 2 > 3 > [peb::peb.c::peb_example_method()] 0x1d722b8 30876344 > > For more information about my configuration, I'm using x86_64 Linux, > the latest `pyopencl` from `git`, and the Intel OpenCL 1.2 SDK. > I've seen a few posts on the `pyopencl` mailing list, so > I hope this isn't an issue with the Intel SDK, > because I can't easily develop on any other OpenCL device.
peb does not build for me:
-------------------------------------------------------
$ python setup.py install
running install
running build
running build_ext
building 'peb' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2
-Wall -Wstrict-prototypes -fPIC -I/usr/local/include
-I/opt/intel/opencl-sdk/include -I/usr/include/python2.7 -c src/peb.c -o
build/temp.linux-x86_64-2.7/src/peb.o
src/peb.c:16:15: error: variable ‘_module’ has initializer but incomplete type
static struct PyModuleDef _module = {
^
src/peb.c:17:3: error: ‘PyModuleDef_HEAD_INIT’ undeclared here (not in a
function)
PyModuleDef_HEAD_INIT, "peb", 0, -1, _methods
^
src/peb.c:17:3: warning: excess elements in struct initializer [enabled by
default]
src/peb.c:17:3: warning: (near initialization for ‘_module’) [enabled by
default]
src/peb.c:17:3: warning: excess elements in struct initializer [enabled by
default]
src/peb.c:17:3: warning: (near initialization for ‘_module’) [enabled by
default]
src/peb.c:17:3: warning: excess elements in struct initializer [enabled by
default]
src/peb.c:17:3: warning: (near initialization for ‘_module’) [enabled by
default]
src/peb.c:17:3: warning: excess elements in struct initializer [enabled by
default]
src/peb.c:17:3: warning: (near initialization for ‘_module’) [enabled by
default]
src/peb.c:18:1: warning: excess elements in struct initializer [enabled by
default]
};
^
src/peb.c:18:1: warning: (near initialization for ‘_module’) [enabled by
default]
src/peb.c: In function ‘PyInit_peb’:
src/peb.c:24:3: warning: implicit declaration of function ‘PyModule_Create’
[-Wimplicit-function-declaration]
PyObject *m = PyModule_Create(&_module);
^
src/peb.c:24:17: warning: initialization makes pointer from integer without a
cast [enabled by default]
PyObject *m = PyModule_Create(&_module);
^
src/peb.c:25:11: warning: ‘return’ with a value, in function returning void
[enabled by default]
if (!m) return 0;
^
src/peb.c:37:5: warning: ‘return’ with a value, in function returning void
[enabled by default]
return 0;
^
src/peb.c:43:5: warning: ‘return’ with a value, in function returning void
[enabled by default]
return 0;
^
src/peb.c:45:3: warning: ‘return’ with a value, in function returning void
[enabled by default]
return m;
^
src/peb.c: In function ‘peb_example_method’:
src/peb.c:81:26: warning: cast from pointer to integer of different size
[-Wpointer-to-int-cast]
printf("%p %d\n", ctx, (int) ctx);
^
src/peb.c:84:7: warning: passing argument 5 of ‘clGetContextInfo’ makes pointer
from integer without a cast [enabled by default]
param_val, ret_sz);
^
In file included from src/peb.c:5:0:
/usr/include/CL/cl.h:633:1: note: expected ‘size_t *’ but argument is of type
‘size_t’
clGetContextInfo(cl_context /* context */,
^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
-------------------------------------------------------
Andreas
pgp01pf6FG_rI.pgp
Description: PGP signature
_______________________________________________ PyOpenCL mailing list [email protected] http://lists.tiker.net/listinfo/pyopencl
