Happy to report that the Altera PyOpenCL backend is also operational. Two things: 1. Needed to add LDFLAGS as a prefix to "-Wl,--no-as-needed" during the PyOpenCL build. Reference that pointed me towards this solution: https://stackoverflow.com/questions/8111754/how-to-pass-flags-to-a-distutils-extension/8114529#8114529
LDFLAGS="-Wl,--no-as-needed" python setup.py build sudo python setup.up install 2. During the actual run of the example Python program at https://documen.tician.de/pyopencl/, the emulation mode throws some warnings, but produces the correct results. Unlike the Xilinx OpenCL flow, there is no dead context problem! $ CL_CONTEXT_EMULATOR_DEVICE_ALTERA=1 PYOPENCL_CTX='0' PYOPENCL_COMPILER_OUTPUT=1 python example.py /usr/local/lib/python2.7/dist-packages/pyopencl-2016.2-py2.7-linux-x86_64.egg/pyopencl/__init__.py:204: CompilerWarning: From-binary build succeeded, but resulted in non-empty logs: Build on <pyopencl.Device 'EmulatorDevice : Emulated Device' on 'Altera SDK for OpenCL' at 0x7ffdf8315d88> succeeded, but said: Trivial build warn(text, CompilerWarning) Error: Specified kernel was not built for any devices [ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] 0.0 Thanks Nachiket On Fri, Aug 5, 2016 at 9:00 PM, Nachiket Kapre <nachi...@gmail.com> wrote: > Some more updates -- almost working now. > > Instead of directly calling prg.sum(), which fails for some unknown > reason (probably OpenCL 1.1 or older version issues), I replaced the > call to with the following text (shown on page > https://documen.tician.de/pyopencl/runtime_program.html) > > ```sum_knl = prg.sum > sum_knl.set_args(a_g, b_g, res_g) > ev = cl.enqueue_nd_range_kernel(queue, sum_knl, a_np.shape, None) > ``` > > This seems to work .. I get a correct result: > $ PYOPENCL_CTX='0' python example.py > [ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] > 0.0 > PyOpenCL WARNING: a clean-up operation failed (dead context maybe?) > clReleaseKernel failed with code -41 > > But, there's some issue with a dead context now... > > Nachiket > > On Fri, Aug 5, 2016 at 4:07 PM, Nachiket Kapre <nachi...@gmail.com> wrote: >> I seem to have made some progress with the Xilinx SDAccel flow. I now have >> the cl.get_boards() function returning a Xilinx device. Note: this is just a >> software emulation of the FPGA, not an actual physical FPGA as I don’t have >> a Xilinx OpenCL board with me... >> >> However, now I’m stuck at loading binaries… Showing fragment that loads >> binary. >> >> dev =cl.get_platforms()[0].get_devices() >> binary = open("sum.xclbin", "rb").read() >> prg = cl.Program(ctx,dev,[binary]) >> prg.build(); >> >> For the FPGA, there is no support for clCreateProgramFromSource().. Hence, I >> compiled my binary offline — same example as the one at >> https://documen.tician.de/pyopencl/index.html.. >> >> Now, the code segfaults here: >> prg.sum(queue, a_np.shape, None, a_g, b_g, res_g) >> >> Error: >> <pyopencl.cffi_cl.Event object at 0x7fd7407c7750> >>>>> [1] 18130 segmentation fault (core dumped) PYOPENCL_CTX='0' python >> >> Nachiket >> >> On 5 Aug 2016, at 9:45 AM, Nachiket Kapre <nachi...@gmail.com> wrote: >> >> Hi, >> >> I’m trying to figure out how to load FPGA bitstreams through the pretty >> PyOpenCL frontend. >> >> Some notes from my experiments: >> https://paper.dropbox.com/doc/PyOpenCL-for-Xilinx-FPGAs-tT2KOlxwe2YGWNBdKNyzx >> https://paper.dropbox.com/doc/PyOpenCL-with-Altera-FPGAs-8ojfCVUBhiz7UOjRTIaFe >> >> I’ve also setup a fork at https://github.com/nachiket/pyopencl with “altera” >> and “xilinx” branches with the correct paths. >> >> In both cases, I’m unable to get the APIs to work (error messages are in the >> notes above). I appreciate any pointers you might have. >> >> Nachiket >> >> _______________________________________________ PyOpenCL mailing list PyOpenCL@tiker.net https://lists.tiker.net/listinfo/pyopencl