diff --git a/src/gcn.jl b/src/gcn.jl index 7105b2ae..5b8023e7 100644 --- a/src/gcn.jl +++ b/src/gcn.jl @@ -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) diff --git a/src/interface.jl b/src/interface.jl index 1346c858..6de28906 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -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) diff --git a/src/ptx.jl b/src/ptx.jl index a90317dc..4b772f7f 100644 --- a/src/ptx.jl +++ b/src/ptx.jl @@ -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) diff --git a/test/gcn.jl b/test/gcn.jl index c9df660f..c16bc5d4 100644 --- a/test/gcn.jl +++ b/test/gcn.jl @@ -1,3 +1,4 @@ +if :AMDGPU in LLVM.backends() @testset "IR" begin @testset "kernel calling convention" begin @@ -14,7 +15,6 @@ end end ############################################################################################ - @testset "assembly" begin @testset "skip scalar trap" begin @@ -214,3 +214,4 @@ end end end +end # :AMDGPU in LLVM.backends() diff --git a/test/ptx.jl b/test/ptx.jl index 32efc006..5b2cfd8a 100644 --- a/test/ptx.jl +++ b/test/ptx.jl @@ -124,7 +124,7 @@ end end ############################################################################################ - +if :NVPTX in LLVM.backends() @testset "assembly" begin @testset "child functions" begin @@ -343,3 +343,4 @@ end end end +end # NVPTX in LLVM.backends() diff --git a/test/runtests.jl b/test/runtests.jl index f26d9adb..7984750c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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")