Skip to content

Commit

Permalink
Support code emission of PTX and GCN even if disabled (#660)
Browse files Browse the repository at this point in the history
Co-authored-by: Valentin Churavy <[email protected]>
  • Loading branch information
wsmoses and vchuravy authored Feb 5, 2025
1 parent 47a4a8b commit 7b9322f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/gcn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ GCNCompilerTarget(dev_isa; features="") = GCNCompilerTarget(dev_isa, features)
llvm_triple(::GCNCompilerTarget) = "amdgcn-amd-amdhsa"

function llvm_machine(target::GCNCompilerTarget)
@static if :AMDGPU LLVM.backends()
return nothing
end
triple = llvm_triple(target)
t = Target(triple=triple)

Expand Down
1 change: 1 addition & 0 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ source_code(@nospecialize(target::AbstractCompilerTarget)) = "text"

llvm_triple(@nospecialize(target::AbstractCompilerTarget)) = error("Not implemented")

# may return nothing if the target is not support by the current version of LLVM.
function llvm_machine(@nospecialize(target::AbstractCompilerTarget))
triple = llvm_triple(target)

Expand Down
3 changes: 3 additions & 0 deletions src/ptx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ source_code(target::PTXCompilerTarget) = "ptx"
llvm_triple(target::PTXCompilerTarget) = Int===Int64 ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda"

function llvm_machine(target::PTXCompilerTarget)
@static if :NVPTX LLVM.backends()
return nothing
end
triple = llvm_triple(target)
t = Target(triple=triple)

Expand Down
3 changes: 2 additions & 1 deletion test/gcn.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if :AMDGPU in LLVM.backends()
@testset "IR" begin

@testset "kernel calling convention" begin
Expand All @@ -14,7 +15,6 @@ end
end

############################################################################################

@testset "assembly" begin

@testset "skip scalar trap" begin
Expand Down Expand Up @@ -214,3 +214,4 @@ end
end

end
end # :AMDGPU in LLVM.backends()
3 changes: 2 additions & 1 deletion test/ptx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ end
end

############################################################################################

if :NVPTX in LLVM.backends()
@testset "assembly" begin

@testset "child functions" begin
Expand Down Expand Up @@ -343,3 +343,4 @@ end
end

end
end # NVPTX in LLVM.backends()
4 changes: 0 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ end
push!(skip_tests, "metal")
end
end
if Sys.isapple()
# support for AMDGPU and NVTX on macOS has been removed from Julia's LLVM build
append!(skip_tests, ["ptx", "gcn"])
end
if !(SPIRV_LLVM_Translator_unified_jll.is_available() && SPIRV_Tools_jll.is_available())
# SPIRV needs it's tools to be available
push!(skip_tests, "spirv")
Expand Down

0 comments on commit 7b9322f

Please sign in to comment.