Skip to content

Commit 9504488

Browse files
authored
Merge branch 'main' into vc/validate
2 parents 083a0c4 + 8d44613 commit 9504488

File tree

9 files changed

+93
-262
lines changed

9 files changed

+93
-262
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
version: ['1.10', '1.11']
25-
os: [ubuntu-24.04, ubuntu-24.04-arm, macOS-13, macOS-15, windows-2025]
25+
os: [ubuntu-24.04, ubuntu-24.04-arm, macOS-15, macOS-15-intel, windows-2025]
2626
arch: [x64, arm64]
2727
pocl: [jll, local]
2828
exclude:
@@ -35,14 +35,14 @@ jobs:
3535
# macOS 13 is Intel-only, while macOS 14+ only support Apple Silicon
3636
- os: macOS-15
3737
arch: x64
38-
- os: macOS-13
38+
- os: macOS-15-intel
3939
arch: arm64
40-
- os: macOS-13
40+
- os: macOS-15-intel
4141
pocl: local
4242
- os: macOS-15
4343
pocl: local
4444
- os: windows-2025
45-
pocl: local
45+
pocl: local
4646
steps:
4747
- uses: actions/checkout@v4
4848
- uses: julia-actions/install-juliaup@v2
@@ -83,14 +83,13 @@ jobs:
8383
julia --project=pocl --color=yes -e '
8484
using LLVM_full_jll,
8585
SPIRV_Tools_jll, SPIRV_LLVM_Translator_jll,
86-
OpenCL_jll, OpenCL_Headers_jll,
87-
Hwloc_jll, CMake_jll
86+
OpenCL_jll, OpenCL_Headers_jll, CMake_jll
8887
sourcedir = joinpath(@__DIR__, "pocl")
8988
builddir = joinpath(@__DIR__, "build")
9089
destdir = joinpath(@__DIR__, "target")
9190
prefix = []
92-
for jll in [SPIRV_Tools_jll, SPIRV_LLVM_Translator_jll, OpenCL_jll,
93-
OpenCL_Headers_jll, Hwloc_jll]
91+
for jll in [SPIRV_Tools_jll, SPIRV_LLVM_Translator_jll,
92+
OpenCL_jll, OpenCL_Headers_jll]
9493
push!(prefix, jll.artifact_dir)
9594
end
9695
withenv("LD_LIBRARY_PATH" => joinpath(Sys.BINDIR, Base.PRIVATE_LIBDIR)) do

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ LLVM = "9.4.1"
4040
LinearAlgebra = "1.6"
4141
MacroTools = "0.5"
4242
PrecompileTools = "1"
43-
SPIRVIntrinsics = "0.4"
43+
SPIRVIntrinsics = "0.5"
4444
SPIRV_LLVM_Backend_jll = "20"
4545
SPIRV_Tools_jll = "2024.4, 2025.1"
4646
SparseArrays = "<0.0.1, 1.6"

docs/src/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ allocate
2121

2222
```@docs
2323
KernelAbstractions.zeros
24+
KernelAbstractions.supports_unified
2425
```
2526

2627
## Internal

src/KernelAbstractions.jl

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -524,47 +524,74 @@ end
524524
# adapt_storage(::Backend, a::BackendArray) = a
525525

526526
"""
527-
allocate(::Backend, Type, dims...)::AbstractArray
527+
allocate(::Backend, Type, dims...; unified=false)::AbstractArray
528528
529-
Allocate a storage array appropriate for the computational backend.
529+
Allocate a storage array appropriate for the computational backend. `unified=true`
530+
allocates an array using unified memory if the backend supports it and throws otherwise.
531+
Use [`supports_unified`](@ref) to determine whether it is supported by a backend.
530532
531533
!!! note
532534
Backend implementations **must** implement `allocate(::NewBackend, T, dims::Tuple)`
533-
"""
534-
allocate(backend::Backend, T::Type, dims...) = allocate(backend, T, dims)
535-
allocate(backend::Backend, T::Type, dims::Tuple) = throw(MethodError(allocate, (backend, T, dims)))
535+
Backend implementations **should** implement `allocate(::NewBackend, T, dims::Tuple; unified::Bool=false)`
536+
"""
537+
allocate(backend::Backend, T::Type, dims...; kwargs...) = allocate(backend, T, dims; kwargs...)
538+
function allocate(backend::Backend, T::Type, dims::Tuple; unified::Union{Nothing, Bool} = nothing)
539+
if isnothing(unified)
540+
throw(MethodError(allocate, (backend, T, dims)))
541+
elseif unified
542+
throw(ArgumentError("`$(typeof(backend))` does not support unified memory. If you believe it does, please open a github issue."))
543+
else
544+
return allocate(backend, T, dims)
545+
end
546+
end
547+
536548

537549
"""
538-
zeros(::Backend, Type, dims...)::AbstractArray
550+
zeros(::Backend, Type, dims...; unified=false)::AbstractArray
539551
540552
Allocate a storage array appropriate for the computational backend filled with zeros.
553+
`unified=true` allocates an array using unified memory if the backend supports it and
554+
throws otherwise.
541555
"""
542-
zeros(backend::Backend, T::Type, dims...) = zeros(backend, T, dims)
543-
function zeros(backend::Backend, ::Type{T}, dims::Tuple) where {T}
544-
data = allocate(backend, T, dims...)
556+
zeros(backend::Backend, T::Type, dims...; kwargs...) = zeros(backend, T, dims; kwargs...)
557+
function zeros(backend::Backend, ::Type{T}, dims::Tuple; kwargs...) where {T}
558+
data = allocate(backend, T, dims...; kwargs...)
545559
fill!(data, zero(T))
546560
return data
547561
end
548562

549563
"""
550-
ones(::Backend, Type, dims...)::AbstractArray
564+
ones(::Backend, Type, dims...; unified=false)::AbstractArray
551565
552566
Allocate a storage array appropriate for the computational backend filled with ones.
567+
`unified=true` allocates an array using unified memory if the backend supports it and
568+
throws otherwise.
553569
"""
554-
ones(backend::Backend, T::Type, dims...) = ones(backend, T, dims)
555-
function ones(backend::Backend, ::Type{T}, dims::Tuple) where {T}
556-
data = allocate(backend, T, dims)
570+
ones(backend::Backend, T::Type, dims...; kwargs...) = ones(backend, T, dims; kwargs...)
571+
function ones(backend::Backend, ::Type{T}, dims::Tuple; kwargs...) where {T}
572+
data = allocate(backend, T, dims; kwargs...)
557573
fill!(data, one(T))
558574
return data
559575
end
560576

577+
"""
578+
supports_unified(::Backend)::Bool
579+
580+
Returns whether unified memory arrays are supported by the backend.
581+
582+
!!! note
583+
Backend implementations **should** implement this function
584+
only if they **do** support unified memory.
585+
"""
586+
supports_unified(::Backend) = false
587+
561588
"""
562589
supports_atomics(::Backend)::Bool
563590
564591
Returns whether `@atomic` operations are supported by the backend.
565592
566593
!!! note
567-
Backend implementations **must** implement this function,
594+
Backend implementations **must** implement this function
568595
only if they **do not** support atomic operations with Atomix.
569596
"""
570597
supports_atomics(::Backend) = true
@@ -575,7 +602,7 @@ supports_atomics(::Backend) = true
575602
Returns whether `Float64` values are supported by the backend.
576603
577604
!!! note
578-
Backend implementations **must** implement this function,
605+
Backend implementations **must** implement this function
579606
only if they **do not** support `Float64`.
580607
"""
581608
supports_float64(::Backend) = true

src/cpu.jl

Lines changed: 0 additions & 224 deletions
This file was deleted.

0 commit comments

Comments
 (0)