diff --git a/Project.toml b/Project.toml index 6fa8a12f6..c3f52ea9b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "KernelAbstractions" uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c" authors = ["Valentin Churavy and contributors"] -version = "0.9.35" +version = "0.9.36" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/ext/StaticArraysExt.jl b/ext/StaticArraysExt.jl new file mode 100644 index 000000000..8cdcdd308 --- /dev/null +++ b/ext/StaticArraysExt.jl @@ -0,0 +1,9 @@ +module StaticArraysExt + +import KernelAbstractions: get_backend, CPU +using StaticArrays: SizedArray, MArray + +get_backend(A::SizedArray) = get_backend(A.data) +get_backend(::MArray) = CPU() + +end diff --git a/src/KernelAbstractions.jl b/src/KernelAbstractions.jl index 73298ca53..f6982c610 100644 --- a/src/KernelAbstractions.jl +++ b/src/KernelAbstractions.jl @@ -865,4 +865,7 @@ if !isdefined(Base, :get_extension) include("../ext/SparseArraysExt.jl") end +# Currently we have a direct dependency on StaticArrays +include("../ext/StaticArraysExt.jl") + end #module diff --git a/test/runtests.jl b/test/runtests.jl index f992afad2..bf9b445a5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,7 +72,6 @@ struct NewBackend <: KernelAbstractions.GPU end @test_throws MethodError kernel() end - include("extensions/enzyme.jl") @static if VERSION >= v"1.7.0" @testset "Enzyme" begin diff --git a/test/test.jl b/test/test.jl index 3528a2cc9..4a4f667ab 100644 --- a/test/test.jl +++ b/test/test.jl @@ -4,6 +4,7 @@ using InteractiveUtils using LinearAlgebra using SparseArrays using Adapt +using StaticArrays identity(x) = x @@ -95,6 +96,18 @@ function unittest_testsuite(Backend, backend_str, backend_mod, BackendArrayT; sk @test @inferred(KernelAbstractions.get_backend(sparse(A))) isa backendT end + @conditional_testset "StaticArrays" skip_tests begin + backend = Backend() + backendT = typeof(backend).name.wrapper # To look through CUDABackend{true, false} + @test backend isa backendT + + @test KernelAbstractions.get_backend(@MMatrix [1.0]) isa CPU + @test_throws ArgumentError KernelAbstractions.get_backend(@SMatrix [1.0]) + + A = allocate(backend, Float32, 5, 5) + @test @inferred(KernelAbstractions.get_backend(SizedMatrix{5, 5}(A))) isa backendT + end + @conditional_testset "adapt" skip_tests begin backend = Backend() x = allocate(backend, Float32, 5)