Build JOCL for ARM

Hi,

I’ve an ARM cross compiler and I executed the makefile after adding the arm-gcc and arm-g++ path. But after compiling, I’m getting a “libJOCL-linux-x86.so” file in the lib folder. Any Idea how I can compile and generate the library file for ARM Machines??

Thanks in Advance,

Iype

Hello

Huh… I have no experience with ARM, but at least I can say for sure that this case is not covered in the library naming of the makefile. So … maybe this already IS the right library, just with a wrong name…? It should probably be called “libJOCL-linux-arm.so” (assuming that the “lib” and the “.so” are correct).

The native library of JOCL is loaded by the ‘LibUtils’ class. It should theoretically already cover ARM libraries, and should be able to load a file that is named
libJOCL-linux-arm.so
when it is in the java.library.path, but of course, I could not test this until now. I’d really like to hear whether you get it running.

bye
Marco

Hi Marco,

Thanks for your reply. I tried to execute a sample program after renaming the library file to “libJOCL-linux-arm.so”, but all I got is an unsatisfied link error.

linaro@linaro-ubuntu-desktop:/media/MYLINUXLIVE/jocl$ java -classpath .:armJOCL.jar OpenCLPart1
Obtaining platform…
Exception in thread “main” java.lang.UnsatisfiedLinkError: Error while loading native library “JOCL_0_1_9-linux-arm” with base name “JOCL_0_1_9”
Operating system name: Linux
Architecture : arm
Architecture bit size: 32
—(start of nested stack traces)—
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError: no JOCL_0_1_9-linux-arm in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at org.jocl.LibUtils.loadLibrary(LibUtils.java:80)
at org.jocl.CL.(CL.java:47)
at OpenCLPart1.main(OpenCLPart1.java:50)
Stack trace from the attempt to load the library as a resource:
java.lang.NullPointerException: No resource found with name ‘/lib/libJOCL_0_1_9-linux-arm.so’
at org.jocl.LibUtils.loadLibraryResource(LibUtils.java:200)
at org.jocl.LibUtils.loadLibrary(LibUtils.java:91)
at org.jocl.CL.(CL.java:47)
at OpenCLPart1.main(OpenCLPart1.java:50)
—(end of nested stack traces)—

at org.jocl.LibUtils.loadLibrary(LibUtils.java:122)
at org.jocl.CL.<clinit>(CL.java:47)
at OpenCLPart1.main(OpenCLPart1.java:50)

Is this error due to the wrong library file?

I also tried to build JOCL on the embedded board, but as it supports only OpenCL 1.0, it throws an error for all the ‘CL_API_SUFFIX_VERSION_1_2’ and ‘CL_EXT_SUFFIX_VERSION_1_1_DEPRECATED’ in src/CLFunctions.hpp

Thank You,

Iype

Hello

If the library is located in the same directory as everything else (i.e. the classfile and the JAR, in this case) then it should find it. But as far as I know, there are also Linux versions where the current directory is NOT automatically part of the Java Library Path, so you might try adding
-Djava.library.path .
(with a dot at the end - for the current directory)
to the command line.

Concerning the compilation: The CLFunctions.cpp is basically extracted from the Khronos OpenCL header. Maybe I could wrap all occurances of OpenCL 1.1- and 1.2-related functions into some
#ifdef CL_VERSION_1_2

#endif
blocks to allow a compilation with older OpenCL versions.

bye

Hi Marco,

I set the LD_LIBRARY_PATH to current directory, renamed the .so file and moved it to the ‘lib’ directory instead of ‘lib/linux’. This time I could eliminate the linker error. Unfortunately, there is another error now.

linaro@linaro-ubuntu-desktop:/media/PENDRIVE/jocl$ java -classpath .:armJOCL.jar OpenCLPart1
Obtaining platform…
java: symbol lookup error: /usr/lib/libOpenCL.so: undefined symbol: gcoOS_AtomConstruct

Is this because I’m using OpenCL Embedded Profile? Does JOCL support OpenCLEP?

Thanks a lot,

Iype

Hi,

I could execute a sample JOCL program on the freescale iMX6Q board. The board has a quad-core arm CPU and a Vivante GPU which supports OpenCL EP. The issue with the earlier version was the absence of preload libraries. Following is the result.

linaro@linaro-ubuntu-desktop:/media/PENDRIVE/jocl$ export LD_PRELOAD=/usr/lib/libOpenCL.so:/usr/lib/libGAL.so:/usr/lib/libCLC.so
linaro@linaro-ubuntu-desktop:/media/PENDRIVE/jocl$ java -classpath .:armJOCL.jar OpenCLPart1
Obtaining platform…
Test PASSED
Result: [0.0, 1.0, 4.0, 9.0, 16.0, 25.0, 36.0, 49.0, 64.0, 81.0]

Thank You Marco, JOCL works fine on arm machines.

For anyone who’s stuck with the same issue, these are the steps I followed.

  1. Add your cross compiler path to the makefile.
  2. Set the JAVA_HOME path.
  3. Include the ‘bits/predefs.h’ and ‘GL/gl.h’ path in makefile.
  4. Execute makefile.
  5. Copy the generated library file from ‘lib/linux’ to ‘lib’ and rename it to “libJOCL_0_1_9-linux-arm.so”.
  6. Generate the jar file.
  7. On the arm machine, set the LD_LIBRARY_PATH to current directory or ‘.’ and set the LD_PRELOAD path as shown above.
  8. compile and run your programs.

Thanks,
Iype

Thanks Iype for this summary! :slight_smile:

I have not yet heard about any specific demand for ARM binaries, but if someone is looking for them, this summary will certainly be helpful. Maybe future releases of the JOCL JAR could also contain these binaries like it already contains those for the x86 architecture…