Skip to content

Commit

Permalink
enable more tshift tests and fix toDoubleImpl for simdArray
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Dec 7, 2023
1 parent b6e7d37 commit 951ef2b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/simd.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ template msa(T: untyped, N: static[int], F: typedesc) {.dirty,used.} =
#makeSimdArray(N, F, `T Obj`)
#template `T Array` = discard
#makeSimdArray(`T Obj`, N, F)
type `T Obj` = SimdArrayObj[N,F]
type `T Obj`* = SimdArrayObj[N,F]
type T* = Simd[`T Obj`]
type `T Array`* = `T Obj`
#static: echo "made type", $T
Expand Down Expand Up @@ -332,7 +332,7 @@ template assignX*(x: var Simd, y: Simd2) =
assign(x[], y[])

macro simdObjType*(N: static int, T: typedesc): auto =
echo T.repr
#echo T.repr
let p = if T.repr == "float32": "S" else: "D"
result = ident("Simd" & p & $N & "Obj")
#echo result
Expand Down
3 changes: 2 additions & 1 deletion src/simd/simdArray.nim
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ template toDoubleImpl*[N:static int,T](x: SimdArrayObj[N,T]): auto =
else:
type D = simdObjType(N, toDouble(T))
var r {.noInit.}: D
assign(r, x)
assign(r, x[])
r

template `[]`*(x: SimdArrayObj): auto = x.v
proc `[]`*[N:static int,T](x: SimdArrayObj[N,T], i: SomeInteger):
Expand Down
9 changes: 9 additions & 0 deletions tests/base/tshift.nim
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,29 @@ makeSimdArrayX(SD4, 4, float)
testS4(SD4)
when declared(SimdD4):
testS4(SimdD4)

makeSimdArrayX(SS4, 4, float32)
testS4(SS4)
when declared(SimdS4):
testS4(SimdS4)

makeSimdArrayX(SD8, 8, float)
testS8(SD8)
when declared(SimdD8):
testS8(SimdD8)

makeSimdArrayX(SS8, 8, float32)
testS8(SS8)
when declared(SimdS8):
testS8(SimdS8)

makeSimdArrayX(SD16, 16, float)
testS16(SD16)
when declared(SimdD16):
testS16(SimdD16)

makeSimdArrayX(SS16, 16, float32)
testS16(SS16)
when declared(SimdS16):
testS16(SimdS16)

Expand Down

0 comments on commit 951ef2b

Please sign in to comment.