Skip to content

Use the platform OpenCL library on Apple. #221

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Sep 10, 2024

Fixes #205

I'm not inclined to merge this, though. Apple has deprecated OpenCL, only supporting v1.2, which is ancient. I'll leave this up in case somebody really needs this, and wants to finish this. That would either involve making everything compatible with OpenCL v1.2, or introducing an opt-in preference to use the system OpenCL platform for backwards compatibility.

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 53.33%. Comparing base (9ccf867) to head (d766d80).

Files with missing lines Patch % Lines
src/util.jl 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #221       +/-   ##
===========================================
- Coverage   70.45%   53.33%   -17.13%     
===========================================
  Files           3        3               
  Lines         132      135        +3     
===========================================
- Hits           93       72       -21     
- Misses         39       63       +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maleadt maleadt mentioned this pull request Sep 10, 2024
@VarLad
Copy link
Contributor

VarLad commented Jun 19, 2025

Hey! May I ask, is the incentive for the PR to support Apple GPUs?

@maleadt
Copy link
Member Author

maleadt commented Jun 19, 2025

Yes, correct. But unlikely to happen, as stated above.

@VarLad
Copy link
Contributor

VarLad commented Jun 19, 2025

Yes, correct.

I think BDA can support this as well. :)
Not directly of course, but through Rusticl (with Zink backend) on MoltenVK (which itself is a Vulkan driver atop Metal). MoltenVK has support for a lot of Mac devices, and is good enough to support BDA.

Would be nice if someone with a Mac could test though.

@VarLad
Copy link
Contributor

VarLad commented Jun 19, 2025

Well, if someone is interested in trying, the mesa package on homebrew seems to have everything required in one package. ;)

Launch julia with RUSTICL_ENABLE=zink environment variable after installing the above package, load the OpenCL.jl package, and things should just work!

@maleadt
Copy link
Member Author

maleadt commented Jun 19, 2025

Launch julia with RUSTICL_ENABLE=zink environment variable after installing the above package, load the OpenCL.jl package, and things should just work!

Sadly not. Homebrew's build of mesa's rusticl depends on homebrew's own libLLVM, which conflicts with the one Julia loads:

❯ OCL_ICD_ENABLE_TRACE=True OCL_ICD_FILENAMES=/opt/homebrew/Cellar/mesa/25.1.4/lib/libRusticlOpenCL.1.dylib RUSTICL_ENABLE=zink julia --project -e 'using OpenCL; OpenCL.versioninfo()'
OpenCL.jl version 0.10.2

Toolchain:
 - Julia v1.11.5
 - OpenCL: 2024.10.24+1
 - SPIRV_LLVM_Backend: 20.1.5+1

KHR ICD trace at /workspace/srcdir/OpenCL-ICD-Loader/loader/icd.c:376: Found OCL_ICD_FILENAMES environment variable.
KHR ICD trace at /workspace/srcdir/OpenCL-ICD-Loader/loader/icd.c:71: attempting to add vendor ...
KHR ICD trace at /workspace/srcdir/OpenCL-ICD-Loader/loader/linux/icd_linux.c:248: Failed to load driver because dlopen(, 0x0002): tried: '' (no such file), '/System/Volumes/Preboot/Cryptexes/OS' (not a file), '/Users/tim/Julia/depot/juliaup/julia-1.11.5+0.aarch64.apple.darwin14/lib/' (not a file), '/usr/lib/' (not a file, not in dyld cache), '' (no such file), '/usr/local/lib/' (not a file), '/usr/lib/' (not a file, not in dyld cache).
KHR ICD trace at /workspace/srcdir/OpenCL-ICD-Loader/loader/icd.c:77: failed to load library
KHR ICD trace at /workspace/srcdir/OpenCL-ICD-Loader/loader/icd.c:71: attempting to add vendor /opt/homebrew/Cellar/mesa/25.1.4/lib/libRusticlOpenCL.1.dylib...
KHR ICD trace at /workspace/srcdir/OpenCL-ICD-Loader/loader/linux/icd_linux.c:248: Failed to load driver because dlopen(/opt/homebrew/Cellar/mesa/25.1.4/lib/libRusticlOpenCL.1.dylib, 0x0002): Symbol not found: _LLVMInitializeAMDGPUAsmParser
  Referenced from: <9BB39E64-602F-3724-846F-9EB912AA0235> /opt/homebrew/Cellar/llvm/20.1.7/lib/libclang-cpp.dylib
  Expected in:     <4C4C44EB-5555-3144-A187-1061A26C42DA> /Users/tim/Julia/depot/juliaup/julia-1.11.5+0.aarch64.apple.darwin14/lib/julia/libLLVM.dylib.
KHR ICD trace at /workspace/srcdir/OpenCL-ICD-Loader/loader/icd.c:77: failed to load library /opt/homebrew/Cellar/mesa/25.1.4/lib/libRusticlOpenCL.1.dylib
KHR ICD trace at /workspace/srcdir/OpenCL-ICD-Loader/loader/linux/icd_linux.c:151: Failed to open path /etc/OpenCL/vendors, continuing
KHR ICD trace at /workspace/srcdir/OpenCL-ICD-Loader/loader/linux/icd_linux.c:151: Failed to open path /etc/OpenCL/layers, continuing
┌ Error: No OpenCL drivers available, either system-wide or provided by a JLL.
│
│ Please install a system-wide OpenCL driver, or load one together with OpenCL.jl,
│ e.g., by doing `using OpenCL, pocl_jll`.
└ @ OpenCL.cl ~/Julia/pkg/OpenCL/lib/cl/api.jl:183
Available platforms: 0

If you want to proceed here, I think we'll need a JLL build of mesa that's either compatible with Julia's LLVM, or statically links its preferred version of the library.

@VarLad
Copy link
Contributor

VarLad commented Jun 19, 2025

I'll open an issue for now!

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

Successfully merging this pull request may close these issues.

v0.9.0 breaks MacOS
2 participants