From d766d80314b61b4be279b35b9d6a1fd5dff0f812 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 10 Sep 2024 12:17:44 +0200 Subject: [PATCH] Use the platform OpenCL library on Apple. --- lib/api.jl | 15 +++++++++++---- src/util.jl | 6 +++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/api.jl b/lib/api.jl index c3a52c5f..67abaa15 100644 --- a/lib/api.jl +++ b/lib/api.jl @@ -1,6 +1,9 @@ -import OpenCL_jll - -const libopencl = OpenCL_jll.libopencl +const libopencl = if Sys.isapple() + "/System/Library/Frameworks/OpenCL.framework/OpenCL" +else + import OpenCL_jll + OpenCL_jll.libopencl +end """ @checked function foo(...) @@ -76,6 +79,8 @@ const initialized = Ref{Bool}(false) @noinline function initialize() initialized[] = true + Sys.isapple() && return + if isempty(OpenCL_jll.drivers) @warn """No OpenCL driver JLLs were detected at the time of the first call into OpenCL.jl. Only system drivers will be available.""" @@ -96,7 +101,9 @@ const initialized = Ref{Bool}(false) end function __init__() - if !OpenCL_jll.is_available() + if Sys.isapple() + @warn "on macOS, OpenCL.jl uses the system OpenCL framework, which is deprecated." + elseif !OpenCL_jll.is_available() @error "OpenCL_jll is not available for your platform, OpenCL.jl. will not work." end end diff --git a/src/util.jl b/src/util.jl index 18b3202f..27e9c399 100644 --- a/src/util.jl +++ b/src/util.jl @@ -53,7 +53,11 @@ function versioninfo(io::IO=stdout) println(io, "Toolchain:") println(io, " - Julia v$(VERSION)") - for pkg in [cl.OpenCL_jll] + pkgs = [] + if !Sys.isapple() + push!(pkgs, OpenCL_jll) + end + for pkg in pkgs println(io, " - $(string(pkg)) v$(pkgversion(pkg))") end println(io)