Skip to content

Commit fe62319

Browse files
authored
Merge pull request #730 from JuliaGPU/tb/compute_sanitizer
Switch tests over to compute-sanitizer.
2 parents eaa47ed + 86a6dc0 commit fe62319

17 files changed

+100
-79
lines changed

.buildkite/pipeline.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ steps:
2727
version: 1.6-nightly
2828
- JuliaCI/julia-test#v1:
2929
julia_args: "-g2"
30-
test_args: "--memcheck"
30+
test_args: "--sanitize --quickfail --jobs=1"
3131
- JuliaCI/julia-coverage#v1:
3232
codecov: true
3333
dirs:
@@ -39,7 +39,9 @@ steps:
3939
cuda: "11.2" # older versions of CUDA have issues
4040
cap: "recent" # test as much as possible
4141
env:
42-
JULIA_CUDA_MEMORY_POOL: 'none' # CUDA's memory pool requires compute-sanitizer
42+
JULIA_CUDA_MEMORY_POOL: 'none' # compute-sanitizer uses a lot of memory, so we need device_reset!
43+
JULIA_CUDA_VERSION: '11.2'
44+
JULIA_CUDA_USE_BINARYBUILDER: 'true'
4345
if: build.message !~ /\[skip tests\]/
4446
timeout_in_minutes: 120
4547

Artifacts.toml

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,99 +85,102 @@ lazy = true
8585

8686
[[CUDA110]]
8787
arch = "powerpc64le"
88-
git-tree-sha1 = "b22672705ca4f00c784a3f9d58619408d4af9de0"
88+
git-tree-sha1 = "25a70e995c5457a9b3c7dd7ff8a62d14acc2abc5"
8989
libc = "glibc"
9090
os = "linux"
9191
lazy = true
9292

9393
[[CUDA110.download]]
94-
sha256 = "e86a67aa8b1b2cd73d78572401efa75f9bb26f6a259f12d0471c64b74fbe204f"
95-
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.0.3+3/CUDA.v11.0.3.powerpc64le-linux-gnu.tar.gz"
94+
sha256 = "120ee6f20fc3c3c59611cf3c5b1584ed14658bb5d1bf9fd1b25a14182247d262"
95+
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.0.3+4/CUDA.v11.0.3.powerpc64le-linux-gnu.tar.gz"
9696

9797
[[CUDA110]]
9898
arch = "x86_64"
99-
git-tree-sha1 = "6b1a60793e5e98abdcfc3724cfa22b2a5348dc09"
99+
git-tree-sha1 = "74e3e04bdbf56ccf276cd8dd896ad07033846fae"
100100
libc = "glibc"
101101
os = "linux"
102102
lazy = true
103103

104104
[[CUDA110.download]]
105-
sha256 = "520e690529f67afe6aabdd8d18dc34d18acf5020cb3dc1fd4e904998d9e17aba"
106-
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.0.3+3/CUDA.v11.0.3.x86_64-linux-gnu.tar.gz"
105+
sha256 = "291e84f0d598ecbcbe438b1d42022583d061ad5f4eece2b1c06d600332b0367e"
106+
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.0.3+4/CUDA.v11.0.3.x86_64-linux-gnu.tar.gz"
107107

108108
[[CUDA110]]
109109
arch = "x86_64"
110-
git-tree-sha1 = "2d09da4d71a0762750dee0861e28029d38b08d1e"
110+
git-tree-sha1 = "1ab27f582deafbc99077d540a01141e620620177"
111111
os = "windows"
112112
lazy = true
113113

114114
[[CUDA110.download]]
115-
sha256 = "d11ca219e9b91725c6677f36b339459d149ffdcfa3f5e51928fb133158caa15a"
116-
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.0.3+3/CUDA.v11.0.3.x86_64-w64-mingw32.tar.gz"
115+
sha256 = "0ea0100ee7fa6d67c8d63ea44e719d76f6f70ce1ab5f657d7c97f30fae173af5"
116+
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.0.3+4/CUDA.v11.0.3.x86_64-w64-mingw32.tar.gz"
117+
117118

118119
[[CUDA111]]
119120
arch = "powerpc64le"
120-
git-tree-sha1 = "44dba03dc848a148c9d2430354bf7e52e216364c"
121+
git-tree-sha1 = "8837163c5563af77039b4a04a49b6e2c3f123ab4"
121122
libc = "glibc"
122123
os = "linux"
123124
lazy = true
124125

125126
[[CUDA111.download]]
126-
sha256 = "ac85a364080ea8b97e77fb83967046c54099f7c63769577fa39a1311b68add81"
127-
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.1.1+2/CUDA.v11.1.1.powerpc64le-linux-gnu.tar.gz"
127+
sha256 = "847f43a4f68c2b08c6275c988ff7c7e5414ad477a625ac78f6e4970969fccc48"
128+
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.1.1+3/CUDA.v11.1.1.powerpc64le-linux-gnu.tar.gz"
128129

129130
[[CUDA111]]
130131
arch = "x86_64"
131-
git-tree-sha1 = "48c41dccb8db0c9aa9483267cb33719207abe4c1"
132+
git-tree-sha1 = "4670dd02df5210bd53199f14ec9f8cc027d889e0"
132133
libc = "glibc"
133134
os = "linux"
134135
lazy = true
135136

136137
[[CUDA111.download]]
137-
sha256 = "b7242ce10b3fb06d886725209d5b19d565c15c7e244eb84b50262f281a04291c"
138-
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.1.1+2/CUDA.v11.1.1.x86_64-linux-gnu.tar.gz"
138+
sha256 = "84a9574db7bfb0a59dd03ef1a85874d3f33a7686507d89312700f5c519307cba"
139+
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.1.1+3/CUDA.v11.1.1.x86_64-linux-gnu.tar.gz"
139140

140141
[[CUDA111]]
141142
arch = "x86_64"
142-
git-tree-sha1 = "ad4cf0816c2c327477c512f476649bfde7ada206"
143+
git-tree-sha1 = "86505c4367204e1769e6341380841f7f589a2f4d"
143144
os = "windows"
144145
lazy = true
145146

146147
[[CUDA111.download]]
147-
sha256 = "026a92bcb8d7a5ff6f2e6e262ed8d8387164314941f0dc1b3228e383e04a60a0"
148-
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.1.1+2/CUDA.v11.1.1.x86_64-w64-mingw32.tar.gz"
148+
sha256 = "a56db28c70e9736f9ea024f3afa7fdedf899b7c998808db7d8a368e0a1208ed9"
149+
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.1.1+3/CUDA.v11.1.1.x86_64-w64-mingw32.tar.gz"
150+
149151

150152
[[CUDA112]]
151153
arch = "powerpc64le"
152-
git-tree-sha1 = "3141108f3144f5170dacc12749a61c14101b42b5"
154+
git-tree-sha1 = "ef3928da3f9b68a5213a93f91da0d27e32c01e50"
153155
libc = "glibc"
154156
os = "linux"
155157
lazy = true
156158

157159
[[CUDA112.download]]
158-
sha256 = "d7d6c399c77cabc75f1387869ca8bbef93cb6a745004993b34306e0b23d5bd18"
159-
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.2.1+0/CUDA.v11.2.1.powerpc64le-linux-gnu.tar.gz"
160+
sha256 = "770235b69868b88e6db4efc30a8659e9708f3b432028e2032ba589cf2c3efaf8"
161+
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.2.1+1/CUDA.v11.2.1.powerpc64le-linux-gnu.tar.gz"
160162

161163
[[CUDA112]]
162164
arch = "x86_64"
163-
git-tree-sha1 = "43b02b66f55952515d3cc933404d027fb904cd8b"
165+
git-tree-sha1 = "18f4e83091aec02d8229c2b009a45a5c22b47664"
164166
libc = "glibc"
165167
os = "linux"
166168
lazy = true
167169

168170
[[CUDA112.download]]
169-
sha256 = "70089c452bf923c4951048d336ac32ed28ee3672f8667bc7595fdc6190bf1990"
170-
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.2.1+0/CUDA.v11.2.1.x86_64-linux-gnu.tar.gz"
171+
sha256 = "6da495c82fae19e0aae8691addc72829376547543324358f39e16835cb208e6e"
172+
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.2.1+1/CUDA.v11.2.1.x86_64-linux-gnu.tar.gz"
171173

172174
[[CUDA112]]
173175
arch = "x86_64"
174-
git-tree-sha1 = "8b7275b36a973e6345a76b2931ddf397228e34ca"
176+
git-tree-sha1 = "4765905e93e1e93ca8d2eb52a1e8cec5de4627b1"
175177
os = "windows"
176178
lazy = true
177179

178180
[[CUDA112.download]]
179-
sha256 = "ed69a6b9630fc83e75856486fd157903c6e93e1d70e0fc7e6c67ca0dacea2b15"
180-
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.2.1+0/CUDA.v11.2.1.x86_64-w64-mingw32.tar.gz"
181+
sha256 = "6dc0ae6aab8b878864bf926fd9446c71f92f689e6115d6dcedc54ac492d30ea3"
182+
url = "https://github.com/JuliaBinaryWrappers/CUDA_jll.jl/releases/download/CUDA-v11.2.1+1/CUDA.v11.2.1.x86_64-w64-mingw32.tar.gz"
183+
181184

182185

183186
# CUDNN

deps/bindeps.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Returns the CUDA release part of the version as returned by [`version`](@ref).
3333
toolkit_release() = @after_init(VersionNumber(__toolkit_version[].major, __toolkit_version[].minor))
3434

3535
const __nvdisasm = Ref{String}()
36-
const __memcheck = Ref{Union{Nothing,String}}()
36+
const __compute_sanitizer = Ref{Union{Nothing,String}}()
3737
const __libdevice = Ref{String}()
3838
const __libcudadevrt = Ref{String}()
3939
const __libcupti = Ref{Union{Nothing,String}}()
@@ -47,10 +47,10 @@ const __libcudnn = Ref{Union{Nothing,String}}(nothing)
4747
const __libcutensor = Ref{Union{Nothing,String}}(nothing)
4848

4949
nvdisasm() = @after_init(__nvdisasm[])
50-
function memcheck()
50+
function compute_sanitizer()
5151
@after_init begin
52-
@assert has_memcheck() "This functionality is unavailabe as CUDA-MEMCHECK is missing."
53-
__memcheck[]
52+
@assert has_compute_sanitizer() "This functionality is unavailabe as compute-sanitizer is missing."
53+
__compute_sanitizer[]
5454
end
5555
end
5656
libdevice() = @after_init(__libdevice[])
@@ -68,8 +68,8 @@ function libnvtx()
6868
end
6969
end
7070

71-
export has_memcheck, has_cupti, has_nvtx
72-
has_memcheck() = @after_init(__memcheck[]) !== nothing
71+
export has_compute_sanitizer, has_cupti, has_nvtx
72+
has_compute_sanitizer() = @after_init(__compute_sanitizer[]) !== nothing
7373
has_cupti() = @after_init(__libcupti[]) !== nothing
7474
has_nvtx() = @after_init(__libnvtx[]) !== nothing
7575

@@ -173,8 +173,7 @@ function use_artifact_cuda()
173173

174174
__nvdisasm[] = artifact_binary(artifact.dir, "nvdisasm")
175175
@assert isfile(__nvdisasm[])
176-
__memcheck[] = artifact_binary(artifact.dir, "cuda-memcheck")
177-
@assert isfile(__memcheck[])
176+
__compute_sanitizer[] = artifact_binary(artifact.dir, "compute-sanitizer")
178177

179178
__libcupti[] = artifact_cuda_library(artifact.dir, "cupti", artifact.version)
180179
@assert isfile(__libcupti[])
@@ -221,7 +220,7 @@ function use_local_cuda()
221220
__nvdisasm[] = path
222221
end
223222

224-
__memcheck[] = find_cuda_binary("cuda-memcheck", cuda_dirs)
223+
__compute_sanitizer[] = find_cuda_binary("compute-sanitizer", cuda_dirs)
225224

226225
cuda_version = parse_toolkit_version("nvdisasm", __nvdisasm[])
227226
if cuda_version === nothing

src/pool.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ const pools = PerDevice{AbstractPool}(dev->begin
223223
pool
224224
end)
225225

226+
# NVIDIA bug #3240770
227+
@memoize any_stream_ordered() = any(dev->pools[dev].stream_ordered, devices())
228+
226229

227230
## interface
228231

src/state.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ so it is generally not needed to subscribe to the reset hook specifically.
344344
this package.
345345
"""
346346
function device_reset!(dev::CuDevice=device())
347-
stream_ordered = any(dev->pools[dev].stream_ordered, devices())
348-
if stream_ordered # NVIDIA bug #3240770
347+
if any_stream_ordered()
349348
@error """Due to a bug in CUDA, resetting the device is not possible on CUDA 11.2 when using the stream-ordered memory allocator.
350349
351350
If you are calling this function to free memory, that may not be required anymore

test/codegen.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,22 @@ end
140140
valid_kernel() = return
141141
invalid_kernel() = 1
142142

143-
@not_if_memcheck @test CUDA.code_sass(devnull, valid_kernel, Tuple{}) == nothing
144-
@not_if_memcheck @test_throws CUDA.KernelError CUDA.code_sass(devnull, invalid_kernel, Tuple{})
143+
@not_if_sanitize @test CUDA.code_sass(devnull, valid_kernel, Tuple{}) == nothing
144+
@not_if_sanitize @test_throws CUDA.KernelError CUDA.code_sass(devnull, invalid_kernel, Tuple{})
145145
end
146146

147147
@testset "function name mangling" begin
148148
@eval @noinline $(Symbol("dummy_^"))(x) = x
149149

150150
@eval kernel_341(ptr) = (@inbounds unsafe_store!(ptr, $(Symbol("dummy_^"))(unsafe_load(ptr))); nothing)
151151

152-
@not_if_memcheck CUDA.code_sass(devnull, kernel_341, Tuple{Ptr{Int}})
152+
@not_if_sanitize CUDA.code_sass(devnull, kernel_341, Tuple{Ptr{Int}})
153153
end
154154

155155
@testset "device runtime" begin
156156
kernel() = (CUDA.cudaGetLastError(); return)
157157

158-
@not_if_memcheck CUDA.code_sass(devnull, kernel, Tuple{})
158+
@not_if_sanitize CUDA.code_sass(devnull, kernel, Tuple{})
159159
end
160160

161161
end

test/cudadrv/module.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let
2424
@test md != md2
2525
end
2626

27-
@not_if_memcheck @test_throws_cuerror CUDA.ERROR_INVALID_IMAGE CuModule("foobar")
27+
@not_if_sanitize @test_throws_cuerror CUDA.ERROR_INVALID_IMAGE CuModule("foobar")
2828

2929
@testset "globals" begin
3030
md = CuModuleFile(joinpath(@__DIR__, "ptx/global.ptx"))
@@ -54,11 +54,11 @@ end
5454
# TODO: test with valid object code
5555
# NOTE: apparently, on Windows cuLinkAddData! _does_ accept object data containing \0
5656
if !Sys.iswindows()
57-
@not_if_memcheck @test_throws_cuerror CUDA.ERROR_UNKNOWN add_data!(link, "vadd_parent", UInt8[0])
57+
@not_if_sanitize @test_throws_cuerror CUDA.ERROR_UNKNOWN add_data!(link, "vadd_parent", UInt8[0])
5858
end
5959
end
6060

61-
@not_if_memcheck @testset "error log" begin
61+
@not_if_sanitize @testset "error log" begin
6262
@test_throws_message contains("ptxas fatal") CuError CuModule(".version 3.1")
6363

6464
link = CuLink()

test/cudadrv/pool.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@not_if_memcheck let
1+
@not_if_sanitize let
22
dev = device()
33

44
pool = memory_pool(dev)

test/cutensor/contractions.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ using CUDA.CUTENSOR
22
using CUDA
33
using LinearAlgebra
44

5+
# these tests perform a lot of harmless-but-invalid API calls, poluting sanitizer logs
6+
@not_if_sanitize begin
7+
58
eltypes = ( (Float32, Float32, Float32, Float32),
69
(Float32, Float32, Float32, Float16),
710
(ComplexF32, ComplexF32, ComplexF32, ComplexF32),
@@ -196,3 +199,5 @@ can_pin = !Sys.iswindows()
196199
end
197200
end
198201
end
202+
203+
end

test/examples.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
# NVIDIA bug 3263616: compute-sanitizer crashes when generating host backtraces,
2+
# but --show-backtrace=no does not survive execve.
3+
@not_if_sanitize begin
4+
15
# these tests spawn subprocesses, so reset the current context to conserve memory
2-
CUDA.release() == v"11.2" || CUDA.device_reset!()
6+
CUDA.any_stream_ordered() || CUDA.device_reset!()
37

48
function find_sources(path::String, sources=String[])
59
if isdir(path)
@@ -28,3 +32,5 @@ cd(examples_dir) do
2832
@test success(pipeline(`$cmd $example`, stderr=stderr))
2933
end
3034
end
35+
36+
end

test/exceptions.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
# NVIDIA bug 3263616: compute-sanitizer crashes when generating host backtraces,
2+
# but --show-backtrace=no does not survive execve.
3+
@not_if_sanitize begin
4+
15
# these tests spawn subprocesses, so reset the current context to conserve memory
2-
CUDA.release() == v"11.2" || CUDA.device_reset!()
6+
CUDA.any_stream_ordered() || CUDA.device_reset!()
37

48
@testset "stack traces at different debug levels" begin
59

@@ -83,3 +87,5 @@ let (code, out, err) = julia_script(script, `-g2`)
8387
end
8488

8589
end
90+
91+
end

test/execution.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ end
3636
@testset "compilation params" begin
3737
@cuda dummy()
3838

39-
@not_if_memcheck @test_throws CuError @cuda threads=2 maxthreads=1 dummy()
39+
@not_if_sanitize @test_throws CuError @cuda threads=2 maxthreads=1 dummy()
4040
@cuda threads=2 dummy()
4141
end
4242

@@ -58,14 +58,14 @@ end
5858
CUDA.code_warntype(devnull, dummy, Tuple{})
5959
CUDA.code_llvm(devnull, dummy, Tuple{})
6060
CUDA.code_ptx(devnull, dummy, Tuple{})
61-
@not_if_memcheck CUDA.code_sass(devnull, dummy, Tuple{})
61+
@not_if_sanitize CUDA.code_sass(devnull, dummy, Tuple{})
6262

6363
@device_code_lowered @cuda dummy()
6464
@device_code_typed @cuda dummy()
6565
@device_code_warntype io=devnull @cuda dummy()
6666
@device_code_llvm io=devnull @cuda dummy()
6767
@device_code_ptx io=devnull @cuda dummy()
68-
@not_if_memcheck @device_code_sass io=devnull @cuda dummy()
68+
@not_if_sanitize @device_code_sass io=devnull @cuda dummy()
6969

7070
mktempdir() do dir
7171
@device_code dir=dir @cuda dummy()
@@ -77,7 +77,7 @@ end
7777
@test occursin("julia_dummy", sprint(io->(@device_code_llvm io=io optimize=false @cuda dummy())))
7878
@test occursin("julia_dummy", sprint(io->(@device_code_llvm io=io @cuda dummy())))
7979
@test occursin("julia_dummy", sprint(io->(@device_code_ptx io=io @cuda dummy())))
80-
@not_if_memcheck @test occursin("julia_dummy", sprint(io->(@device_code_sass io=io @cuda dummy())))
80+
@not_if_sanitize @test occursin("julia_dummy", sprint(io->(@device_code_sass io=io @cuda dummy())))
8181

8282
# make sure invalid kernels can be partially reflected upon
8383
let

test/initialization.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# the API shouldn't have been initialized
55
@test CuCurrentContext() == nothing
6-
@not_if_memcheck @test CuCurrentDevice() == nothing
6+
@not_if_sanitize @test CuCurrentDevice() == nothing
77

88
task_cb = Any[nothing for tid in 1:Threads.nthreads()]
99
CUDA.attaskswitch() do
@@ -68,7 +68,7 @@ end
6868

6969
reset_cb()
7070

71-
if CUDA.release() != v"11.2"
71+
if !CUDA.any_stream_ordered()
7272
# NVIDIA bug #3240770
7373
device_reset!()
7474

test/pool.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CUDA.alloc(0)
22

3-
@not_if_memcheck @test_throws OutOfGPUMemoryError CuArray{Int}(undef, 10^20)
3+
@not_if_sanitize @test_throws OutOfGPUMemoryError CuArray{Int}(undef, 10^20)
44

55
@testset "@allocated" begin
66
@test (CUDA.@allocated CuArray{Int32}(undef,1)) == 4

0 commit comments

Comments
 (0)