Skip to content

Commit fc1d509

Browse files
vchuravymaleadt
andauthored
Mark all ccalls as GC safe (#2262)
This allows the GC to run while potentially blocking in a CUDA library. To make this safe, callbacks into Julia should again transition to GC-unsafe mode. It should be reimplemented when JuliaLang/julia#49933 lands. Co-authored-by: Tim Besard <tim.besard@gmail.com>
1 parent 297c628 commit fc1d509

File tree

28 files changed

+16107
-14142
lines changed

28 files changed

+16107
-14142
lines changed

.buildkite/pipeline.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,12 @@ steps:
132132
println("--- :julia: Instantiating project")
133133
withenv("JULIA_PKG_PRECOMPILE_AUTO" => 0) do
134134
Pkg.activate(joinpath(pwd(), "lib", lowercase("{{matrix.package}}")))
135-
Pkg.instantiate()
135+
try
136+
Pkg.instantiate()
137+
catch
138+
# if we fail to instantiate, assume that we need a newer CUDA.jl
139+
Pkg.develop(path=".")
140+
end
136141
137142
Pkg.add("CUDA_Runtime_jll")
138143
write("LocalPreferences.toml", "[CUDA_Runtime_jll]\nversion = \"{{matrix.cuda}}\"")

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "CUDA"
22
uuid = "052768ef-5323-5732-b1bb-66c8b64840ba"
3-
version = "5.2.0"
3+
version = "5.3.0"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

lib/cublas/CUBLAS.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function log_message(ptr)
210210
return
211211
end
212212

213-
function _log_message(blob)
213+
@gcunsafe_callback function _log_message(blob)
214214
# the message format isn't documented, but it looks like a message starts with a capital
215215
# and the severity (e.g. `I!`), and subsequent lines start with a lowercase mark (`!i`)
216216
#

lib/cublas/libcublas.jl

Lines changed: 3214 additions & 2702 deletions
Large diffs are not rendered by default.

lib/cudadrv/libcuda.jl

Lines changed: 1016 additions & 923 deletions
Large diffs are not rendered by default.

lib/cudadrv/occupancy.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ end
3636
# HACK: callback function for `launch_configuration` on platforms without support for
3737
# trampolines as used by `@cfunction` (JuliaLang/julia#27174, JuliaLang/julia#32154)
3838
_shmem_cb = nothing
39-
_shmem_cint_cb(x::Cint) = Cint(something(_shmem_cb)(x))
39+
@gcunsafe_callback function _shmem_cint_cb(x::Cint)
40+
Cint(something(_shmem_cb)(x))
41+
end
4042
_shmem_cb_lock = Threads.ReentrantLock()
4143

4244
"""
@@ -58,7 +60,9 @@ function launch_configuration(fun::CuFunction; shmem::Union{Integer,Base.Callabl
5860
if isa(shmem, Integer)
5961
cuOccupancyMaxPotentialBlockSize(blocks_ref, threads_ref, fun, C_NULL, shmem, max_threads)
6062
elseif Sys.ARCH == :x86 || Sys.ARCH == :x86_64
61-
shmem_cint = threads -> Cint(shmem(threads))
63+
@gcunsafe_callback function shmem_cint(threads)
64+
Cint(shmem(threads))
65+
end
6266
cb = @cfunction($shmem_cint, Cint, (Cint,))
6367
cuOccupancyMaxPotentialBlockSize(blocks_ref, threads_ref, fun, cb, 0, max_threads)
6468
else

lib/cudnn/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "cuDNN"
22
uuid = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"
33
authors = ["Tim Besard <tim.besard@gmail.com>"]
4-
version = "1.3.0"
4+
version = "1.3.1"
55

66
[deps]
77
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
@@ -11,7 +11,7 @@ CUDNN_jll = "62b44479-cb7b-5706-934f-f13b2eb2e645"
1111

1212
[compat]
1313
CEnum = "0.2, 0.3, 0.4, 0.5"
14-
CUDA = "~5.1, ~5.2"
14+
CUDA = "~5.3"
1515
CUDA_Runtime_Discovery = "0.2"
1616
CUDNN_jll = "~8.9"
1717
julia = "1.8"

lib/cudnn/src/cuDNN.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function log_message(sev, udata, dbg_ptr, ptr)
137137
return
138138
end
139139

140-
function _log_message(sev, dbg, str)
140+
@gcunsafe_callback function _log_message(sev, dbg, str)
141141
lines = split(str, '\0')
142142
msg = join(lines, '\n')
143143
if sev == CUDNN_SEV_INFO

lib/cudnn/src/libcudnn.jl

Lines changed: 1694 additions & 1587 deletions
Large diffs are not rendered by default.

lib/cufft/libcufft.jl

Lines changed: 88 additions & 77 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)