Skip to content
Merged
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 src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ function Base.resize!(a::oneVector{T}, n::Integer) where {T}
unsafe_copyto!(ctx, dev, ptr, pointer(a), m)
end
new_data = DataRef(buf) do buf
free(buf)
release(buf)
end
unsafe_free!(a)

Expand Down
16 changes: 16 additions & 0 deletions test/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,22 @@ end
@test length(b) == 0
resize!(b, 1)
@test length(b) == 1

# resized buffers are released through the pool, like freshly allocated ones
c = oneArray{Float32}(undef, 4)
resize!(c, 0)
oneAPI.unsafe_free!(c)

GC.enable(false)
try
d = oneArray{Float32}(undef, 1024)
before = oneAPI._allocated_bytes[]
resize!(d, 1 << 20)
oneAPI.unsafe_free!(d)
@test oneAPI._allocated_bytes[] == before - sizeof(Float32) * 1024
finally
GC.enable(true)
end
end

# Reductions and scans come from GPUArrays (AcceleratedKernels). oneAPI used to work around
Expand Down
Loading