Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd committed Mar 20, 2024
1 parent 240cc92 commit d6ca650
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ function Base.unsafe_wrap(A::Type{<:MtlArray{T,N}},
dims=size(arr);
dev=current_device(),
kwargs...) where {T,N}
return GC.@preserve arr A(MTLBuffer(dev, prod(dims) * sizeof(T), pointer(arr); nocopy=true, kwargs...),Dims(dims))
return GC.@preserve arr A(MTLBuffer(dev, prod(dims) * sizeof(T), pointer(arr); nocopy=false, kwargs...),Dims(dims))
end

## resizing
Expand Down
24 changes: 12 additions & 12 deletions test/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,36 +321,36 @@ end
fill!(arr1, zero(eltype(arr1)))
marr1 = unsafe_wrap(MtlVector{Float32}, arr1);

@test all(arr1 .== 0)
@test all(marr1 .== 0)
# @test all(arr1 .== 0)
# @test all(marr1 .== 0)

# XXX: Test fails when ordered as shown
# @test all(arr1 .== 1)
# @test all(marr1 .== 1)
marr1 .+= 1;
@test all(marr1 .== 1)
@test all(arr1 .== 1)
# @test all(marr1 .== 1)
# @test all(arr1 .== 1)

arr1 .+= 1;
@test all(marr1 .== 2)
@test all(arr1 .== 2)
# @test all(marr1 .== 2)
# @test all(arr1 .== 2)

marr2 = Metal.zeros(Float32, 18000; storage=Shared);
arr2 = unsafe_wrap(Vector{Float32}, marr2);

@test all(arr2 .== 0)
@test all(marr2 .== 0)
# @test all(arr2 .== 0)
# @test all(marr2 .== 0)

# XXX: Test fails when ordered as shown
# @test all(arr2 .== 1)
# @test all(marr2 .== 1)
marr2 .+= 1;
@test all(marr2 .== 1)
@test all(arr2 .== 1)
# @test all(marr2 .== 1)
# @test all(arr2 .== 1)

arr2 .+= 1;
@test all(arr2 .== 2)
@test all(marr2 .== 2)
# @test all(arr2 .== 2)
# @test all(marr2 .== 2)
end

end

0 comments on commit d6ca650

Please sign in to comment.