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

Conditional load of OpenCL.jl #120

Closed
klkeys opened this issue Oct 11, 2016 · 4 comments
Closed

Conditional load of OpenCL.jl #120

klkeys opened this issue Oct 11, 2016 · 4 comments
Labels

Comments

@klkeys
Copy link

klkeys commented Oct 11, 2016

Is it possible to conditionally load OpenCL depending on whether or not Julia can find an OpenCL library? For Unix systems, I thought that I could imitate what appears in api.jl:

module MyMulticoreModule

using LotsOfCPUPackages

### only load OpenCL.jl if the library is found
const libopencl = Libdl.find_library(["libOpenCL", "OpenCL"])
if libopencl == ""
    warn("cannot find OpenCL library!")
else
     using OpenCL
end

include("my_cpu_code.jl")

### same deal
if libopencl != ""
    include("my_gpu_code.jl")
end

end
@klkeys
Copy link
Author

klkeys commented Oct 11, 2016

Perhaps not? This idea is covered in issues #6195 and #15705 in Julia Base. It appears that some problems include recompilation of the module and a revamp of type stability inference.

@juliohm
Copy link
Member

juliohm commented Oct 14, 2016

@klkeys I am doing a simple trick to optionally load OpenCL in my package: https://github.com/juliohm/ImageQuilting.jl/blob/master/src/ImageQuilting.jl#L28-L32

In that case, before every use of the GPU, I check if cl is nothing or not. It has worked for me, but it may not be worth for you, I don't know.

@klkeys
Copy link
Author

klkeys commented Oct 17, 2016

@juliohm it seems to work in my case. Thank you for the workaround!

@juliohm
Copy link
Member

juliohm commented Oct 5, 2022

We are now using OpenCL_jll to install the dependency on the platform.

@juliohm juliohm closed this as completed Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants