Skip to content

Commit dfaebe9

Browse files
committed
small tweaks incl g128x
1 parent a2e9255 commit dfaebe9

File tree

9 files changed

+22
-18
lines changed

9 files changed

+22
-18
lines changed

jsrc/ca.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static DF2(jtupon20atom){F2PREFIP; if(unlikely((AN(a)|AN(w))>1&&JT(jt,deprecct)!
115115

116116
// special lightweight case for u@[ and u@].
117117
static DF1(onright1){F1PREFIP; R (FAV(FAV(self)->fgh[0])->valencefns[0])(jtinplace,w,FAV(self)->fgh[0],FAV(self)->fgh[0]);} // pass straight through. All we do here is set self. Leave inplaceability unchanged
118-
static DF2(onleft2){F2PREFIP; R (FAV(FAV(self)->fgh[0])->valencefns[0])((J)(((I)jtinplace&~(JTINPLACEA+JTINPLACEW))+(((I)jtinplace>>(JTINPLACEAX-JTINPLACEWX))&(JTINPLACEA>>(JTINPLACEAX-JTINPLACEWX)))),a,FAV(self)->fgh[0],FAV(self)->fgh[0]);} // move inplaceable a to w
118+
static DF2(onleft2){F2PREFIP; R (FAV(FAV(self)->fgh[0])->valencefns[0])((J)(((I)jtinplace&~(JTINPLACEA+JTINPLACEW))+(((I)jtinplace>>(JTINPLACEAX-JTINPLACEWX))&(JTINPLACEA>>(JTINPLACEAX-JTINPLACEWX)))),a,FAV(self)->fgh[0],FAV(self)->fgh[0]);} // move inplaceable a to w, pass other JT flags
119119
static DF2(onright2){F2PREFIP; R (FAV(FAV(self)->fgh[0])->valencefns[0])((J)((I)jtinplace&~JTINPLACEA),w,FAV(self)->fgh[0],FAV(self)->fgh[0]);} // keep inplaceable w
120120

121121
// u@n
@@ -319,7 +319,7 @@ F2(jtatco){F2PREFIP;A f,g;AF f1=on1cell,f2=jtupon2cell;C c,d,e;I flag, flag2=0,m
319319
case CQUERY&0x3f: if((d&~1)==CPOUND){f2=jtrollk; flag&=~VJTFLGOK2;} break; // x ?@:# y or x ?@:$ y
320320
case CQRYDOT&0x3f: if((d&~1)==CPOUND){f2=jtrollkx; flag&=~VJTFLGOK2;} break; // x ?.@:# y or x ?.@:$ y
321321
case CICAP&0x3f: if(d==CNE){f1=jtnubind; flag&=~VJTFLGOK1;} else if(FIT0(CNE,wv)){f1=jtnubind0; flag&=~VJTFLGOK1;}else if(d==CEBAR){f2=jtifbebar; flag&=~VJTFLGOK2;} break; // I.@:~: y I.@:(~:!.0) y x I.@:E. y
322-
case CAMP&0x3f: {m=(e&~2)==CIOTA?e:m; I j=-1; j=g==num(0)?0:j; j=g==num(1)?1:j; m|=j; break;} // i.@0/1@:g i:@0/1@:g
322+
case CAMP&0x3f: {m=(e&~2)==CIOTA?e:m; I j=-1; j=g==num(0)?0:j; j=g==num(1)?1:j; m|=j; break;} // i.&0/1@:g i:&0/1@:g note 0/1 must be boolean SDTs
323323
case CSLASH&0x3f: // f/@:g where f is not a gerund
324324
if(FAV(f)->flag&FAV(w)->flag&VISATOMIC2){f2=jtfslashatg;} // f/@:g when f and g are both atomic
325325
if(d==CCOMMA){f1=jtredravel;}
@@ -494,8 +494,10 @@ F2(jtamp){F2PREFIP;A h=0;AF f1,f2;B b;C c;I flag,flag2=0,linktype=0,mode=-1,p,r;
494494
mode=((II0EPS-1+((p&VFCOMPCOMP)>>3))&0xf)+1; // e.-compound&n including e. -. ([ -. -.) or any i.&1@:e. - LESS/INTER not in 32-bit
495495
if(mode==IINTER){cct=FAV(va)->localuse.lu1.cct; b=cct!=0;} // ([-.-.) always has cct, but it might be 0 indicating default
496496
{PUSHCCTIF(FAV(va)->localuse.lu1.cct,b) h=indexofsub(mode,w,mark); cct=jt->cct; POPCCT f1=ixfixedright; flag&=~VJTFLGOK1; RZ(h)} // m&i[.:][!.f], and remember cct when we created the table
497-
}else if(unlikely((c^visa)==CWORDS)){RZ(a=fsmvfya(a)); f1=jtfsmfx; flag&=~VJTFLGOK1; // m&;:
498-
}else if(unlikely((c^visa)==CIBEAM)){if(FAV(w)->localuse.lu1.foreignmn[0]==128&&FAV(w)->localuse.lu1.foreignmn[1]==3){RZ(h=crccompile(a)); f1=jtcrcfixedleft; flag&=~VJTFLGOK1; } // m&128!:3 scaf use rtn addr
497+
// obsolete }else if(unlikely((c^visa)==CWORDS)){RZ(a=fsmvfya(a)); f1=jtfsmfx; flag&=~VJTFLGOK1; // m&;:
498+
}else if(unlikely(FAV(w)->valencefns[0]==jtwords)){RZ(a=fsmvfya(a)); f1=jtfsmfx; flag&=~VJTFLGOK1; // m&;:
499+
// obsolete }else if(unlikely((c^visa)==CIBEAM)){if(FAV(w)->localuse.lu1.foreignmn[0]==128&&FAV(w)->localuse.lu1.foreignmn[1]==3){RZ(h=crccompile(a)); f1=jtcrcfixedleft; flag&=~VJTFLGOK1; } // m&128!:3
500+
}else if(unlikely(FAV(w)->valencefns[0]==jtcrc1)){RZ(h=crccompile(a)); f1=jtcrcfixedleft; flag&=~VJTFLGOK1; // m&128!:3
499501
}
500502
}
501503
fdeffillall(z,0,CAMP,VERB, f1,with2, a,w,h, flag, RMAX,RMAX,RMAX,fffv->localuse.lu0.cachedloc=0,FAV(z)->localuse.lu1.cct=cct);

jsrc/cf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ A jtfolk(J jt,A f,A g,A h){F2PREFIP;A p,q,x,y;AF f1=0,f2=0;B b;C c,fi,gi,hi;I fl
5959
// f will be INCORPed by fdef
6060
flag=(hv->flag&(VJTFLGOK1|VJTFLGOK2))+((gv->flag&hv->flag)&VASGSAFE); // We accumulate the flags for the derived verb. Start with ASGSAFE if all descendants are.
6161
fline=5; // set left argtype
62-
if(((AT(f)^B01)|AR(f)|BAV0(f)[0])==0&&BOTHEQ8(gi,hi,CEPS,CDOLLAR))f1=jtisempty; // 0 e. $, accepting only boolean 0
62+
// obsolete if(((AT(f)^B01)|AR(f)|BAV0(f)[0])==0&&BOTHEQ8(gi,hi,CEPS,CDOLLAR))f1=jtisempty; // 0 e. $, accepting only boolean 0
63+
if(f==num(0)&&BOTHEQ8(gi,hi,CEPS,CDOLLAR))f1=jtisempty; // 0 e. $, accepting only SDT boolean 0
6364
if(LIT&AT(f)&&1==AR(f)&&BOTHEQ8(gi,hi,CTILDE,CFORK)&&CFROM==ID(gv->fgh[0])){
6465
x=hv->fgh[0];
6566
if(LIT&AT(x)&&1==AR(x)&&CIOTA==ID(hv->fgh[1])&&CRIGHT==ID(hv->fgh[2])){f1=jtcharmap;} // (N {~ N i. ]) supports inplacing
@@ -92,7 +93,7 @@ A jtfolk(J jt,A f,A g,A h){F2PREFIP;A p,q,x,y;AF f1=0,f2=0;B b;C c,fi,gi,hi;I fl
9293
if(gi==CPOUND){f1=hi==CCOMMA?jtnatoms:f1; f1=hi==CDOLLAR?jtrank:f1;} // [: # , [: # $
9394
break; /* [: g h */
9495
case CSLASH: if(BOTHEQ8(gi,hi,CDIV,CPOUND)&&CPLUS==FAV(fv->fgh[0])->id){f1=jtmean; flag|=VIRS1; flag &=~(VJTFLGOK1);} break; /* +/%# */
95-
case CAT: /* <"1@[ { ] */
96+
case CAT: case CATCO: /* <"1@[ { ] or <"1@:[ { ] */
9697
if(BOTHEQ8(gi,hi,CLBRACE,CRIGHT)){
9798
p=fv->fgh[0]; q=fv->fgh[1];
9899
if(CQQ==FAV(p)->id&&CLEFT==ID(q)&&(CLT==ID(FAV(p)->fgh[0])&&FAV(p)->fgh[1]==num(1))){f2=jtsfrom; flag &=~(VJTFLGOK2);}

jsrc/cip.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ DF1(jtludecompg){F1PREFIP;PROLOG(823);
11281128
// the ith element of the permutation is the original row of row i of LU
11291129
// Bivalent. a, if given, is the sequence of thresholds to try
11301130
DF2(jtludecomp){F1PREFIP;PROLOG(823);
1131-
static D pthresh[2]={1e-6,0}, *pivotthresh; I npivotthresh, curpivotthreshx=0; // list of successive thresholds for pivots, last one usually 0.0
1131+
static D pthresh[2]={1e-6,0}, *pivotthresh; I npivotthresh, curpivotthreshx; // list of successive thresholds for pivots, last one usually 0.0
11321132
if(AT(w)&NOUN){ASSERT(AR(a)<=1,EVRANK); ASSERT(AN(a)>0,EVLENGTH) if(unlikely(!(AT(a)&FL)))RZ(a=cvt(FL,a)); pivotthresh=DAV(a); npivotthresh=AN(a);}else{w=a; pivotthresh=pthresh; npivotthresh=sizeof(pthresh)/sizeof(pthresh[0]);}
11331133
#if C_AVX2 || EMU_AVX2
11341134
// We operate on 4x4 blocks of A, which we transform into 4x4 blocks of LU. The ravel of each LU block is stored for cache ease,
@@ -1191,6 +1191,7 @@ DF2(jtludecomp){F1PREFIP;PROLOG(823);
11911191
// obsolete D *wluv=wclv; I wlustride=BLKSZ*wn; // pointer to next input values in A, and offset to next. We start going south
11921192
// obsolete D *nextfetchaddr=wclv; // the address of the block being fetched into nexta0..3. Init to the corner which we just prefetched
11931193
scv=LBLOCK(nr-1-r,nr-1-r); // start store at corner block. It will not advance until pivots have been found
1194+
curpivotthreshx=0; // start every ring looking for large pivots, even if we had to relax the criterion for an earlier ring
11941195

11951196
restartring:; // *** restart point after permutation has been updated. We restart the ring at the corner, which will succeed
11961197
// obsolete D (*llv)[BLKSZ][BLKSZ]=LBLOCK(nr-1-r,0), (*luv)[BLKSZ][BLKSZ]=UBLOCK(0,nr-1-r), (*prechv)[BLKSZ][BLKSZ]=llv+nr; // start point of dot-products (both going L-to-R), startpoint of next dot-product (first L block)

jsrc/io.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ static C* nfeinput(JS jt,C* s){A y;
353353
// if *p is (C)1 (which comes from m : 0), the request is for unprocessed 'literal input'
354354
// otherwise processed in inpl
355355
// Lines may come from a script, in which case return 0 on EOF, but EVINPRUPT is still possible as an error
356-
// scaf should rewrite this interface to keep the control info in locals in 0!:x
357356
A jtjgets(JJ jt,C*p){A y;B b;C*v;I j,k,m,n;UC*s;
358357
__atomic_store_n(&IJT(jt,adbreak)[0],0,__ATOMIC_RELEASE); // this is CLRATTN but for the definition of JT here
359358
if(b=1==*p)p=""; /* 1 means literal input; remember & clear prompt */

jsrc/jtype.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,9 @@ typedef I SI;
615615
#define ACSETPERM(x) {AC(x)=ACPERMANENT+100000; __atomic_fetch_or(&AFLAG(x),(AT(x)&RECURSIBLE),__ATOMIC_ACQ_REL);} // Make a block permanent from now on. In case other threads have committed to changing the usecount, make it permanent with a margin of safety
616616
#define SGNIFPRISTINABLE(c) ((c)+ACPERMANENT) // sign is set if this block is OK in a PRISTINE boxed noun
617617
// s is an expression that is neg if it's OK to inplace
618-
#define ASGNINPLACENEG(s,w) ((s)&(AC(w)|SGNIF(jt->zombieval==w,0))) // neg if OK to inplace ordinary operation
619-
#define ASGNINPLACESGN(s,w) (ASGNINPLACENEG(s,w)<0) // OK to inplace ordinary operation
620-
#define ASGNINPLACESGNNJA(s,w) ASGNINPLACESGN(s,w) // OK to inplace ordinary operation
618+
#define ASGNINPLACENEG(s,w) ((s)&(AC(w)|SGNIF(jt->zombieval==w,0))) // neg if OK to inplace ordinary operation, either because the block is inplaceable or because it's an assignment to zombie
619+
#define ASGNINPLACESGN(s,w) (ASGNINPLACENEG(s,w)<0)
620+
#define ASGNINPLACESGNNJA(s,w) ASGNINPLACESGN(s,w)
621621
// define virtreqd and set it to 0 to start
622622
// This is used in apip. We must ALWAYS allow inplacing for NJA types, but for ordinary inplacing we don't bother if the number of atoms of w pushes a over a power-of-2 boundary
623623
#define EXTENDINPLACENJA(a,w) \

jsrc/sc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ DF2(jtunquote){A z;
5555
// If it has a (necessarily direct named) locative, we must fetch the locative so we switch to it
5656
if(unlikely(((A)(I)(NAV(thisname)->flag&NMLOC))!=0)){ // most verbs aren't locatives. if no direct locative, leave global unchanged
5757
if(unlikely((explocale=FAV(self)->localuse.lu0.cachedloc)==0)){ // if we have looked it up before, keep the lookup
58-
RZSUFF(explocale=stfindcre(AN(thisname)-NAV(thisname)->m-2,1+NAV(thisname)->m+NAV(thisname)->s,NAV(thisname)->bucketx),z=0; goto exitname;); // extract locale string, find/create locale scaf why create?
58+
RZSUFF(explocale=stfind(AN(thisname)-NAV(thisname)->m-2,1+NAV(thisname)->m+NAV(thisname)->s,NAV(thisname)->bucketx),z=0; goto exitname;); // extract locale string, find locale, which must exist
5959
FAV(self)->localuse.lu0.cachedloc=explocale; // save named lookup calc for next time
6060
}
61-
flgd0cpC|=((explocale!=jt->global)&~(LXAV0(explocale)[SYMLEXECCT]>>EXECCTPERMX))<<FLGLOCINCRDECRX; // remember that there is a change of locale
61+
flgd0cpC|=((explocale!=jt->global)&~(LXAV0(explocale)[SYMLEXECCT]>>EXECCTPERMX))<<FLGLOCINCRDECRX; // remember that there is a change of locale, but not if it is permanent
6262
SYMSETGLOBAL(explocale); // switch to the (possibly new) locale.
6363
}
6464
flgd0cpC|=FLGCACHED; // indicate cached lookup, which also tells us that we have not ra()d the name
@@ -176,7 +176,7 @@ DF2(jtunquote){A z;
176176
// be horrid. To avoid that, we update execct only during a change
177177
// at this point jt->global is the new locale to use (possibly inherited). If LOCINCRDECR is set,
178178
// explocale also holds that value. LOCINCRDECR is set if we should incr/decr explocale, which is true if it changes
179-
// to a non-permanent locale (we don't want executions in z to hammer the z count)
179+
// to a non-permanent locale (we don't want executions in z/base/... to hammer the z count)
180180
if(flgd0cpC&FLGLOCINCRDECR){INCREXECCT(explocale);} // incr execct in newly-starting locale
181181
// scaf if someone deletes the locale before we start it, we are toast
182182
// ************** from here on errors must (optionally) decr explocale and unra() before exiting
@@ -263,7 +263,8 @@ exitfa:; // error point for errors after symbol res.
263263
if(likely(!(flgd0cpC&(FLGCACHED|FLGPSEUDO)))){fanamedacv(fs);} // unra the name if it was looked up from the symbol tables
264264
// obsolete if(0){exitname: SYMSETGLOBALINLOCAL(jt->locsyms,stack.global);} // error point for name errors. In case we put jt->global into jt->locsyms, undo that
265265
exitname:; // error point for name errors.
266-
SYMSETGLOBALINLOCAL(stack.locsyms,stack.global); // we will restore jt->global, which might have changed early or as late as the deletion; make sure locsyms matches
266+
SYMSETGLOBALINLOCAL(stack.locsyms,stack.global); // we will restore jt->global, which might have changed early or as late as the deletion; make sure locsyms matches. global and AKGST always match for the named explicit routine that is running.
267+
// if an explicit routine calls a tacit name via locative, globals and AKGST will diverge while the tacit verb runs; if the tacit verb then calls a (possibly named) explicit, the explicit's u. will be from the earlier explicit, not the intervening tacit.
267268
#if C_AVX2 || EMU_AVX2
268269
_mm256_storeu_si256((__m256i *)&jt->parserstackframe.sf,_mm256_loadu_si256((__m256i *)&stack));
269270
#else

jsrc/v.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ DF1(jticap){A a,e;I n;P*p;
164164
R likely((B01&AT(w))!=0) ? ifb(n,BAV(w)) : repeat(w,IX(n));
165165
}
166166

167-
DF1(jtcharmap){F1PREFIP; A z;B bb[256];I k,n,wn;UC c,*u,*v,zz[256]; // scaf should inplace w
167+
DF1(jtcharmap){F1PREFIP; A z;B bb[256];I k,n,wn;UC c,*u,*v,zz[256];
168168
A x=FAV(FAV(self)->fgh[2])->fgh[0], y=FAV(self)->fgh[0]; // extract translation tables
169169
RZ(w&&x&&y);
170170
if(!(LIT&AT(w)))R from(indexof(x,w),y);

jsrc/x15.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ static B jtcdexec1(J jt,CCT*cc,C*zv0,C*wu,I wk,I wt,I wd){A*wv=(A*)wu,x,y,*zv;B
11901190
#endif
11911191
// remember inplace-conversions (i. e. conversions to smaller precisions, which can be handled in place). Conversions to larger precisions, or to other types, were handled above.
11921192
// Here we see if a conversion will be needed and add it to the list of inplace conversions
1193-
CDASSERT(ISDENSETYPE(xt,B01+LIT+C2T+C4T+INT+INT2+INT4+FL+CMPX),per); // verify J type is DIRECT scaf not needed, impossible
1193+
// obsolete CDASSERT(ISDENSETYPE(xt,B01+LIT+C2T+C4T+INT+INT2+INT4+FL+CMPX),per); // verify J type is a C native type
11941194
if(unlikely(xlgsz>clgsz)){ // x is bigger than needed (ignoring cases of LIT buffers)
11951195
cip[cipcount].v=xv; cip[cipcount].n=xn; cip[cipcount].t=ctype; cip[cipcount].cxlgsz=4*clgsz+xlgsz; // save conversion info
11961196
++cipcount;

test/g128x.ijs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ for_dim. 2 + 20 ?@$ 40 do.
7676
l =. 1. todiag l * 0.5 > ($l) ?@$ 0
7777
a =. ({~ ?~@#) l +/ . * r
7878
'p lr' =. (1 0.01 1e_6 0) 128!:10 perma=: a
79-
assert. 1e_9 > >./ | , (p { a) - lrtoa lr
79+
assert. 1e_8 > >./ | , (p { a) - lrtoa lr
8080
end.
8181
1
8282
}}^:IF64 1 NB. all J64 support EMU_AVX2 true fma

0 commit comments

Comments
 (0)