diff --git a/build/singeliSubmodule b/build/singeliSubmodule index d76f2bef..89f8fa33 160000 --- a/build/singeliSubmodule +++ b/build/singeliSubmodule @@ -1 +1 @@ -Subproject commit d76f2befeca169e94feda44edc65c3785412745d +Subproject commit 89f8fa33d1cf2f01e2d7122f43f024b96e569ab7 diff --git a/src/singeli/src/avx.singeli b/src/singeli/src/avx.singeli index 006ce927..65dc15b4 100644 --- a/src/singeli/src/avx.singeli +++ b/src/singeli/src/avx.singeli @@ -45,20 +45,16 @@ def broadcast{T, v & w256i{T, 64}} = emit{T, '_mm256_set1_epi64x',promote{eltype def broadcast{T, v & w256f{T, 64}} = emit{T, '_mm256_set1_pd', v} def broadcast{T, v & w256f{T, 32}} = emit{T, '_mm256_set1_ps', v} -def make{T==[4]f64,a,b,c,d} = emit{T,'_mm256_setr_pd',a,b,c,d} -def make{T==[8]f32,a,b,c,d,e,f,g,h} = emit{T,'_mm256_setr_ps',a,b,c,d,e,f,g,h} +local def makeGen{T,s,x} = emit{T, s, ...each{{c}=>promote{eltype{T},c}, x}} +def make{T, ...xs & w256f{T,64} & tuplen{xs}== 4} = makeGen{T, '_mm256_setr_pd', xs} +def make{T, ...xs & w256f{T,32} & tuplen{xs}== 8} = makeGen{T, '_mm256_setr_ps', xs} +def make{T, ...xs & w256i{T,64} & tuplen{xs}== 4} = makeGen{T, '_mm256_setr_epi64x', xs} +def make{T, ...xs & w256i{T,32} & tuplen{xs}== 8} = makeGen{T, '_mm256_setr_epi32', xs} +def make{T, ...xs & w256i{T,16} & tuplen{xs}==16} = makeGen{T, '_mm256_setr_epi16', xs} +def make{T, ...xs & w256i{T, 8} & tuplen{xs}==32} = makeGen{T, '_mm256_setr_epi8', xs} +def make{T, x & w256{T} & istup{x}} = make{T, ...x} -local def makeGen{T,s,x} = apply{emit, merge{tup{T,s}, each{{c}=>promote{eltype{T},c}, x}}} -def make{T,a,b,c,d & w256i{T,64}} = makeGen{T, '_mm256_setr_epi64x', tup{a,b,c,d}} -def make{T,a,b,c,d,e,f,g,h & w256i{T,32}} = makeGen{T, '_mm256_setr_epi32', tup{a,b,c,d,e,f,g,h}} -def make{T,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p & w256i{T,16}} = makeGen{T, '_mm256_setr_epi16', tup{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}} -def make{T,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P & w256i{T,8}} = makeGen{T, '_mm256_setr_epi8', tup{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P}} -def make{T,x & w256{T} & istup{x}} = apply{make, merge{tup{T}, x}} - -def iota{T & w256{T,64}} = make{T,0,1,2,3} -def iota{T & w256{T,32}} = make{T,0,1,2,3,4,5,6,7} -def iota{T & w256{T,16}} = make{T,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} -def iota{T & w256{T,8}} = make{T,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31} +def iota{T & w256{T}} = make{T, ...iota{vcount{T}}} # bit arith def __xor{a:T, b:T & w256{T}} = T ~~ emit{[8]f32, '_mm256_xor_ps', v2f{a}, v2f{b}} diff --git a/src/singeli/src/sse3.singeli b/src/singeli/src/sse3.singeli index 8455071c..541fb196 100644 --- a/src/singeli/src/sse3.singeli +++ b/src/singeli/src/sse3.singeli @@ -43,20 +43,16 @@ def broadcast{T, v & w128i{T, 64}} = emit{T, '_mm_set1_epi64x',promote{eltype{T} def broadcast{T, v & w128f{T, 64}} = emit{T, '_mm_set1_pd', v} def broadcast{T, v & w128f{T, 32}} = emit{T, '_mm_set1_ps', v} -def make{T==[2]f64,a,b} = emit{T,'_mm_setr_pd',a,b} -def make{T==[4]f32,a,b,c,d} = emit{T,'_mm_setr_ps',a,b,c,d} +local def makeGen{T,s,x} = emit{T, s, ...each{{c}=>promote{eltype{T},c}, x}} +def make{T, ...xs & w128f{T,64} & tuplen{xs}== 2} = makeGen{T, '_mm_setr_pd', xs} +def make{T, ...xs & w128f{T,32} & tuplen{xs}== 4} = makeGen{T, '_mm_setr_ps', xs} +def make{T, ...xs & w128i{T,64} & tuplen{xs}== 2} = makeGen{T, '_mm_setr_epi64x', xs} +def make{T, ...xs & w128i{T,32} & tuplen{xs}== 4} = makeGen{T, '_mm_setr_epi32', xs} +def make{T, ...xs & w128i{T,16} & tuplen{xs}== 8} = makeGen{T, '_mm_setr_epi16', xs} +def make{T, ...xs & w128i{T, 8} & tuplen{xs}==16} = makeGen{T, '_mm_setr_epi8', xs} +def make{T, x & w128{T} & istup{x}} = make{T, ...x} -def makeGen{T,s,x} = apply{emit, merge{tup{T,s}, each{{c}=>promote{eltype{T},c}, x}}} -def make{T,a,b & w128i{T,64}} = makeGen{T, '_mm_set_epi64x', tup{b,a}} # yay no _mm_setr_epi64x -def make{T,a,b,c,d & w128i{T,32}} = makeGen{T, '_mm_setr_epi32', tup{a,b,c,d}} -def make{T,a,b,c,d,e,f,g,h & w128i{T,16}} = makeGen{T, '_mm_setr_epi16', tup{a,b,c,d,e,f,g,h}} -def make{T,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p & w128i{T,8}} = makeGen{T, '_mm_setr_epi8', tup{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}} -def make{T,x & w128{T} & istup{x}} = apply{make, merge{tup{T}, x}} - -def iota{T & w128{T,64}} = make{T,0,1} -def iota{T & w128{T,32}} = make{T,0,1,2,3} -def iota{T & w128{T,16}} = make{T,0,1,2,3,4,5,6,7} -def iota{T & w128{T,8}} = make{T,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} +def iota{T & w128{T}} = make{T, ...iota{vcount{T}}} # bit arith def __xor{a:T, b:T & w128{T}} = T ~~ emit{[4]f32, '_mm_xor_ps', v2f{a}, v2f{b}} @@ -136,7 +132,7 @@ def anyneg{x:T & w128s{T, 16}} = getmask{[32]u8 ~~ (([16]i16~~x) < broadcast{[16 def extract{x:T, i & w128i{T,16} & knum{i}} = emit{eltype{T}, '_mm_extract_epi16', x, i} # debug stuff -local def printGen{x, s, n} = apply{emit, merge{tup{void, 'printf', merge{'"', apply{merge,each{{c}=>{if(c>0) merge{',',s}; else s}, iota{n}}}, '"'}}, each{{c}=>extract{x,c}, iota{n}}}} +local def printGen{x, s, n} = emit{void, 'printf', merge{'"', apply{merge,each{{c}=>{if(c>0) merge{',',s}; else s}, iota{n}}}, '"'}, ...each{{c}=>extract{x,c}, iota{n}}} def print{x:T & isvec{T}} = printGen{x, printfType{eltype{T}}, vcount{T}}