ajkxyz / opencl4py

Python cffi OpenCL bindings and helper classes
Other
6 stars 19 forks source link

opencl4py for FPGA #7

Open mohmsslk opened 8 years ago

mohmsslk commented 8 years ago

Hello, I used to use OpenCL with FPGA, the OpenCL project has two code, the kernel and the host, the host is written in C++ but I want to use it with python, as Im new here, can I use opencl4py for that? take in account that the kernel code I compile it with SDK Altera OpenCL compiler to get the file which I use it to configure the FPGA to have Kernel. becuse I see that you writte the kernel code with host code. Thank you in advance

ajkxyz commented 8 years ago

Hello, From what I've read on Altera's site, the compilation of OpenCL kernels for FPGA is only done in offline mode using their separate compiler. That compiler produces OpenCL binary which can further be provided to the standard clCreateProgramWithBinary() function. So, the opencl4py will probably work if Altera registers their OpenCL driver within the system or provides standard shared library (libOpenCL.so / OpenCL.dll).

You can check if the Altera's device is listed in the system OpenCL devices with the code: import opencl4py as cl print(cl.Platforms().dump_devices()) and if it is listed, you can later create program with the binary: prg = ctx.create_program(open("test.aocx", "rb").read(), binary=True) where ctx is the corresponding OpenCL context.