forked from JuliaGPU/CUDA.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.jl
99 lines (72 loc) · 2.12 KB
/
profile.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import NVTX
@testset "profiler" begin
@testset "external" begin
CUDA.Profile.start()
CUDA.Profile.stop()
@test CUDA.@profile external=true begin
true
end
end
############################################################################################
@static if VERSION >= v"1.9" && CUDA.runtime_version() >= v"11.2" && can_use_cupti()
@testset "integrated" begin
# smoke test
let
str = string(CUDA.@profile true)
@test occursin("No host-side activity was recorded", str)
@test occursin("No device-side activity was recorded", str)
end
# kernel launch
let
@cuda identity(nothing)
str = string(CUDA.@profile @cuda identity(nothing))
@test occursin("cuLaunchKernel", str)
@test occursin("_Z8identityv", str)
@test !occursin("cuCtxSynchronize", str)
@test !occursin("ID", str)
end
# kernel launch (trace)
let
str = string(CUDA.@profile trace=true @cuda identity(nothing))
@test occursin("cuLaunchKernel", str)
@test occursin("_Z8identityv", str)
@test occursin("ID", str)
@test !occursin("cuCtxSynchronize", str)
end
# kernel launch (raw trace)
let
str = string(CUDA.@profile trace=true raw=true @cuda identity(nothing))
@test occursin("cuLaunchKernel", str)
@test occursin("_Z8identityv", str)
@test occursin("ID", str)
@test occursin("cuCtxSynchronize", str)
end
# benchmarked profile
let
str = string(CUDA.@bprofile @cuda identity(nothing))
@test occursin("cuLaunchKernel", str)
@test occursin("_Z8identityv", str)
@test !occursin("cuCtxGetCurrent", str)
str = string(CUDA.@bprofile raw=true @cuda identity(nothing))
@test occursin("cuLaunchKernel", str)
@test occursin("_Z8identityv", str)
@test occursin("cuCtxGetCurrent", str)
end
# JuliaGPU/NVTX.jl#37
if !Sys.iswindows()
# NVTX markers
let
str = string(CUDA.@profile trace=true NVTX.@mark "a marker")
@test occursin("NVTX marker", str)
@test occursin("a marker", str)
end
# NVTX ranges
let
str = string(CUDA.@profile trace=true NVTX.@range "a range" identity(nothing))
@test occursin("NVTX ranges", str)
@test occursin("a range", str)
end
end
end
end
end