gpu / JOCL

Java bindings for OpenCL
http://www.jocl.org
Other
187 stars 33 forks source link

Load arm64 library on aarch64 arch #38

Closed Adam- closed 3 years ago

Adam- commented 3 years ago

Java has two 64-bit arm ports, arm64 and aarch64, with newer Java versions having only aarch64 - https://openjdk.java.net/jeps/340 In particular, the new Zulu VM builds running on the new Apple M1s use aarch64, so currently arch detection on them fails.

gpu commented 3 years ago

I'll have to look at the details, but maybe the essential part can be answered quickly: Even when aarch64 is reported, the same native library (i.e. the same .so file) can be used, is that correct?

Adam- commented 3 years ago

Yes. I've tested this on an m1 machine. I'm somewhat confused how #32 was closed since jocl definitely doesn't work on m1 machines currently for me.

gpu commented 3 years ago

Again, there are some details that I'll have to take a closer look at, but the other issue was mainly about the build infrastructure - namely, modifying the CMake so that the specific arm64 library could be built (and comparing it to this PR, the aarch64 string apparently was not relevant there).

The library that was provided in the other issue does not contain the function that was added via https://github.com/gpu/JOCL/pull/36, so it would not be compatible with the latest release. So this native library is currently not part of the JOCL release.

Is this what you referred to when you said that it "does not work"?

(If you can provide an additional native binary, based on the state from 2.0.3, then I could add this as part of a new release (i.e. 2.0.4, without actual changes, just including the additional library)).

Adam- commented 3 years ago

"does not work" as in

java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Error while loading native library "JOCL_2_0_3-apple-unknown"
Operating system name: Mac OS X
Architecture         : aarch64
Architecture bit size: 64
---(start of nested stack traces)---
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError: no JOCL_2_0_3-apple-unknown in java.library.path: 

It detects the arch as UNKNOWN. These two binaries should be equivalent to what you use but I have renamed them:

http://repo.runelite.net/net/runelite/jocl/jocl/1.0/jocl-1.0-macos-arm64.jar http://repo.runelite.net/net/runelite/jocl/jocl/1.0/jocl-1.0-macos-x64.jar

The existing pr using arm64 is definitely correct in cmake. That is for the clang -arch parameter.

gpu commented 3 years ago

The guy from the other PR probably had the arm64 version, and thus, the two issues are apparently independent. But in any case: I'll schedule a release 2.0.4 that will contain the additional binaries that you provided, and the corresponding fix in the LibUtils. (I should be able to do this soon, maybe tomorrow, but not later than during the weekend).

gpu commented 3 years ago

Version 2.0.4, including the fix for loading the right binaries for the aarch64 case and the arm64 binary that you provided is available under

<dependency>
    <groupId>org.jocl</groupId>
    <artifactId>jocl</artifactId>
    <version>2.0.4</version>
</dependency>

If you encounter any problem, just let me know.

Thanks again for your contribution!