Skip to content

Commit 0d2c377

Browse files
committed
Add SMatrix example to staticarray tests
1 parent 80ab9ee commit 0d2c377

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

test/staticarrays.jl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ end
1010
:(@cfunction($c, Cvoid, (Ptr{UInt},)))
1111
end
1212

13-
function setup_mul_svector!(p, y::Base.RefValue{SVector{N,T}}, x::Base.RefValue{SVector{N,T}}) where {N,T}
14-
py = Base.unsafe_convert(Ptr{SVector{N,T}}, y)
15-
px = Base.unsafe_convert(Ptr{SVector{N,T}}, x)
13+
function setup_mul_svector!(p, y::Base.RefValue{T}, x::Base.RefValue{T}) where {T}
14+
py = Base.unsafe_convert(Ptr{T}, y)
15+
px = Base.unsafe_convert(Ptr{T}, x)
1616
fptr = mul_staticarray_ptr(py, px)
1717
offset = ThreadingUtilities.store!(p, fptr, sizeof(UInt))
1818
ThreadingUtilities.store!(p, (py,px), offset)
@@ -24,13 +24,13 @@ end
2424
end
2525
end
2626

27-
function mul_svector_threads(a::SVector{N,T}, b::SVector{N,T}, c::SVector{N,T}) where {N,T}
27+
function mul_svector_threads(a::T, b::T, c::T) where {T}
2828
ra = Ref(a)
2929
rb = Ref(b)
3030
rc = Ref(c)
31-
rx = Ref{SVector{N,T}}()
32-
ry = Ref{SVector{N,T}}()
33-
rz = Ref{SVector{N,T}}()
31+
rx = Ref{T}()
32+
ry = Ref{T}()
33+
rz = Ref{T}()
3434
GC.@preserve ra rb rc rx ry rz begin
3535
launch_thread_mul_svector(1, rx, ra)
3636
launch_thread_mul_svector(2, ry, rb)
@@ -53,5 +53,13 @@ end
5353
@test x == b*2.7
5454
@test y == c*2.7
5555
@test z muladd(2.7, a, b)
56-
end
56+
A = @SMatrix rand(4,5);
57+
B = @SMatrix rand(4,5);
58+
C = @SMatrix rand(4,5);
5759

60+
W,X,Y,Z = mul_svector_threads(A, B, C)
61+
@test W == A*2.7
62+
@test X == B*2.7
63+
@test Y == C*2.7
64+
@test Z muladd(2.7, A, B)
65+
end

0 commit comments

Comments
 (0)