forked from JuliaGPU/CUDA.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exceptions.jl
75 lines (61 loc) · 2.45 KB
/
exceptions.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# these tests spawn subprocesses, so reset the current context to conserve memory
CUDA.device_reset!()
@testset "stack traces at different debug levels" begin
script = """
function kernel(arr, val)
arr[1] = val
return
end
cpu = zeros(Int)
gpu = CuArray(cpu)
@cuda kernel(gpu, 1.2)
Array(gpu)
# FIXME: on some platforms (Windows...), for some users, the exception flag change
# doesn't immediately propagate to the host, and gets caught during finalization.
# this looks like a driver bug, since we threadfence_system() after setting the flag.
# https://stackoverflow.com/questions/16417346/cuda-pinned-memory-flushing-from-the-device
sleep(1)
synchronize()
Array(gpu)
"""
let (code, out, err) = julia_script(script, `-g0`)
@test code == 1
@test occursin("ERROR: KernelException: exception thrown during kernel execution on device", err)
@test !occursin("ERROR: a exception was thrown during kernel execution", out)
# NOTE: stdout sometimes contain a failure to free the CuArray with ILLEGAL_ACCESS
end
let (code, out, err) = julia_script(script, `-g1`)
@test code == 1
@test occursin("ERROR: KernelException: exception thrown during kernel execution on device", err)
@test occursin("ERROR: a exception was thrown during kernel execution", out)
@test occursin("Run Julia on debug level 2 for device stack traces", out)
end
let (code, out, err) = julia_script(script, `-g2`)
@test code == 1
@test occursin("ERROR: KernelException: exception thrown during kernel execution on device", err)
@test occursin("ERROR: a exception was thrown during kernel execution", out)
if VERSION < v"1.3.0-DEV.270"
@test occursin("[1] Type at float.jl", out)
else
@test occursin("[1] Int64 at float.jl", out)
end
@test occursin("[4] kernel at none:5", out)
end
end
@testset "#329" begin
script = """
@noinline foo(a, i) = a[1] = i
bar(a) = (foo(a, 42); nothing)
ptr = reinterpret(Core.LLVMPtr{Int,AS.Global}, C_NULL)
arr = CuDeviceArray{Int,1,AS.Global}((0,), ptr)
@cuda bar(arr)
CUDA.synchronize()
"""
let (code, out, err) = julia_script(script, `-g2`)
@test code == 1
@test occursin("ERROR: KernelException: exception thrown during kernel execution on device", err)
@test occursin("ERROR: a exception was thrown during kernel execution", out)
@test occursin("foo at none:4", out)
@test occursin("bar at none:5", out)
end
end