JOCL on the ODROID-XU / Android

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

JOCL on the ODROID-XU / Android

MichaelEGR
Greets,

This is my first post and I look forward to participating with the Jogamp community in getting JOCL support on Android. The ODROID-XU is presently the only Android device that has unfettered access to OpenCL since it is a development board outside the purview of Google's attempts to block OpenCL access.

http://www.hardkernel.com/renewal_2011/products/prdt_info.php?g_code=G137510300620

I notated on the 773 issue the location of the PowerVR OpenCL driver. Quite likely it is located in a similar place for all PowerVR based SoCs.

https://jogamp.org/bugzilla/show_bug.cgi?id=773

The driver is located here:
/system/vendor/lib/libPVROCL.so

Xerxes, made some comments about possible modifications to JOCL to support dynamic driver loading. Since I am not familiar with the internals of building JOCL presently it may take me some time to take a look. This is a priority task for me though because I am speaking at two Android conferences (OnAndroidConf & AnDevCon) on OpenCL for Android. The first being in two weeks, so indeed I'd like to get this working. I have desktop and Android demos built, but just lack the last step of getting JOCL working with the ODROID-XU.

Given that Xerxes proposed some changes in 773 is there any way that those changes can be made then I can take a look at how to add the proper lookup for the ODROID / PowerVR drivers.

Here is what Xerxes proposed:
------------
The best way to resolve this bug is to move the implementation into a new class
com.jogamp.opencl.CLDynamicLibraryBundleInfo and use the DynamicLibraryBundle helper class provided by Gluegen.
http://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/os/DynamicLibraryBundle.html
http://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/os/DynamicLibraryBundleInfo.html

I suggest to make JOCL library and symbol look-up similar to how we do dynamic library symbol look-up inside multiple librarys for the JOGL project. You may take a look at the com.jogamp.opengl.GLDynamicLibraryBundleInfo implementation to see how we prefer to do dynamic library loading and symbol look-up inside the JogAmp projects.
------------

If the above changes can be made it will be easier for me to continue investigating getting things working on the ODROID-XU.  Xerxes, do you think you can complete your proposed changes since you are more familiar with the internal workings of JOCL and can implement things appropriately to be similar to the GLDynamicLibaryBundleInfo functionality?

Thanks for taking a look or communicating more on how to resolve dynamic loading of the OpenCL driver.

--Mike
Reply | Threaded
Open this post in threaded view
|

Re: JOCL on the ODROID-XU / Android

Xerxes Rånby
The quickest way to get your demo running within 2 weeks may be to create a symlink on your device libopencl.so -> /system/vendor/lib/libPVROCL.so
And then install and use the prebuilt jocl-armeabi.apk
http://jogamp.org/deployment/jogamp-current/apk/

The second quickest way it to change the lib search path in the JOCL JNI Lib loader is currently located in com.jogamp.opencl.JOCLJNILibLoader
and then compile your own jocl-armeabi.apk

JogAmp may start looking into a proper solution to bug/enhancement 773 issue first after the now imminent 2.1.0 release.
Reply | Threaded
Open this post in threaded view
|

Re: JOCL on the ODROID-XU / Android

MichaelEGR
Cool, I'll definitely take a look as soon as I can.. The new day gig is consuming my time, so yeah.. This is going to be one of those barn storming getting the demo working without much time to spare to get the slides & white paper ready kind of thing for the initial presentation at OnAndroidConf... It should be a good audience though...

One of the solutions I'm proposing for Google and the rest of the Android OEM world to do instead of intentionally crippling their devices is to make the library accessible by a LOCAL_LDLIBS parameter in the NDK build files then add a uses-feature tag in the AndroidManifest to filter out devices that don't have OpenCL support in a similar manner that one handles OpenGL ES version filtering. No need for anything more than this / no software OpenCL support necessary... Just a uses-feature tag and easy library alias / connection to the native build process. I suppose one could even request versions and profiles too in the manifest filter tag. IE they don't need to support a public API, but just make it easy to link to the library if a given device supports it. There will be plenty of Java bindings available.  I'm sure they spent far more effort than the above to cripple it on the Nexus devices.

I assume JOCL is pointed at:
/system/lib/libopencl.so

Since you were quite active in the little Android issue for CL that got closed down in August I'd be glad to pick your brain offline and discuss some of the points I'll be making about the situation. As far as audiences go it should get some word out on the situation. Showing working demos is important too when one is trying to talk up how cool it is to do GPU compute across the desktop and Android from a shared Java codebase that doesn't require mods for each platform! Yep.... Almost there...
Reply | Threaded
Open this post in threaded view
|

Re: JOCL on the ODROID-XU / Android

MichaelEGR
Sven et al....

Thanks for taking a look at adding the Android libPVROCL.so loading... I got stuck though still in trying to print out basic OpenCL device info.

in my basic test execution hangs after "CLContext.create();"

Here is what is output in the logs:

3821-3844/? D/dalvikvm﹕ Trying to load lib /data/app-lib/com.egrsoftware.gridwalk-1/libgluegen-rt.so 0x4109c678
3821-3844/? D/dalvikvm﹕ Added shared lib /data/app-lib/com.egrsoftware.gridwalk-1/libgluegen-rt.so 0x4109c678
3821-3844/? D/dalvikvm﹕ No JNI_OnLoad found in /data/app-lib/com.egrsoftware.gridwalk-1/libgluegen-rt.so 0x4109c678, skipping init
3821-3844/? D/dalvikvm﹕ Trying to load lib /data/app-lib/com.egrsoftware.gridwalk-1/libjocl.so 0x4109c678
3821-3844/? D/dalvikvm﹕ Added shared lib /data/app-lib/com.egrsoftware.gridwalk-1/libjocl.so 0x4109c678
3821-3844/? E/IMGSRV﹕ :0: Invalid device type.

Execution halts after "Invalid device type"...

As things go I don't have visibility into the depths of JOCL yet and can't proceed with prepping the demos for tomorrows talk. It's a bummer not to have the CL demos running on the ODROID, but there is plenty to talk about. Hopefully the audience is receptive to the bleeding edge nature of OpenCL on Android. I basically hit my coding drop dead time, so now it's off to slide making... If possible though if you have any thoughts on what to attempt I'd be glad to take a look.

------------------------------------------

For folks using Android Studio here is how to setup the gradle.build file for including the JogAmp native libraries:

dependencies {
    compile files('libs/gluegen-rt.jar')
    compile files('libs/jogl.jar')
    compile files('libs/jocl.jar')
    compile files("$buildDir/native-libs/native-libs.jar")
}

task nativeLibsToJar(type: Zip) {
    destinationDir file("$buildDir/native-libs")
    baseName 'native-libs'
    extension 'jar'
    from fileTree(dir: 'libs', include: '**/*.so')
    into 'lib/'
}

tasks.withType(Compile) {
    compileTask -> compileTask.dependsOn(nativeLibsToJar)
}



-------------------

Put the Android native files in libs/armeabi

I validated that indeed the *.so files are included in the Android app build process and they are indeed found given the log output above.

I don't think jogl.jar and natives are necessary, but after I couldn't get things to work with just the gluegen and jocl native libraries I added them just in case.

-------------------

For anyone who is picking up the ODROID-XU be sure to sign up for the gpu-compute early access program from Imagination Tech:
http://www.imgtec.com/powervr/insider/gpu_compute/
Reply | Threaded
Open this post in threaded view
|

Re: JOCL on the ODROID-XU / Android

Xerxes Rånby
JogAmp JOCL has added the flexible opencl lib lookup and Android JOCl test applications since the 2.1.4 release and laters.
https://jogamp.org/bugzilla/show_bug.cgi?id=863 - Android: Add JOCL Version Info Test
https://jogamp.org/bugzilla/show_bug.cgi?id=773 - Device specific JOCL dynamic library look-up on Android (including libPVROCL.so lookup if Android ..)

Thus JOCL on the ODROID-XU / Android should now be supported out of the box.
http://jogamp.org/deployment/jogamp-current/apk/