Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
Tracy = "e689c965-62c8-4b79-b2c5-8359227902fd"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Expand All @@ -28,6 +28,6 @@ Preferences = "1"
Scratch = "1"
Serialization = "1"
TOML = "1"
TimerOutputs = "0.5"
Tracy = "0.1.4"
UUIDs = "1"
julia = "1.10"
4 changes: 3 additions & 1 deletion src/GPUCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module GPUCompiler
using LLVM
using LLVM.Interop

using TimerOutputs
using Tracy

using ExprTools: splitdef, combinedef

Expand Down Expand Up @@ -64,6 +64,8 @@ function __init__()
end
mkpath(dir)
global compile_cache = dir

Tracy.@register_tracepoints()
end

end # module
30 changes: 15 additions & 15 deletions src/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function compile_unhooked(output::Symbol, @nospecialize(job::CompilerJob); kwarg
error("No active LLVM context. Use `JuliaContext()` do-block syntax to create one.")
end

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

if output == :llvm
if job.config.strip
@timeit_debug to "strip debug info" strip_debuginfo!(ir)
@tracepoint "strip debug info" strip_debuginfo!(ir)
end

return ir, ir_meta
Expand Down Expand Up @@ -168,7 +168,7 @@ const __llvm_initialized = Ref(false)
__llvm_initialized[] = true
end

@timeit_debug to "IR generation" begin
@tracepoint "IR generation" begin
ir, compiled = irgen(job)
if job.config.entry_abi === :specfunc
entry_fn = compiled[job.source].specfunc
Expand Down Expand Up @@ -267,21 +267,21 @@ const __llvm_initialized = Ref(false)
runtime_intrinsics = ["julia.gc_alloc_obj"]
end

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

# GPU run-time library
if !uses_julia_runtime(job) && any(fn -> fn in runtime_fns ||
fn in runtime_intrinsics,
undefined_fns)
@timeit_debug to "runtime library" link_library!(ir, runtime)
@tracepoint "runtime library" link_library!(ir, runtime)
end
end
end

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

if job.config.toplevel && job.config.optimize
@timeit_debug to "optimization" begin
@tracepoint "optimization" begin
optimize!(job, ir; job.config.opt_level)

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

if job.config.toplevel && job.config.cleanup
@timeit_debug to "clean-up" begin
@tracepoint "clean-up" begin
@dispose pb=NewPMPassBuilder() begin
add!(pb, RecomputeGlobalsAAPass())
add!(pb, GlobalOptPass())
Expand Down Expand Up @@ -379,13 +379,13 @@ const __llvm_initialized = Ref(false)
end

if job.config.toplevel && job.config.validate
@timeit_debug to "Validation" begin
@tracepoint "Validation" begin
check_ir(job, ir)
end
end

if should_verify()
@timeit_debug to "verification" verify(ir)
@tracepoint "verification" verify(ir)
end

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

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

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

return code, ()
Expand Down
2 changes: 1 addition & 1 deletion src/gcn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ end
function lower_throw_extra!(mod::LLVM.Module)
job = current_job::CompilerJob
changed = false
@timeit_debug to "lower throw (extra)" begin
@tracepoint "lower throw (extra)" begin

throw_functions = [
r"julia_bounds_error.*",
Expand Down
10 changes: 5 additions & 5 deletions src/irgen.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# LLVM IR generation

function irgen(@nospecialize(job::CompilerJob))
mod, compiled = @timeit_debug to "emission" compile_method_instance(job)
mod, compiled = @tracepoint "emission" compile_method_instance(job)
if job.config.entry_abi === :specfunc
entry_fn = compiled[job.source].specfunc
else
Expand All @@ -11,7 +11,7 @@ function irgen(@nospecialize(job::CompilerJob))
entry = functions(mod)[entry_fn]

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

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

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

# classify the arguments
args = classify_arguments(job, ft)
Expand Down
2 changes: 1 addition & 1 deletion src/ptx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ function nvvm_reflect!(fun::LLVM.Function)
job = current_job::CompilerJob
mod = LLVM.parent(fun)
changed = false
@timeit_debug to "nvvmreflect" begin
@tracepoint "nvvmreflect" begin

# find and sanity check the nnvm-reflect function
# TODO: also handle the llvm.nvvm.reflect intrinsic
Expand Down
4 changes: 2 additions & 2 deletions src/spirv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ end
function rm_trap!(mod::LLVM.Module)
job = current_job::CompilerJob
changed = false
@timeit_debug to "remove trap" begin
@tracepoint "remove trap" begin

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

for f in functions(mod), bb in blocks(f), inst in instructions(bb)
if inst isa LLVM.FreezeInst
Expand Down
9 changes: 0 additions & 9 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ defs(mod::LLVM.Module) = filter(f -> !isdeclaration(f), collect(functions(mod))
decls(mod::LLVM.Module) = filter(f -> isdeclaration(f) && !LLVM.isintrinsic(f),
collect(functions(mod)))

## timings

const to = TimerOutput()

timings() = (TimerOutputs.print_timer(to); println())

enable_timings() = (TimerOutputs.enable_debug_timings(GPUCompiler); return)


## debug verification

should_verify() = ccall(:jl_is_debugbuild, Cint, ()) == 1 ||
Expand Down
Loading