From e39dd95c2b3492dc3b266eb7677b8b38c3dbe9f1 Mon Sep 17 00:00:00 2001 From: Simeon David Schaub Date: Tue, 12 Aug 2025 13:03:33 +0200 Subject: [PATCH 1/2] add `backend` to `COMPILER_KWARGS` --- src/compiler/execution.jl | 2 +- test/Project.toml | 1 + test/execution.jl | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/compiler/execution.jl b/src/compiler/execution.jl index ad761bea..1b264a71 100644 --- a/src/compiler/execution.jl +++ b/src/compiler/execution.jl @@ -4,7 +4,7 @@ export @opencl, clfunction ## high-level @opencl interface const MACRO_KWARGS = [:launch] -const COMPILER_KWARGS = [:kernel, :name, :always_inline, :extensions] +const COMPILER_KWARGS = [:kernel, :name, :always_inline, :extensions, :backend] const LAUNCH_KWARGS = [:global_size, :local_size, :queue] macro opencl(ex...) diff --git a/test/Project.toml b/test/Project.toml index 1efff760..1125cf4d 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -3,6 +3,7 @@ Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" +GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55" IOCapture = "b5f81e59-6552-4d32-b1f0-c071b021bf89" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" diff --git a/test/execution.jl b/test/execution.jl index db663c04..b0d4eb97 100644 --- a/test/execution.jl +++ b/test/execution.jl @@ -1,3 +1,5 @@ +using GPUCompiler: isavailable, SPIRV_LLVM_Translator_jll + @testset "execution" begin @testset "@opencl" begin @@ -133,4 +135,22 @@ end end end +@testset "backends" begin + llvm_backend_llvm = sprint() do io + OpenCL.code_llvm(io, () -> nothing, (); dump_module = true, backend = :llvm) + end + if Int === Int64 + @test occursin("target triple = \"spirv64-unknown-unknown-unknown\"", llvm_backend_llvm) + end + + if isavailable(SPIRV_LLVM_Translator_jll) + llvm_backend_khronos = sprint() do io + OpenCL.code_llvm(io, () -> nothing, (); dump_module = true, backend = :khronos) + end + if Int === Int64 + @test occursin("target triple = \"spir64-unknown-unknown\"", llvm_backend_khronos) + end + end +end + end From 07fa60eeab7f134e2900337c7f29fcfd8b5d3c04 Mon Sep 17 00:00:00 2001 From: Simeon David Schaub Date: Tue, 2 Sep 2025 15:00:54 +0200 Subject: [PATCH 2/2] make SPIRV_LLVM_Translator_jll test unconditional --- test/Project.toml | 2 +- test/execution.jl | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/test/Project.toml b/test/Project.toml index 1125cf4d..a44cae6b 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -3,7 +3,6 @@ Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" -GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55" IOCapture = "b5f81e59-6552-4d32-b1f0-c071b021bf89" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" @@ -15,6 +14,7 @@ REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SPIRVIntrinsics = "71d1d633-e7e8-4a92-83a1-de8814b09ba8" SPIRV_LLVM_Backend_jll = "4376b9bf-cff8-51b6-bb48-39421dff0d0c" +SPIRV_LLVM_Translator_jll = "4a5d46fc-d8cf-5151-a261-86b458210efb" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" diff --git a/test/execution.jl b/test/execution.jl index b0d4eb97..e15a4349 100644 --- a/test/execution.jl +++ b/test/execution.jl @@ -1,4 +1,4 @@ -using GPUCompiler: isavailable, SPIRV_LLVM_Translator_jll +using SPIRV_LLVM_Translator_jll @testset "execution" begin @@ -143,13 +143,11 @@ end @test occursin("target triple = \"spirv64-unknown-unknown-unknown\"", llvm_backend_llvm) end - if isavailable(SPIRV_LLVM_Translator_jll) - llvm_backend_khronos = sprint() do io - OpenCL.code_llvm(io, () -> nothing, (); dump_module = true, backend = :khronos) - end - if Int === Int64 - @test occursin("target triple = \"spir64-unknown-unknown\"", llvm_backend_khronos) - end + llvm_backend_khronos = sprint() do io + OpenCL.code_llvm(io, () -> nothing, (); dump_module = true, backend = :khronos) + end + if Int === Int64 + @test occursin("target triple = \"spir64-unknown-unknown\"", llvm_backend_khronos) end end