Skip to content

Commit 7b9322f

Browse files
wsmosesvchuravy
andauthored
Support code emission of PTX and GCN even if disabled (#660)
Co-authored-by: Valentin Churavy <[email protected]>
1 parent 47a4a8b commit 7b9322f

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

src/gcn.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ GCNCompilerTarget(dev_isa; features="") = GCNCompilerTarget(dev_isa, features)
1313
llvm_triple(::GCNCompilerTarget) = "amdgcn-amd-amdhsa"
1414

1515
function llvm_machine(target::GCNCompilerTarget)
16+
@static if :AMDGPU LLVM.backends()
17+
return nothing
18+
end
1619
triple = llvm_triple(target)
1720
t = Target(triple=triple)
1821

src/interface.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ source_code(@nospecialize(target::AbstractCompilerTarget)) = "text"
2323

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

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

src/ptx.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ source_code(target::PTXCompilerTarget) = "ptx"
4545
llvm_triple(target::PTXCompilerTarget) = Int===Int64 ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda"
4646

4747
function llvm_machine(target::PTXCompilerTarget)
48+
@static if :NVPTX LLVM.backends()
49+
return nothing
50+
end
4851
triple = llvm_triple(target)
4952
t = Target(triple=triple)
5053

test/gcn.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
if :AMDGPU in LLVM.backends()
12
@testset "IR" begin
23

34
@testset "kernel calling convention" begin
@@ -14,7 +15,6 @@ end
1415
end
1516

1617
############################################################################################
17-
1818
@testset "assembly" begin
1919

2020
@testset "skip scalar trap" begin
@@ -214,3 +214,4 @@ end
214214
end
215215

216216
end
217+
end # :AMDGPU in LLVM.backends()

test/ptx.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ end
124124
end
125125

126126
############################################################################################
127-
127+
if :NVPTX in LLVM.backends()
128128
@testset "assembly" begin
129129

130130
@testset "child functions" begin
@@ -343,3 +343,4 @@ end
343343
end
344344

345345
end
346+
end # NVPTX in LLVM.backends()

test/runtests.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ end
116116
push!(skip_tests, "metal")
117117
end
118118
end
119-
if Sys.isapple()
120-
# support for AMDGPU and NVTX on macOS has been removed from Julia's LLVM build
121-
append!(skip_tests, ["ptx", "gcn"])
122-
end
123119
if !(SPIRV_LLVM_Translator_unified_jll.is_available() && SPIRV_Tools_jll.is_available())
124120
# SPIRV needs it's tools to be available
125121
push!(skip_tests, "spirv")

0 commit comments

Comments
 (0)