|
10 | 10 | :(@cfunction($c, Cvoid, (Ptr{UInt},))) |
11 | 11 | end |
12 | 12 |
|
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) |
16 | 16 | fptr = mul_staticarray_ptr(py, px) |
17 | 17 | offset = ThreadingUtilities.store!(p, fptr, sizeof(UInt)) |
18 | 18 | ThreadingUtilities.store!(p, (py,px), offset) |
|
24 | 24 | end |
25 | 25 | end |
26 | 26 |
|
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} |
28 | 28 | ra = Ref(a) |
29 | 29 | rb = Ref(b) |
30 | 30 | 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}() |
34 | 34 | GC.@preserve ra rb rc rx ry rz begin |
35 | 35 | launch_thread_mul_svector(1, rx, ra) |
36 | 36 | launch_thread_mul_svector(2, ry, rb) |
|
53 | 53 | @test x == b*2.7 |
54 | 54 | @test y == c*2.7 |
55 | 55 | @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); |
57 | 59 |
|
| 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