diff --git a/SingeliClone b/SingeliClone index 4255440a..4a4cee08 160000 --- a/SingeliClone +++ b/SingeliClone @@ -1 +1 @@ -Subproject commit 4255440afd05c77a0efebdb6d5bd21e0b8a93aa9 +Subproject commit 4a4cee084d0e0f13593ed1feb678aa85bde02002 diff --git a/src/singeli/src/avx.singeli b/src/singeli/src/avx.singeli index 9537dab6..307d959d 100644 --- a/src/singeli/src/avx.singeli +++ b/src/singeli/src/avx.singeli @@ -1,9 +1,7 @@ -# various utilities - def w256{T} = 0 def w256{T & isvec{T}} = width{T}==256 -def wgen256{F} = { +local def wgen256{F} = { def r{T} = 0 def r{T & w256{T}} = F{eltype{T}} def r{T,w} = 0 @@ -50,7 +48,7 @@ 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} -def makeGen{T,s,x} = apply{emit, merge{tup{T,s}, each{{c}=>promote{eltype{T},c}, 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}} @@ -69,8 +67,8 @@ def __or {a:T, b:T & w256i{T}} = T ~~ emit{[8]f32, '_mm256_or_ps', v2f{a}, v2f{ def __not{a:T & w256u{T}} = a ^ broadcast{T, ~cast{eltype{T},0}} # float comparison -def f32cmpAVX{a,b,n} = [8]u32 ~~ emit{[8]f32, '_mm256_cmp_ps', a, b, n} -def f64cmpAVX{a,b,n} = [4]u64 ~~ emit{[4]f64, '_mm256_cmp_pd', a, b, n} +local def f32cmpAVX{a,b,n} = [8]u32 ~~ emit{[8]f32, '_mm256_cmp_ps', a, b, n} +local def f64cmpAVX{a,b,n} = [4]u64 ~~ emit{[4]f64, '_mm256_cmp_pd', a, b, n} def __eq{a:T,b:T & T==[8]f32} = f32cmpAVX{a,b, 0}; def __eq{a:T,b:T & T==[4]f64} = f64cmpAVX{a,b, 0} def __ne{a:T,b:T & T==[8]f32} = f32cmpAVX{a,b, 4}; def __ne{a:T,b:T & T==[4]f64} = f64cmpAVX{a,b, 4} def __gt{a:T,b:T & T==[8]f32} = f32cmpAVX{a,b,30}; def __gt{a:T,b:T & T==[4]f64} = f64cmpAVX{a,b,30} diff --git a/src/singeli/src/base.singeli b/src/singeli/src/base.singeli index 0a44f9be..d07a3b46 100644 --- a/src/singeli/src/base.singeli +++ b/src/singeli/src/base.singeli @@ -1,7 +1,7 @@ include 'skin/c' include 'arch/c' -oper infix right ~~ reinterpret 55 +oper ~~ reinterpret infix right 55 def Size = u64 def load{x} = *x @@ -107,9 +107,9 @@ def maxvalue{T & T==u16} = 0xffff def maxvalue{T & T==u32} = 0xffffffff # tuple operations -def broadcast{T, v & match{typekind{T},'primitive'}} = v -def any{v:T & match{typekind{T},'primitive'}} = v -def anyneg{v:T & match{typekind{T},'primitive'}} = v<0 +def broadcast{T, v & isprim{T}} = v +def any{v:T & isprim{T}} = v +def anyneg{v:T & isprim{T}} = v<0 def iota{n & knum{n}} = @collect(i to n) i def broadcast{n, v & knum{n}} = @collect(n) v diff --git a/src/singeli/src/dyarith.singeli b/src/singeli/src/dyarith.singeli index c91b96a9..cb018dcc 100644 --- a/src/singeli/src/dyarith.singeli +++ b/src/singeli/src/dyarith.singeli @@ -8,15 +8,15 @@ include './bitops' include './mask' -def rootty{T & match{typekind{T},'primitive'}} = T -def rootty{T & match{typekind{T},'vector'}} = eltype{T} +def rootty{T & isprim{T}} = T +def rootty{T & isvec{T}} = eltype{T} # old scalar code # def ty_dbl{T & isprim{T}} = apply{tern{issigned{T}, ty_s, ty_u}, tup{width{T}*2}} # def ty_dbl{T & isvec{T}} = [vcount{T}/2](ty_dbl{eltype{T}}) # def dcast_i{x:T} = promote{ty_dbl{T}, x} -# def arithChk2{F, M, w:T, x:T, i & match{F,__mul} & match{typekind{T},'primitive'}} = { +# def arithChk2{F, M, w:T, x:T, i & match{F,__mul} & isprim{T}} = { # r:= F{dcast_i{w}, dcast_i{x}} # tup{r, r!=promote{type{r}, trunc{T, r}}} # } diff --git a/src/singeli/src/mask.singeli b/src/singeli/src/mask.singeli index cd3cdb09..ae769c9e 100644 --- a/src/singeli/src/mask.singeli +++ b/src/singeli/src/mask.singeli @@ -1,10 +1,10 @@ # get mask of first n items; n>0 & n { merge{broadcast{w/8-1, 255}, (1<{if(c>0) merge{',',s}; else s}, iota{n}}}, '"'}}, each{{c}=>extract{x,c}, iota{n}}}} +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}}}} def print{x:T & isvec{T}} = printGen{x, printfType{eltype{T}}, vcount{T}}