Skip to content
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

JOCL on Mac OS Big Sur & Apple Silicon M1 #32

Closed
psobolewskiPhD opened this issue Dec 26, 2020 · 5 comments
Closed

JOCL on Mac OS Big Sur & Apple Silicon M1 #32

psobolewskiPhD opened this issue Dec 26, 2020 · 5 comments

Comments

@psobolewskiPhD
Copy link

(First time on GitHub, not really a coder, so please be gentle.)
Out of interest in running CLIJ (https://clij.github.io) which enables running ImageJ macros on GPU, I tried to compile JOCL on my M1 MacBook Pro (Big Sur 11.1, latest command line dev tools)
I installed native CMake (3.19.2)
Cloned JOCL and JOCLCommon, according to the build instructions
I then edited the CMakeLists.txt to add at line 60/61
elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
set(JOCL_TARGET_ARCH "arm64")
I'm running Zulu 15 JDK. In CMake I set the new Env variable
CMAKE_APPLE_SILICON_PROCESSOR to arm64
also set
CMAKE_OSX_ARCHITECTURES to arm64

make generated 5 warnings of 'weak-import' but finished:
[100%] Built target JOCL_2_0_1-apple-arm64

Adding the obtained dylib to Fiji along with CLIJ and CLIJ2 yielded functioning GPU processing.
Using benchmarks from CLIJ (https://clij.github.io/clij2-docs/md/benchmarking/):
the new binary enabled a ~60X speedup:
Native CPU: ~1200 ms, Native GPU: ~20 ms
(For reference, using a fully Rosetta Fiji: Rosetta CPU: ~1600 ms, Rosetta GPU: ~160 ms)

I can share the binary or edited CMakelists.txt
See also: twitter thread with maintainer of CLIJ @haesleinhuepf
https://twitter.com/psobolewskiPhD/status/1342494593082920960?s=20

@gpu
Copy link
Owner

gpu commented Dec 29, 2020

Thanks for that heads-up @psobolewskiPhD !

I had a short look at CLIJ in the context of a PR ( #26 ), but haven't looked at the details yet. It's a pity. However, the speedup looks great. Benchmarking in detail can be difficult, but if this an existing reference benchmark, then the proof may indeed be in the wall-clock time.

For the updated CMakeLists.txt, you could either create a PR, or (if this is easier for you) post it here or send it via mail to jocl at jocl.org.

(The binary could be helpful for an actual release that could go into Maven Central, but that's currently not on my schedule ... at least, probably not before I also have time to tackle the update to OpenCL 3.0...)

@psobolewskiPhD
Copy link
Author

I'm going to be brave and try and do a PR.
Fingers crossed.

@gpu
Copy link
Owner

gpu commented Jan 1, 2021

Thanks for the PR, I just merged it, and think it's OK to close this issue then.

@gpu gpu closed this as completed Jan 1, 2021
@psobolewskiPhD
Copy link
Author

Just in case you want the binary (compiled on M1 for M1).
libJOCL_2_0_1-apple-arm64.dylib.zip

@gpu
Copy link
Owner

gpu commented Jan 2, 2021

Thanks. If I decide to make another release on Maven Central before the update to 3.0, this will be included. (Otherwise, people can just drop this binary into their local directory, and it will be picked up accordingly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants