Closed DilumAluthge closed 3 years ago
Needs GC.@preserve
on the L2Buffer
.
For example, inside matmul!.
I'd also test for exact equality. Something like
@time Test.@testset "PointerMatrix" begin
mem = Octavian.L2Buffer(Float64);
ptr = Base.unsafe_convert(Ptr{Float64}, mem)
block = Octavian.PointerMatrix(ptr, (10, 20))
Test.@test Base.unsafe_convert(Ptr{Float64}, block) == pointer(block.p)
GC.@preserve mem begin
block[1] = 2.3
Test.@test block[1] == 2.3
block[4, 5] = 67.89
Test.@test block[4, 5] == 67.89
end
end
The point of this is that while PointerMatrix
es do get passed to non-inlined functions, mem
never does in matmul!
.
Therefore, mem
gets stack allocated.
But we need the GC.@preserve
to protect it for as long as we're using it.
Perfect!
Combination of
@time
and@testset
breaksgetindex
forPointerMatrix
.(This is on Julia master.)