Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "AcceleratedKernels"
uuid = "6a4ca0a5-0e36-4168-a932-d9be78d558f1"
version = "0.5.2"
version = "0.5.3"
authors = ["Andrei-Leonard Nicusan <leonard@evophase.co.uk> and contributors"]

[deps]
Expand Down
2 changes: 1 addition & 1 deletion src/accumulate/accumulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ end

function _check_scan_destination(dst, src)
dst === src && return nothing
Base.mightalias(dst, src) && throw(ArgumentError(
_mightalias(dst, src) && throw(ArgumentError(
"the destination of a scan must be its source or not overlap it"))
axes(dst) == axes(src) || throw(DimensionMismatch(
"the destination of a scan must have the source's axes $(axes(src)), got $(axes(dst))"))
Expand Down
2 changes: 1 addition & 1 deletion src/reduce/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ function _mapreducedim_setup(f::F, op::OP, src, dst, dims_valid, backend, init,
end

function _check_noalias(R, src::AbstractArray)
Base.mightalias(R, src) &&
_mightalias(R, src) &&
throw(ArgumentError("the destination of a reduction must not alias its source"))
nothing
end
Expand Down
4 changes: 4 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const LOCAL_MEMORY_BUDGET = 32 * 1024
# `init=nothing`, which is an explicit initial value.
struct _NoInit end

# `Base.mightalias`, but with empty arrays aliasing nothing, which Julia 1.10's does not know:
# GPU back-ends give all of them the same null data pointer
_mightalias(a, b) = !isempty(a) && !isempty(b) && Base.mightalias(a, b)

"""
struct TypeWrap{T} end
TypeWrap(T) = TypeWrap{T}()
Expand Down
2 changes: 1 addition & 1 deletion src/workspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function _buffers(p::_Plan, ws::Workspace, arrays...)
end

# Whether the buffer `b` may alias the array or `Broadcasted` source `a`
_aliases(b, a::AbstractArray) = Base.mightalias(b, a)
_aliases(b, a::AbstractArray) = _mightalias(b, a)
_aliases(b, a::Base.Broadcast.Broadcasted) = Base.any(x -> _aliases(b, x), a.args)
_aliases(b, a::Base.Broadcast.Extruded) = _aliases(b, a.x)
_aliases(b, a) = false
Expand Down
3 changes: 3 additions & 0 deletions test/generic/accumulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@ end
if Base.mightalias(view(x, 2:100), view(x, 1:99))
@test_throws ArgumentError AK.accumulate!(+, view(x, 2:100), view(x, 1:99); alg=scan_alg())
end
# (empty arrays overlap nothing, even where Julia 1.10's `Base.mightalias` says otherwise)
@test isempty(AK.accumulate!(+, view(x, 1:0), vec(view(reshape(x, 100, :), :, 1:0));
alg=scan_alg()))
@test_throws DimensionMismatch AK.accumulate!(+, array_from_host(zeros(Int32, 5)), x;
alg=scan_alg())
end
Expand Down
2 changes: 2 additions & 0 deletions test/generic/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,8 @@ end
@test_throws DimensionMismatch AK.mapreducedim!(identity, +, array_from_host(zeros(Int32, 3, 1)), A; alg)
@test_throws DimensionMismatch AK.mapreducedim!(identity, +, array_from_host(zeros(Int32, 1, 1, 2)), A; alg)
@test_throws ArgumentError AK.mapreducedim!(identity, +, view(A, 1:1, :), A; alg)
@test size(AK.mapreducedim!(identity, +, view(A, 1:1, 1:0), reshape(view(A, 1:0, :), 2, 0);
alg)) == (1, 0)
bc = Base.Broadcast.preprocess(nothing, Base.Broadcast.instantiate(
Base.Broadcast.broadcasted(identity, A)))
@test_throws ArgumentError AK.mapreducedim!(identity, +, view(A, 1:1, :), bc;
Expand Down
Loading