Skip to content

Commit 969e00d

Browse files
authored
Use Tracy instead of TimerOutputs (#688)
1 parent c4cda76 commit 969e00d

File tree

8 files changed

+29
-36
lines changed

8 files changed

+29
-36
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Preferences = "21216c6a-2e73-6563-6e65-726566657250"
1414
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
1515
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
1616
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
17-
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
17+
Tracy = "e689c965-62c8-4b79-b2c5-8359227902fd"
1818
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1919

2020
[compat]
@@ -28,6 +28,6 @@ Preferences = "1"
2828
Scratch = "1"
2929
Serialization = "1"
3030
TOML = "1"
31-
TimerOutputs = "0.5"
31+
Tracy = "0.1.4"
3232
UUIDs = "1"
3333
julia = "1.10"

src/GPUCompiler.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module GPUCompiler
33
using LLVM
44
using LLVM.Interop
55

6-
using TimerOutputs
6+
using Tracy
77

88
using ExprTools: splitdef, combinedef
99

@@ -64,6 +64,8 @@ function __init__()
6464
end
6565
mkpath(dir)
6666
global compile_cache = dir
67+
68+
Tracy.@register_tracepoints()
6769
end
6870

6971
end # module

src/driver.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function compile_unhooked(output::Symbol, @nospecialize(job::CompilerJob); kwarg
8282
error("No active LLVM context. Use `JuliaContext()` do-block syntax to create one.")
8383
end
8484

85-
@timeit_debug to "Validation" begin
85+
@tracepoint "Validation" begin
8686
check_method(job) # not optional
8787
job.config.validate && check_invocation(job)
8888
end
@@ -96,7 +96,7 @@ function compile_unhooked(output::Symbol, @nospecialize(job::CompilerJob); kwarg
9696

9797
if output == :llvm
9898
if job.config.strip
99-
@timeit_debug to "strip debug info" strip_debuginfo!(ir)
99+
@tracepoint "strip debug info" strip_debuginfo!(ir)
100100
end
101101

102102
return ir, ir_meta
@@ -168,7 +168,7 @@ const __llvm_initialized = Ref(false)
168168
__llvm_initialized[] = true
169169
end
170170

171-
@timeit_debug to "IR generation" begin
171+
@tracepoint "IR generation" begin
172172
ir, compiled = irgen(job)
173173
if job.config.entry_abi === :specfunc
174174
entry_fn = compiled[job.source].specfunc
@@ -267,21 +267,21 @@ const __llvm_initialized = Ref(false)
267267
runtime_intrinsics = ["julia.gc_alloc_obj"]
268268
end
269269

270-
@timeit_debug to "Library linking" begin
270+
@tracepoint "Library linking" begin
271271
# target-specific libraries
272272
undefined_fns = LLVM.name.(decls(ir))
273-
@timeit_debug to "target libraries" link_libraries!(job, ir, undefined_fns)
273+
@tracepoint "target libraries" link_libraries!(job, ir, undefined_fns)
274274

275275
# GPU run-time library
276276
if !uses_julia_runtime(job) && any(fn -> fn in runtime_fns ||
277277
fn in runtime_intrinsics,
278278
undefined_fns)
279-
@timeit_debug to "runtime library" link_library!(ir, runtime)
279+
@tracepoint "runtime library" link_library!(ir, runtime)
280280
end
281281
end
282282
end
283283

284-
@timeit_debug to "IR post-processing" begin
284+
@tracepoint "IR post-processing" begin
285285
# mark everything internal except for entrypoints and any exported
286286
# global variables. this makes sure that the optimizer can, e.g.,
287287
# rewrite function signatures.
@@ -312,7 +312,7 @@ const __llvm_initialized = Ref(false)
312312
end
313313

314314
if job.config.toplevel && job.config.optimize
315-
@timeit_debug to "optimization" begin
315+
@tracepoint "optimization" begin
316316
optimize!(job, ir; job.config.opt_level)
317317

318318
# deferred codegen has some special optimization requirements,
@@ -339,7 +339,7 @@ const __llvm_initialized = Ref(false)
339339
end
340340

341341
if job.config.toplevel && job.config.cleanup
342-
@timeit_debug to "clean-up" begin
342+
@tracepoint "clean-up" begin
343343
@dispose pb=NewPMPassBuilder() begin
344344
add!(pb, RecomputeGlobalsAAPass())
345345
add!(pb, GlobalOptPass())
@@ -379,13 +379,13 @@ const __llvm_initialized = Ref(false)
379379
end
380380

381381
if job.config.toplevel && job.config.validate
382-
@timeit_debug to "Validation" begin
382+
@tracepoint "Validation" begin
383383
check_ir(job, ir)
384384
end
385385
end
386386

387387
if should_verify()
388-
@timeit_debug to "verification" verify(ir)
388+
@tracepoint "verification" verify(ir)
389389
end
390390

391391
return ir, (; entry, compiled)
@@ -395,13 +395,13 @@ end
395395
format::LLVM.API.LLVMCodeGenFileType)
396396
# NOTE: strip after validation to get better errors
397397
if job.config.strip
398-
@timeit_debug to "Debug info removal" strip_debuginfo!(ir)
398+
@tracepoint "Debug info removal" strip_debuginfo!(ir)
399399
end
400400

401-
@timeit_debug to "LLVM back-end" begin
402-
@timeit_debug to "preparation" prepare_execution!(job, ir)
401+
@tracepoint "LLVM back-end" begin
402+
@tracepoint "preparation" prepare_execution!(job, ir)
403403

404-
code = @timeit_debug to "machine-code generation" mcgen(job, ir, format)
404+
code = @tracepoint "machine-code generation" mcgen(job, ir, format)
405405
end
406406

407407
return code, ()

src/gcn.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ end
6161
function lower_throw_extra!(mod::LLVM.Module)
6262
job = current_job::CompilerJob
6363
changed = false
64-
@timeit_debug to "lower throw (extra)" begin
64+
@tracepoint "lower throw (extra)" begin
6565

6666
throw_functions = [
6767
r"julia_bounds_error.*",

src/irgen.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# LLVM IR generation
22

33
function irgen(@nospecialize(job::CompilerJob))
4-
mod, compiled = @timeit_debug to "emission" compile_method_instance(job)
4+
mod, compiled = @tracepoint "emission" compile_method_instance(job)
55
if job.config.entry_abi === :specfunc
66
entry_fn = compiled[job.source].specfunc
77
else
@@ -11,7 +11,7 @@ function irgen(@nospecialize(job::CompilerJob))
1111
entry = functions(mod)[entry_fn]
1212

1313
# clean up incompatibilities
14-
@timeit_debug to "clean-up" begin
14+
@tracepoint "clean-up" begin
1515
for llvmf in functions(mod)
1616
if Base.isdebugbuild()
1717
# only occurs in debug builds
@@ -81,7 +81,7 @@ function irgen(@nospecialize(job::CompilerJob))
8181
(; compiled[job.source].ci, func, specfunc)
8282

8383
# minimal required optimization
84-
@timeit_debug to "rewrite" begin
84+
@tracepoint "rewrite" begin
8585
if job.config.kernel && needs_byval(job)
8686
# pass all bitstypes by value; by default Julia passes aggregates by reference
8787
# (this improves performance, and is mandated by certain back-ends like SPIR-V).
@@ -136,7 +136,7 @@ end
136136
function lower_throw!(mod::LLVM.Module)
137137
job = current_job::CompilerJob
138138
changed = false
139-
@timeit_debug to "lower throw" begin
139+
@tracepoint "lower throw" begin
140140

141141
throw_functions = [
142142
# unsupported runtime functions that are used to throw specific exceptions
@@ -370,7 +370,7 @@ end
370370
# https://reviews.llvm.org/D79744
371371
function lower_byval(@nospecialize(job::CompilerJob), mod::LLVM.Module, f::LLVM.Function)
372372
ft = function_type(f)
373-
@timeit_debug to "lower byval" begin
373+
@tracepoint "lower byval" begin
374374

375375
# classify the arguments
376376
args = classify_arguments(job, ft)

src/ptx.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ function nvvm_reflect!(fun::LLVM.Function)
387387
job = current_job::CompilerJob
388388
mod = LLVM.parent(fun)
389389
changed = false
390-
@timeit_debug to "nvvmreflect" begin
390+
@tracepoint "nvvmreflect" begin
391391

392392
# find and sanity check the nnvm-reflect function
393393
# TODO: also handle the llvm.nvvm.reflect intrinsic

src/spirv.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ end
212212
function rm_trap!(mod::LLVM.Module)
213213
job = current_job::CompilerJob
214214
changed = false
215-
@timeit_debug to "remove trap" begin
215+
@tracepoint "remove trap" begin
216216

217217
if haskey(functions(mod), "llvm.trap")
218218
trap = functions(mod)["llvm.trap"]
@@ -238,7 +238,7 @@ end
238238
function rm_freeze!(mod::LLVM.Module)
239239
job = current_job::CompilerJob
240240
changed = false
241-
@timeit_debug to "remove freeze" begin
241+
@tracepoint "remove freeze" begin
242242

243243
for f in functions(mod), bb in blocks(f), inst in instructions(bb)
244244
if inst isa LLVM.FreezeInst

src/utils.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ defs(mod::LLVM.Module) = filter(f -> !isdeclaration(f), collect(functions(mod))
22
decls(mod::LLVM.Module) = filter(f -> isdeclaration(f) && !LLVM.isintrinsic(f),
33
collect(functions(mod)))
44

5-
## timings
6-
7-
const to = TimerOutput()
8-
9-
timings() = (TimerOutputs.print_timer(to); println())
10-
11-
enable_timings() = (TimerOutputs.enable_debug_timings(GPUCompiler); return)
12-
13-
145
## debug verification
156

167
should_verify() = ccall(:jl_is_debugbuild, Cint, ()) == 1 ||

0 commit comments

Comments
 (0)