diff --git a/Project.toml b/Project.toml index 5eef15fcf..5bd606365 100644 --- a/Project.toml +++ b/Project.toml @@ -22,12 +22,15 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" pocl_standalone_jll = "54f56a70-6062-5590-a942-1226658f6c83" [weakdeps] +EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [extensions] LinearAlgebraExt = "LinearAlgebra" SparseArraysExt = "SparseArrays" +StaticArraysExt = "StaticArrays" [compat] Adapt = "0.4, 1.0, 2.0, 3.0, 4" @@ -47,6 +50,7 @@ SPIRVIntrinsics = "1" SPIRV_LLVM_Backend_jll = "22" SPIRV_Tools_jll = "2024.4, 2025.1" SparseArrays = "<0.0.1, 1.6" +StaticArrays = "0.12, 1.0" UUIDs = "<0.0.1, 1.6" julia = "1.10" pocl_standalone_jll = "7.2" 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/test/test.jl b/test/test.jl index 444ffe401..92b36d1b5 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 @@ -104,6 +105,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)