Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd committed Mar 30, 2024
1 parent b635091 commit 4e7abb1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lib/mps/vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,20 @@ end
desc = MPSVectorDescriptor(len, T2)
vec = @objc [MPSVector alloc]::id{MPSVector}
obj = MPSVector(vec)
offset = UInt(arr.offset * sizeof(T) / sizeof(T2))
offset = arr.offset * sizeof(T)
finalizer(release, obj)
@objc [obj::id{MPSVector} initWithBuffer:arr::id{MTLBuffer}
offset:offset::NSUInteger
descriptor:desc::id{MPSVectorDescriptor}]::id{MPSVector}
return obj
end

resourceSize(vecormat::M) where {M<:Union{MPSVector,MPSMatrix}} =
@objc [vecormat::id{M} resourceSize]::NSUInteger

synchronizeOnCommandBuffer(vecormat::M, cmdBuf::MTLCommandBuffer) where {M<:Union{MPSVector,MPSMatrix}} =
@objc [vecormat::id{M} synchronizeOnCommandBuffer:cmdBuf::id{MTLCommandBuffer}]::Nothing

#
# matrix vector multiplication
#
Expand Down
3 changes: 1 addition & 2 deletions src/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Random.randn!(A::MtlArray) = Random.randn!(gpuarrays_rng(), A)

@inline usempsrandom(::MtlArray, ::Val{true}) = true
@inline function usempsrandom(A::MtlArray{T}, _::Bool=false) where {T}
# return (A.offset == 0 &&
return ((A.offset * sizeof(T) % MTL.BUFFER_ALIGNMENT_FOR_RAND == 0) &&
return (A.offset == 0 &&
(length(A) * sizeof(T) % MTL.BUFFER_ALIGNMENT_FOR_RAND == 0))
end

Expand Down
2 changes: 1 addition & 1 deletion test/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const OOPLACE_TUPLES = [[(Metal.rand, T) for T in RAND_TYPES];

# Test when view offset is multiple of 16 and buffer size multiple of 16
@testset "Off % 16 == 0, buf % 16 == 0" begin
test_view!(A, 17:32; shouldusemps=true)
test_view!(A, 17:32; shouldusemps=false)
end
end
end
Expand Down

0 comments on commit 4e7abb1

Please sign in to comment.