Rebuild OpenCL driver for custom Linux console

I have an Altera Cyclone V SoC dev board and I followed this tutorial to build a new Linux image that includes some addition functionality, namely python-numpy. I also want to use OpenCL and I’m wondering what is the best way to do this. Is there is a way to add Altera’s OpenCL to the Yocto build; or must I recompile the driver against the built kernel and copy over the RTE files?

Any advice is appreciated, I have limited experience with embedded Linux but I’ve managed to get this far!

Update,

I’ve downloaded the opencl_arm32_rte and recompiled the driver against the kernel from altera-opensource/linux-socfpga github that was used in the Yocto build. However, whenever I try to load the aclsoc_drv.ko with insmod I get a vermagic error. If I change the suffix used in the Yocto build to match that of the linux-socfpga kernel against which I compiled the driver, then insmod hangs, I can’t even send ctrl+c interrupt.

Any idea why this hangs? or any advice here?

Update, more progress!

I used the opencl.rbf file from the prebuilt sd_card image, but what I missed in my first attempts was renaming that file. My linux console was looking for soc_system.rbf so I renamed the opencl.rbf to match and then managed to successfully install aclsoc_drv.ko.

Of course I’ve hit my next wall now, I can’t actually run any OpenCL programs on the FPGA:

root@cyclone5:~# ./host
ERROR: Unable to find Altera OpenCL platform.

For posterity, I will update myself again!

I found this in the Intel FPGA SDK for OpenCL Release Notes document:

DESCRIPTION:


The Altera SDK for OpenCL platform is now the Intel FPGA
SDK for OpenCL platform. As a result, if the
cl_platform_id findPlatform(string_name)
function in your host code looks for "Altera", "Altera SDK",
or other similar strings, the findPlatform() call will
return a NULL value. In some cases, you might not receive
a NULL value from findPlatform(), but you will
encounter a segmentation fault when running your
application.
When running design examples from previous versions, you
might encounter the following error message:
'ERROR: Unable to find Altera OpenCL Platform'

WORKAROUND


Update your host code to instruct the findPlatform()
function to search for "Intel(R) FPGA SDK for OpenCL",
"Intel(R) FPGA SDK", or "Intel(R) FPGA".
Do not limit the search string to just "Intel" because you
might have other Intel platforms in your library path.
Note: Version 16.1 of the OpenCL design examples have
been updated to search for "Intel(R) FPGA" as the
platform name.
1 Like