@@ -533,8 +533,17 @@ allocates an array using unified memory if the backend supports it. Use
533533!!! note
534534 Backend implementations **must** implement `allocate(::NewBackend, T, dims::Tuple)`
535535"""
536- allocate (backend:: Backend , T:: Type , dims... ; unified = false ) = allocate (backend, T, dims; unified)
537- allocate (backend:: Backend , T:: Type , dims:: Tuple ; unified = false ) = throw (MethodError (allocate, (backend, T, dims)))
536+ allocate (backend:: Backend , T:: Type , dims... ; kwargs... ) = allocate (backend, T, dims; kwargs... )
537+ function allocate (backend:: Backend , T:: Type , dims:: Tuple ; unified:: Union{Nothing, Bool} = nothing )
538+ if isnothing (unified)
539+ throw (MethodError (allocate, (backend, T, dims)))
540+ elseif unified
541+ throw (ArgumentError (" `$(typeof (backend)) ` either does not support unified memory or it has not yet defined `allocate(backend::$backend , T::Type, dims::Tuple; unified::Bool)`" ))
542+ else
543+ allocate (backend, T, dims)
544+ end
545+ end
546+
538547
539548"""
540549 zeros(::Backend, Type, dims...; unified=false)::AbstractArray
@@ -543,8 +552,8 @@ Allocate a storage array appropriate for the computational backend filled with z
543552`unified` allocates an array using unified memory if the backend supports it.
544553"""
545554zeros (backend:: Backend , T:: Type , dims... ; kwargs... ) = zeros (backend, T, dims; kwargs... )
546- function zeros (backend:: Backend , :: Type{T} , dims:: Tuple ; unified = false ) where {T}
547- data = allocate (backend, T, dims... ; unified )
555+ function zeros (backend:: Backend , :: Type{T} , dims:: Tuple ; kwargs ... ) where {T}
556+ data = allocate (backend, T, dims... ; kwargs ... )
548557 fill! (data, zero (T))
549558 return data
550559end
@@ -556,8 +565,8 @@ Allocate a storage array appropriate for the computational backend filled with o
556565`unified` allocates an array using unified memory if the backend supports it.
557566"""
558567ones (backend:: Backend , T:: Type , dims... ; kwargs... ) = ones (backend, T, dims; kwargs... )
559- function ones (backend:: Backend , :: Type{T} , dims:: Tuple ; unified = false ) where {T}
560- data = allocate (backend, T, dims; unified )
568+ function ones (backend:: Backend , :: Type{T} , dims:: Tuple ; kwargs ... ) where {T}
569+ data = allocate (backend, T, dims; kwargs ... )
561570 fill! (data, one (T))
562571 return data
563572end
@@ -569,9 +578,9 @@ Returns whether unified memory arrays are supported by the backend.
569578
570579!!! note
571580 Backend implementations **must** implement this function
572- only if they **do not ** support unified memory.
581+ only if they **do** support unified memory.
573582"""
574- supports_unified (:: Backend ) = true
583+ supports_unified (:: Backend ) = false
575584
576585"""
577586 supports_atomics(::Backend)::Bool
0 commit comments