Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/host/construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@ function Base.fill!(A::AnyGPUArray{T}, x) where T

@kernel function fill_kernel!(a, val)
idx = @index(Global, Linear)
@inbounds a[idx] = val
stride = prod(@ndrange())
while idx <= length(a)
@inbounds a[idx] = val
idx += stride
end
end

# ndims check for 0D support
kernel = fill_kernel!(get_backend(A))
kernel(A, x; ndrange = length(A))

# Calculate ndrange to ensure that a total grid size >typemax(UInt32) is never
# chosen. Grid stride to accomodate grid size limitations on AMD and Metal backends
len = length(A)
ndrange = cld(len, cld(len, typemax(UInt32) - 1024))

kernel(A, x; ndrange)
A
end

Expand Down
Loading