Skip to content

Commit

Permalink
Perform driver initialization as part of ccall library lookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Oct 4, 2021
1 parent 179498a commit 0bc1191
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 359 deletions.
2 changes: 2 additions & 0 deletions lib/cudadrv/CUDAdrv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function libcuda()
Typically, that involves an entry in '/etc/ld.so.conf', or setting LD_LIBRARY_PATH.""")
end
end

cuInit(0)
end

# memoized because otherwise each ccall would perform discovery again
Expand Down
14 changes: 0 additions & 14 deletions lib/cudadrv/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,6 @@ Base.show(io::IO, ::MIME"text/plain", err::CuError) = print(io, "CuError($(err.c

## API call wrapper

const __initialized_driver = LazyInitialized{Bool}()
@inline function initialize_api()
get!(__initialized_driver; hook=__init_driver__) do
if haskey(ENV, "_") && basename(ENV["_"]) == "rr"
@error("Running under rr, which is incompatible with CUDA")
return false
end
cuInit(0)

return true
end
return
end

@inline function initialize_context()
prepare_cuda_state()
return
Expand Down
Loading

0 comments on commit 0bc1191

Please sign in to comment.