Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions jsrc/ar.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ static DF1(jtreducesp){A a,g,z;B b;I f,n,r,*v,wn,wr,*ws,wt,zt;P*wp;
else DQ(m, x=*u++; y=*u++; *zv++=F(x,y); ); \
}
#define BTABIFX(F) {btab[0 ]=0 F 0; \
btab[C_LE?256: 1]=0 F 1; \
btab[C_LE? 1:256]=1 F 0; \
btab[256]=0 F 1; \
btab[ 1]=1 F 0; \
btab[257 ]=1 F 1; \
}
#define BTABPFX(F) {btab[0 ]=F(0,0); \
btab[C_LE?256: 1]=F(0,1); \
btab[C_LE? 1:256]=F(1,0); \
btab[256]=F(0,1); \
btab[ 1]=F(1,0); \
btab[257 ]=F(1,1); \
}
#define BR2CASE(t,id) ((id)+256*(t))
Expand Down
4 changes: 0 additions & 4 deletions jsrc/dtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,7 @@
/* Options for use with J */
#include "js.h"
#define Long int
#if C_LE
#define IEEE_8087
#else
#define IEEE_MC68k
#endif
#define MULTIPLE_THREADS
#define ACQUIRE_DTOA_LOCK(n) /* handled by using jt */
#define FREE_DTOA_LOCK(n) /* handled by using jt */
Expand Down
40 changes: 0 additions & 40 deletions jsrc/j.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,10 @@ static inline omp_int_t omp_get_max_threads() { return 1;}
#define XNAN "\000\000\000\000\000\000\370\177"
#endif

#if C_LE
#ifndef XINF
#define XINF "\000\000\000\000\000\000\360\177"
#define XNAN "\000\000\000\000\000\000\370\377"
#endif
#endif

#ifndef XINF
#define XINF "\177\360\000\000\000\000\000\000"
Expand Down Expand Up @@ -921,15 +919,10 @@ static inline __attribute__((inline)) float64x2_t vec_and_pd(float64x2_t a, floa
#define NUMMAX 9 // largest number represented in num[]
#define NUMMIN (~NUMMAX) // smallest number represented in num[]
// Given SZI B01s read into p, pack the bits into the MSBs of p and clear the lower bits of p
#if C_LE // if anybody makes a bigendian CPU we'll have to recode
#if BW==64
// this is what it should be #define PACKBITS(p) {p|=p>>7LL;p|=p>>14LL;p|=p>>28LL;p<<=56LL;}
#define PACKBITS(p) {p|=p>>7LL;p|=p>>14LL;p|=p<<28LL;p&=0xff0000000; p<<=28LL;} // this generates one extra instruction, rather than the 3 for the correct version
#define PACKBITSINTO(p,out) {p|=p>>7LL;p|=p>>14LL;out=((p|(p>>28LL))<<56)|(out>>SZI);} // pack and shift into out
#else
#define PACKBITS(p) {p|=p>>7LL;p|=p>>14LL;p<<=28LL;}
#define PACKBITSINTO(p,out) {p|=p>>7LL;p|=p>>14LL;out=(p<<28)|(out>>SZI);} // pack and shift into out
#endif
#endif
#define PRISTCOMSET(w,flg) awback=(w); if(unlikely((flg&AFVIRTUAL)!=0)){awback=ABACK(awback); flg=AFLAG(awback);} AFLAG(awback)=flg&~AFPRISTINE;
#define PRISTCOMSETF(w,flg) if(unlikely((flg&AFVIRTUAL)!=0)){w=ABACK(w); flg=AFLAG(w);} AFLAG(w)=flg&~AFPRISTINE; // used only at end, when w can be destroyed
Expand Down Expand Up @@ -1057,10 +1050,8 @@ if(likely(z<3)){_zzt+=z; z=(I)&oneone; _zzt=_i&3?_zzt:(I*)z; z=_i&2?(I)_zzt:z; z
#else
#define REPLBYTETOW(in,out) (out=(UC)(in),out|=out<<8,out|=out<<16)
#endif
#if C_LE
// Output is pointer, Input is I/UI, count is # bytes to NOT store to output pointer (0-7).
#define STOREBYTES(out,in,n) {*(UI*)(out) = (*(UI*)(out)&~((UI)~(I)0 >> ((n)<<3))) | ((in)&((UI)~(I)0 >> ((n)<<3)));}
#endif
// Input is the name of word of bytes. Result is modified name, 1 bit per input byte, spaced like B01s, with the bit 0 iff the corresponding input byte was all 0. Non-boolean bits of result are garbage.
#define ZBYTESTOZBITS(b) (b=b|((b|(~b+VALIDBOOLEAN))>>7)) // for each byte: zero if b0 off, b7 off, and b7 turns on when you subtract 1 or 2
// to verify gah conversion #define RETF(exp) { A retfff=(exp); if ((retfff) && ((AT(retfff)&SPARSE && AN(retfff)!=1) || (AT(retfff)&DENSE && AN(retfff)!=prod(AR(retfff),AS(retfff)))))SEGFAULT;; R retfff; } // scaf
Expand Down Expand Up @@ -1099,7 +1090,6 @@ if(likely(z<3)){_zzt+=z; z=(I)&oneone; _zzt=_i&3?_zzt:(I*)z; z=_i&2?(I)_zzt:z; z
#define VAL2 '\002'
#define WITHDEBUGOFF(stmt) {UC d=jt->uflags.us.cx.cx_c.db; jt->uflags.us.cx.cx_c.db=0; stmt jt->uflags.us.cx.cx_c.db=d;} // execute stmt with debug turned off

#if C_LE
#if BW==64
#define IHALF0 0x00000000ffffffffLL
#else
Expand All @@ -1125,39 +1115,9 @@ if(likely(z<3)){_zzt+=z; z=(I)&oneone; _zzt=_i&3?_zzt:(I*)z; z=_i&2?(I)_zzt:z; z
#define BS01 0x0100
#define BS10 0x0001
#define BS11 0x0101
#else
#if BW==64
#define IHALF0 0xffffffff00000000LL
#else
#define IHALF0 0xffff0000
#endif
#define B0000 0x00000000
#define B0001 0x00000001
#define B0010 0x00000100
#define B0011 0x00000101
#define B0100 0x00010000
#define B0101 0x00010001
#define B0110 0x00010100
#define B0111 0x00010101
#define B1000 0x01000000
#define B1001 0x01000001
#define B1010 0x01000100
#define B1011 0x01000101
#define B1100 0x01010000
#define B1101 0x01010001
#define B1110 0x01010100
#define B1111 0x01010101
#define BS00 0x0000
#define BS01 0x0001
#define BS10 0x0100
#define BS11 0x0101
#endif



#define CACHELINESIZE 64 // size of processor cache line, in case we align to it


// flags in call to cachedmmult and blockedmmult
#define FLGCMPX 0
#define FLGCMP ((I)1<<FLGCMPX) // arguments are complex
Expand Down
10 changes: 0 additions & 10 deletions jsrc/js.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
/* */
/* SYS_ and friends */

// configuration - conditional compilation
// historical confusion that will slowly be sorted out
// complexity of autoconf et. al. seems overkill for J - we shall see

// C_? new style config - default value if not defined by builder

#ifndef C_LE // littleendian/bigendian
#define C_LE 1
#endif

#ifndef C_NA // noasm/asm
#define C_NA 1
#endif
Expand Down
11 changes: 0 additions & 11 deletions jsrc/jtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,10 @@ struct AD {
I c; // usecount
// NOTE!! result.h faux cellshape block depends on n, r, and s being in place from here to the end of this struct, with 2 Is from n to s
I n; // # atoms - always 1 for sparse arrays
#if C_LE
RANKT r; // rank
US h; // reserved for allocator. Not used for AFNJA memory
#if BW==64
UI4 fill; // On 64-bit systems, there will be a padding word here - insert in case compiler doesn't
#endif
#else
#if BW==64
UI4 fill; // On 64-bit systems, there will be a padding word here - insert in case compiler doesn't
#endif
US h; // reserved for allocator. Not used for AFNJA memory
RANKT r; // rank
#endif
I s[1]; // shape starts here. NOTE!! s[0] is always OK to fetch. We allocate 8 words minimum and s[0] is the last.
};
Expand Down Expand Up @@ -210,10 +202,7 @@ typedef I SI;
#define PAV(x) ( (P*)((C*)(x)+AK(x))) /* sparse */
#define SBAV(x) ((SB*)((C*)(x)+AK(x))) /* symbol */
#define voidAV(x) ((void*)((C*)(x)+AK(x))) // unknown

#if C_LE
#define BIV0(w) (IAV(w)[0]&(1-((AT(w)&INT)>>(INTX-1)))) // the first (presumably only) value in w, when w is an INT or B01 type
#endif

/* Types for AT(x) field of type A */
/* Note: BOOL name conflict with ???; SCHAR name conflict with sqltypes.h */
Expand Down
2 changes: 1 addition & 1 deletion jsrc/k.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static KF1(jtQfromX){X*v=XAV(w),*x=(X*)yv; DQ(AN(w), *x++=*v++; *x++=iv1;); R 1;

static KF2(jtQfromD){B neg,recip;D c,d,t,*wv;I e,i,n,*v;Q q,*x;S*tv;
if(!(w))R 0;
n=AN(w); wv=DAV(w); x=(Q*)yv; tv=3*C_LE+(S*)&t;
n=AN(w); wv=DAV(w); x=(Q*)yv; tv=3+(S*)&t;
for(i=0;i<n;++i){
t=wv[i];
ASSERT(!_isnan(t),EVNAN);
Expand Down
2 changes: 1 addition & 1 deletion jsrc/sl.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ A jtstfindcre(J jt,I n,C*u,I bucketx){
// b is flags: 1=check name for validity, 2=do not allow numeric locales (whether atomic or not)
static A jtvlocnl(J jt,I b,A w){A*wv,y;C*s;I i,m,n;
ARGCHK1(w);
if(((b-2) & (SGNIF(AT(w),INTX) | (SGNIF(AT(w),B01X) & (AR(w)-1))))<0)R w; // integer list or scalar boolean is OK C_LE
if(((b-2) & (SGNIF(AT(w),INTX) | (SGNIF(AT(w),B01X) & (AR(w)-1))))<0)R w; // integer list or scalar boolean is OK
n=AN(w);
ASSERT(((n-1)|SGNIF(AT(w),BOXX))<0,EVDOMAIN);
wv=AAV(w);
Expand Down
2 changes: 1 addition & 1 deletion jsrc/va2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ DF2(jtfslashatg){A fs,gs,y,z;B b,sb=0;C*av,c,d,*wv;I ak,an,ar,*as,at,m,
tn=(zn+SZI-1)>>LGSZI; GATV0(t,INT,tn,1); tc=UAV(t); ti=(UI*)tc;
// Run g in batches of up to 255, accumulating the result bytewise. NOTE: there may be garbage at the end of yv, but because
// we are supporting littleendian only, it will not affect the result
for(j=nn;0<j;j-=255/C_LE){
for(j=nn;0<j;j-=255){
memset(ti,C0,tn*SZI);
DO(MIN(j,255), ((AHDR2FN*)adocv.f)(n,m,av,wv,yv,jt); av+=ak; wv+=wk; DO(tn,ti[i]+=yv[i];););
DO(zn, zv[i]+=tc[i];);
Expand Down
32 changes: 16 additions & 16 deletions jsrc/vcompsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,25 @@
R sc(n); \
}

#define SUMB(f,T0,T1,F) \
static F2(f){I an,*av,n,p,r1,wn,*wv,z=0;UI t,x; \
an=AN(a); av=AV(a); \
wn=AN(w); wv=AV(w); n=1; n=AR(a)?an:n; n=AR(w)?wn:n; \
p=n>>LGSZI; r1=n&(SZI-1); \
if (!AR(a)){ \
ASSIGNX(av); \
#define SUMB(f,T0,T1,F) \
static F2(f){I an,*av,n,p,r1,wn,*wv,z=0;UI t,x; \
an=AN(a); av=AV(a); \
wn=AN(w); wv=AV(w); n=1; n=AR(a)?an:n; n=AR(w)?wn:n; \
p=n>>LGSZI; r1=n&(SZI-1); \
if (!AR(a)){ \
ASSIGNX(av); \
while((p-=255)>0){t=0; DQ(255, t+=F(x, *wv++);); ADDBYTESINI(t); z+=t;} \
t=0; DQ(p+255, t+=F(x, *wv++);); ADDBYTESINI(t); z+=t; x=F(x, *wv); \
}else if(!AR(w)){ \
ASSIGNX(wv); \
t=0; DQ(p+255, t+=F(x, *wv++);); ADDBYTESINI(t); z+=t; x=F(x, *wv); \
}else if(!AR(w)){ \
ASSIGNX(wv); \
while((p-=255)>0){t=0; DQ(255, t+=F(*av++,x );); ADDBYTESINI(t); z+=t;} \
t=0; DQ(p+255, t+=F(*av++,x );); ADDBYTESINI(t); z+=t; x=F(*av,x ); \
}else{ \
t=0; DQ(p+255, t+=F(*av++,x );); ADDBYTESINI(t); z+=t; x=F(*av,x ); \
}else{ \
while((p-=255)>0){t=0; DQ(255, t+=F(*av++,*wv++);); ADDBYTESINI(t); z+=t;} \
t=0; DQ(p+255, t+=F(*av++,*wv++);); ADDBYTESINI(t); z+=t; x=F(*av,*wv); \
} \
x &= ((I)1<<(r1<<LGBB))-1; ADDBYTESINI(x); z+=x; /* C_LE */ \
R sc(z); \
t=0; DQ(p+255, t+=F(*av++,*wv++);); ADDBYTESINI(t); z+=t; x=F(*av,*wv); \
} \
x &= ((I)1<<(r1<<LGBB))-1; ADDBYTESINI(x); z+=x; \
R sc(z); \
}

INDB( i0eqBB,B,B,NE ) INDF( i0eqBI,B,I,ANE ) INDF0( i0eqBD,B,D,TNEXD,NEXD0) /* = */
Expand Down
2 changes: 1 addition & 1 deletion jsrc/ve.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ A jtintmod2(J jt,A w,I mod){A z;B *v;I n,q,r,*u;UI m=0; // init m for warning
// the rest is boolean result
n=AN(w); v=BAV(w); // littleendian only
GATV(z,B01,n,AR(w),AS(w)); RZ(n); // loops below can't handle empty
u=AV(z); q=(n-1)>>(LGSZI/C_LE); r=((n-1)&(SZI-1))+1; // there is always a remnant
u=AV(z); q=(n-1)>>(LGSZI); r=((n-1)&(SZI-1))+1; // there is always a remnant
I mask=mod==2?VALIDBOOLEAN:0; // if mod is 1, all results will be 0; otherwise boolean result
DQ(q, DQ(SZI, m=(m>>8)+((UI)*v<<((SZI-1)*8)); v+=SZI;); *u++=m&mask;)
DQ(r, m=(m>>8)+((UI)*v<<((SZI-1)*8)); v+=SZI;); // 1-8 bytes
Expand Down
2 changes: 1 addition & 1 deletion jsrc/vg.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ static GF(jtgrc){A x;B b,q,up;I e,i,p,ps,*xv,yv[256];UC*vv,*wv;
if((UI)ai>lgn)R grx(m,ai,n,w,zv); // TUNE
ai<<=((AT(w)>>C2TX)&1);
p=B01&AT(w)?2:256; ps=p*SZI; wv=UAV(w); up=SGNTO0(jt->workareas.compare.complt);
q=C2T&AT(w) && C_LE;
q=C2T&AT(w) && 1;
if(1<ai){GATV0(x,INT,n,1); xv=AV(x);}
for(i=0;i<m;++i){
b=(B)(ai&1); if(q){e=-3; vv=wv+ai-2;}else{e=-1; vv=wv+ai-1;}
Expand Down
18 changes: 5 additions & 13 deletions jsrc/vg.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,14 @@ extern I grcol2(I,I,US*,I,I*,I*,const I,US*,I);
extern void jtmsort(J,I,void**,void**);

// Convert 2 Booleans to a code 0-3
#if C_LE
#define IND2(x) {US xx = (x); ii = ((xx<<9)|xx)>>8;}
#else
#define IND2(x) {US xx = (x); ii = 0x3&((xx>>7)|xx);}
#endif

// Convert 4 Booleans to a code 0-15
#if C_LE
#define IND4(x) {UINT xx = (x); xx|=xx<<9; xx|=xx<<18; ii = xx>>24;} // first byte (bit 0) is the MSB when a word is loaded
#else
#define IND4(x) {UINT xx = (x); ii = 0xf&((xx>>21)|(xx>>14)|(xx>>7)|xx);}
#endif

// endian constants for 16-bit radix sorts
#define FPLSBWDX (C_LE?0:3)
#define FPMSBWDX (C_LE?3:0)
#define INTLSBWDX (C_LE?0:(SZI/2-1))
#define INTMSBWDX (C_LE?(SZI/2-1):0)
#define WDINC (C_LE?1:-1)
#define FPLSBWDX (0)
#define FPMSBWDX (3)
#define INTLSBWDX (0)
#define INTMSBWDX (SZI/2-1)
#define WDINC (1)
4 changes: 0 additions & 4 deletions jsrc/vgranking.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,12 @@ F1(jtranking){A y,z;C*wv;I icn,i,k,m,n,t,wcr,wf,wn,wr,*ws,wt,*zv;CR rng;TTYPE *y
case sizeof(C4):
RANKINGLOOP(C4); break;
case sizeof(C): RANKINGLOOP(UC); break;
#if C_LE
case sizeof(S):
if(wt&IS1BYTE){I c,d,s,t;US*v;TTYPE *u;
v=(US*)wv; DQ(n, ++yu[*v++];);
s=0; DO(256, c=0; d=i; DQ(256, u=yv+(c+d); c+=256; if(*u){t=*u; *u=(TTYPE)s; s+=t;}););
v=(US*)wv; DQ(n, *zv++=yu[*v++]++;);
}else RANKINGLOOP(US);
#else
case sizeof(S): RANKINGLOOP(US);
#endif
}
wv+=n*k;
}
Expand Down
2 changes: 1 addition & 1 deletion jsrc/vgsort.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static SF(jtsortc2){A y,z;B up;I i,p,*yv;US j,k,*wv,*v;
DO(p, yv[i]=0;);
for(i=0;i<m;++i){
DQ(n, ++yv[*wv++];);
if(C2T&AT(w)||!C_LE){
if(C2T&AT(w)){
if(up){j=0; DQ(p, DQ(yv[j], *v++=j;); yv[j]=0; ++j;);}
else {j=(US)(p-1); DQ(p, DQ(yv[j], *v++=j;); yv[j]=0; --j;);}
}else{
Expand Down
19 changes: 0 additions & 19 deletions jsrc/vi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@
/* ThinkC MAC 6888x 0 1 _ _ 2 3 4 5 6 7 8 9 */
/* normal 0 1 2 3 4 5 6 7 ... */

#if C_LE
#define MSW 1 /* most significant word */
#define LSW 0 /* least significant word */
#else
#define MSW 0
#define LSW 1
#endif

// create a mask of bits in which a difference is considered significant for floating-point purposes.
// we calculate this using pi as a reference: find pi +- ct, and see which bits are different. Everything
Expand Down Expand Up @@ -55,28 +50,14 @@ static UI hicnz( I k,UC*v){UI HASHINIT(z);UC c; DQ(k, c=*v++; if(c&&c!

static UI hicx(J jt,I k,UC*v){UI HASHINIT(z);I*u=jt->hiv; DQ(jt->hin, HASHSTEP(z,v[*u++]); ); R z;}

#if C_LE
UI hic2( I k,UC*v){UI HASHINIT(z); DQ(k>>1, HASHSTEP(z,v[0]);
if(*(v+1)){HASHSTEP(z,v[1]);} v+=2;); R z;}
#else
UI hic2( I k,UC*v){UI HASHINIT(z); ++v; DQ(k>>1, HASHSTEP(z,v[0]);
if(*(v-1)){HASHSTEP(z,v[-1]);} v+=2;); R z;}
#endif

#if C_LE
UI hic4( I k,UC*v){UI HASHINIT(z); DQ(k>>2, HASHSTEP(z,v[0]);
if(*(v+2)||*(v+3)){HASHSTEP(z,v[1]);
HASHSTEP(z,v[2]);
HASHSTEP(z,v[3]);}
else if(*(v+1)){HASHSTEP(z,v[1]);} v+=4;); R z;}
#else
UI hic4( I k,UC*v){UI HASHINIT(z); v+=3; DQ(k>>2, HASHSTEP(z,v[0]);
if(*(v-2)||*(v-3)){HASHSTEP(z,v[-1]);
HASHSTEP(z,v[-2]);
HASHSTEP(z,v[-3]);}
else if(*(v-1)){HASHSTEP(z,v[-1]);} v+=4;); R z;}
#endif


// Hash a single unsigned INT
#define hicw(v) (10495464745870458733U**(UI*)(v))
Expand Down
4 changes: 0 additions & 4 deletions jsrc/viix.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ F2(jticap2){A*av,*wv,z;C*uu,*vv;I ar,*as,at,b,c,ck,cm,ge,gt,j,k,m,n,p,q,r,t,wr,*
case TT(B01X, FLX ): BSLOOP(C, D ); break;
case TT(LITX, C2TX ): BSLOOP(UC,US); break;
case TT(LITX, C4TX ): BSLOOP(UC,C4); break;
#if C_LE
case TT(LITX, LITX ): BSLOOP(UC,UC); break;
#else
case TT(LITX, LITX ): if(1&c){BSLOOP(UC,UC); break;}else c>>=1; /* fall thru */
#endif
case TT(C2TX, C2TX ): BSLOOP(US,US); break;
case TT(C2TX, C4TX ): BSLOOP(US,C4); break;
case TT(C2TX, LITX ): BSLOOP(US,UC); break;
Expand Down
Loading