-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port to Android Toolchain #4
Conversation
+ Add explicit support for Android ARM architectures. + Sizeof.computePointerSize() now delegates to native implementation as System.getProperty("sun.arch.data.model") does not exist on Android. Likely a more portable solution in the long run considering that we already rely on JNI. + LibInitializer.java now searches through a list of potential OpenCL shared library candidates. Some Android platforms that support OpenCL store their library under different names or in non-standard locations. Would this be better placed somewhere else? + Android shared library outputs to `nativeLibraries/${ANDROID_ABI}/` to comply with canonical Android lib location (also the only place the Android runtime checks when searching for a shared library through System.loadLibrary(...)). + Document building for Android. Currently describes building using a global installation of android-cmake. Possible to cross-compile without this toolchain file, but 10x more painful and 10x more edge-cases. + Should be merged in conjunction with the commit of the same name under JOCLCommon. TODO: More general cross-compiling support? TODO: Better, more explicit support for other OS's / ARCH's? TODO: Library would be more accessible if uploaded to maven repo. But we also have native libraries which makes everything painful. TODO: Refactor out native library loading to another library? There's lots of redundancy and slight changes between this LibUtils, jcuda's LibUtils, our LibUtils (BIDMat), etc...
+ Needed for Android build, as Android doesn't support java 8 + See: http://stackoverflow.com/a/22981151
Thanks for this contribution! Actually, I created an Android version of JOCL ~4 years ago, but I had a non-disclosure-agreement with some company (which now does no longer seem to give a ... care about this topic - and the NDA was limited to 3 years, so ... the risk of being sued should be rather small). I remember that there had been some other issues. From the tip of my head, there was something related to the inheritance hierarchy of the I'll have to read through the changes in more detail. I'll try to do this during the weekend, and give it a try early next week (I should even be able to test it on some android device - the above mentioned company provided me one, and they never wanted it back...). But quickly going over the changes and the points that you mentioned:
Regarding the TODOs: Generalizations regarding the target platforms (and their build processes): These are always welcome. However, they may increase the complexity of the makefiles considerably. (You might have noticed that the current issues in the issue tracker are related to "embarassingly basic" problems of building on other platforms - I hope that a robust, portable and maintainable solution can be found there soon...) The native library deployment (and loading) is indeed an issue. There have been some related discussions in the JOCL forum. The migration of JOCL from "a downloadable ZIP" to "a Maven artifact" was a hassle. (For me, because I'm not a Maven expert, and ... native libraries are always difficult in Maven). I'll try to summarize some points here (and consider to open one or more dedicated issues in the issue tracker for these) :
(BTW: I didn't even know BIDMat, thanks for this pointer) |
I'm not sure this is always valid. While the system might be 64 bit, the library and/or JVM could be compiled as 32 bit. I'm not sure how exactly the "os.arch" responds to say a 32 bit vs 64 bit JVM or the precise interplay between JVM and native pointers; but (from my understanding, please correct me if I'm wrong), I would assume the native code interacting with the OpenCL API is the source of truth in this case.
I agree. It's definitely not pretty, but Google has not standardized OpenCL on Android (they're pushing for their own framework called Renderscript). As a result, every vendor seems to put their library in nonstandard locations...
Unfortunately, I don't think Android supports unpacking the library and then loading it (might have something to do with permissions?) Maybe I'm wrong, but I haven't had any luck with the extract and then load process. Android's loadLibrary method is nonstandard in that a call to loadLibrary("libfoo.so") searches not for lib/libfoo.so but rather lib/armveabi-v7a/libfoo.so and lib/arm/libfoo.so if, for example, the device is running an armv7a compatible processor. I would like a more standard and maintainable library loading method, however. On a different note, I'm wondering whether we should classify Android as its own OS or put it under Linux in |
On the one hand, you are right. According to a quick websearch,
This may be true. I had another look at my old JOCL-Android project, and noticed the Regarding the pull request: I had a closer look at this, and it seems that it is safe and compatible to the existing toolchains. I reviewed the changes, tested it locally, and everything worked fine. So I merged it locally, with minor adjustments, and will push it soon. One thing: In gpu/JOCLCommon#3 you added the Apart from that, I'm currently updating (or rather reviving) my Android infrastructure: I downloaded Android Studio and try to familiarize with it, and see how the NDK interplays with it. I have some trouble with my android device (API version 7 ... ) : It's connected to the USB for 1 hour now, and still says "Charging: 0%" - hope it's not a defect battery... However, I hope that once everything is set up, I can actually try out your changes. |
Forgot that one:
Although it does not make a difference in the |
System.getProperty("sun.arch.data.model") does not exist on Android.
Likely a more portable solution in the long run considering that we
already rely on JNI.
shared library candidates. Some Android platforms that support OpenCL
store their library under different names or in non-standard locations.
Would this be better placed somewhere else?
nativeLibraries/${ANDROID_ABI}/
to comply with canonical Android lib location (also the only place the
Android runtime checks when searching for a shared library through
System.loadLibrary(...)).
global installation of android-cmake. Possible to cross-compile without
this toolchain file, but 10x more painful and 10x more edge-cases.
under JOCLCommon. Port to Android Toolchain JOCLCommon#3
TODO: More general cross-compiling support?
TODO: Better, more explicit support for other OS's / ARCH's?
TODO: Library would be more accessible if uploaded to maven repo. But we
also have native libraries which makes everything painful.
TODO: Refactor out native library loading to another library? There's
lots of redundancy and slight changes between this LibUtils, jcuda's
LibUtils, our LibUtils (BIDMat), etc...