version 1.29, 2020/07/02 09:24:17 |
version 1.30, 2020/07/03 03:37:59 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.28 2020/06/30 01:52:17 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.29 2020/07/02 09:24:17 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 50 static NDV *nd_ps_trace; |
|
Line 50 static NDV *nd_ps_trace; |
|
static NDV *nd_ps_sym; |
static NDV *nd_ps_sym; |
static NDV *nd_ps_trace_sym; |
static NDV *nd_ps_trace_sym; |
static RHist *nd_psh; |
static RHist *nd_psh; |
static int nd_psn,nd_pslen; |
static int nd_psn,nd_pslen,nd_nbase; |
static RHist *nd_red; |
static RHist *nd_red; |
static int *nd_work_vector; |
static int *nd_work_vector; |
static int **nd_matrix; |
static int **nd_matrix; |
Line 2484 print_eg("update",&eg_update); |
|
Line 2484 print_eg("update",&eg_update); |
|
return g; |
return g; |
} |
} |
|
|
ND_pairs update_pairs_s(ND_pairs d,NODE g,int t,NODE *syz); |
ND_pairs update_pairs_s(ND_pairs d,int t,NODE *syz); |
ND_pairs nd_newpairs_s( NODE g, int t ,NODE *syz); |
ND_pairs nd_newpairs_s(int t ,NODE *syz); |
|
|
int nd_nf_pbucket_s(int mod,ND g,NDV *ps,int full,ND *nf); |
int nd_nf_pbucket_s(int mod,ND g,NDV *ps,int full,ND *nf); |
int nd_nf_s(int mod,ND d,ND g,NDV *ps,int full,ND *nf); |
int nd_nf_s(int mod,ND d,ND g,NDV *ps,int full,ND *nf); |
Line 2606 ND_pairs remove_large_lcm(ND_pairs d) |
|
Line 2606 ND_pairs remove_large_lcm(ND_pairs d) |
|
|
|
struct oEGT eg_create,eg_newpairs,eg_merge; |
struct oEGT eg_create,eg_newpairs,eg_merge; |
|
|
|
NODE conv_ilist_s(int demand,int trace,int **indp); |
|
|
NODE nd_sba_buch(int m,int ishomo,int **indp) |
NODE nd_sba_buch(int m,int ishomo,int **indp) |
{ |
{ |
int i,j,nh,sugar,stat; |
int i,j,nh,sugar,stat; |
NODE r,g,t; |
NODE r,t,g; |
ND_pairs d; |
ND_pairs d; |
ND_pairs l; |
ND_pairs l; |
ND h,nf,s,head,nf1; |
ND h,nf,s,head,nf1; |
Line 2629 init_eg(&eg_remove); |
|
Line 2631 init_eg(&eg_remove); |
|
Nsyz = 0; |
Nsyz = 0; |
Nnd_add = 0; |
Nnd_add = 0; |
Nredundant = 0; |
Nredundant = 0; |
g = 0; d = 0; |
d = 0; |
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
d = update_pairs_s(d,g,i,syzlist); |
d = update_pairs_s(d,i,syzlist); |
g = append_one(g,i); |
|
} |
} |
for ( i = 0; i < nd_psn; i++ ) |
for ( i = 0; i < nd_psn; i++ ) |
for ( j = i+1; j < nd_psn; j++ ) { |
for ( j = i+1; j < nd_psn; j++ ) { |
|
|
nfv = ndtondv(m,nf); nd_free(nf); |
nfv = ndtondv(m,nf); nd_free(nf); |
nh = ndv_newps(m,nfv,0); |
nh = ndv_newps(m,nfv,0); |
|
|
d = update_pairs_s(d,g,nh,syzlist); |
d = update_pairs_s(d,nh,syzlist); |
g = append_one(g,nh); |
|
nd_sba_pos[sig->pos] = append_one(nd_sba_pos[sig->pos],nh); |
nd_sba_pos[sig->pos] = append_one(nd_sba_pos[sig->pos],nh); |
FREENDP(l); |
FREENDP(l); |
} else { |
} else { |
Line 2704 get_eg(&eg2); add_eg(&eg_remove,&eg1,&eg2); |
|
Line 2704 get_eg(&eg2); add_eg(&eg_remove,&eg1,&eg2); |
|
FREENDP(l); |
FREENDP(l); |
} |
} |
} |
} |
conv_ilist(nd_demand,0,g,indp); |
g = conv_ilist_s(nd_demand,0,indp); |
if ( DP_Print ) { |
if ( DP_Print ) { |
printf("\nnd_sba done. nd_add=%d,Nsyz=%d,Nredundant=%d\n",Nnd_add,Nsyz,Nredundant); |
printf("\nnd_sba done. nd_add=%d,Nsyz=%d,Nredundant=%d\n",Nnd_add,Nsyz,Nredundant); |
fflush(stdout); |
fflush(stdout); |
Line 3135 ND_pairs update_pairs( ND_pairs d, NODE /* of index */ |
|
Line 3135 ND_pairs update_pairs( ND_pairs d, NODE /* of index */ |
|
|
|
ND_pairs merge_pairs_s(ND_pairs d,ND_pairs d1); |
ND_pairs merge_pairs_s(ND_pairs d,ND_pairs d1); |
|
|
ND_pairs update_pairs_s( ND_pairs d, NODE /* of index */ g, int t,NODE *syz) |
ND_pairs update_pairs_s( ND_pairs d, int t,NODE *syz) |
{ |
{ |
ND_pairs d1; |
ND_pairs d1; |
struct oEGT eg1,eg2,eg3; |
struct oEGT eg1,eg2,eg3; |
|
|
if ( !g ) return d; |
if ( !t ) return d; |
get_eg(&eg1); |
get_eg(&eg1); |
d1 = nd_newpairs_s(g,t,syz); |
d1 = nd_newpairs_s(t,syz); |
get_eg(&eg2); add_eg(&eg_create,&eg1,&eg2); |
get_eg(&eg2); add_eg(&eg_create,&eg1,&eg2); |
d = merge_pairs_s(d,d1); |
d = merge_pairs_s(d,d1); |
get_eg(&eg3); add_eg(&eg_merge,&eg2,&eg3); |
get_eg(&eg3); add_eg(&eg_merge,&eg2,&eg3); |
Line 3186 ND_pairs nd_newpairs( NODE g, int t ) |
|
Line 3186 ND_pairs nd_newpairs( NODE g, int t ) |
|
return r0; |
return r0; |
} |
} |
|
|
|
|
int comp_sig(SIG s1,SIG s2) |
int comp_sig(SIG s1,SIG s2) |
{ |
{ |
#if 0 |
#if 0 |
Line 3362 INLINE int __dl_redble(DL d1,DL d2,int nvar) |
|
Line 3361 INLINE int __dl_redble(DL d1,DL d2,int nvar) |
|
return 1; |
return 1; |
} |
} |
|
|
ND_pairs nd_newpairs_s( NODE g, int t, NODE *syz) |
ND_pairs nd_newpairs_s(int t, NODE *syz) |
{ |
{ |
NODE h,s; |
NODE h,s; |
UINT *dl; |
UINT *dl; |
Line 3380 ND_pairs nd_newpairs_s( NODE g, int t, NODE *syz) |
|
Line 3379 ND_pairs nd_newpairs_s( NODE g, int t, NODE *syz) |
|
r0 = 0; |
r0 = 0; |
for ( i = 0; i < t; i++ ) { |
for ( i = 0; i < t; i++ ) { |
ret = _create_spair_s(i,t,_sp,_sig1,_sig2); |
ret = _create_spair_s(i,t,_sp,_sig1,_sig2); |
// for ( h = g; h; h = NEXT(h) ) { |
|
// ret = _create_spair_s((long)BDY(h),t,_sp,_sig1,_sig2); |
|
if ( ret ) { |
if ( ret ) { |
spsig = _sp->sig; |
spsig = _sp->sig; |
for ( s = syz[spsig->pos]; s; s = s->next ) { |
for ( s = syz[spsig->pos]; s; s = s->next ) { |
Line 5582 ND_pairs nd_reconstruct(int trace,ND_pairs d) |
|
Line 5579 ND_pairs nd_reconstruct(int trace,ND_pairs d) |
|
return s0; |
return s0; |
} |
} |
|
|
|
void nd_reconstruct_s(int trace,ND_pairs *d) |
|
{ |
|
int i,obpe,oadv,h; |
|
static NM prev_nm_free_list; |
|
static ND_pairs prev_ndp_free_list; |
|
RHist mr0,mr; |
|
RHist r; |
|
RHist *old_red; |
|
ND_pairs s0,s,t; |
|
EPOS oepos; |
|
|
|
obpe = nd_bpe; |
|
oadv = nmv_adv; |
|
oepos = nd_epos; |
|
if ( obpe < 2 ) nd_bpe = 2; |
|
else if ( obpe < 3 ) nd_bpe = 3; |
|
else if ( obpe < 4 ) nd_bpe = 4; |
|
else if ( obpe < 5 ) nd_bpe = 5; |
|
else if ( obpe < 6 ) nd_bpe = 6; |
|
else if ( obpe < 8 ) nd_bpe = 8; |
|
else if ( obpe < 10 ) nd_bpe = 10; |
|
else if ( obpe < 16 ) nd_bpe = 16; |
|
else if ( obpe < 32 ) nd_bpe = 32; |
|
else error("nd_reconstruct_s : exponent too large"); |
|
|
|
nd_setup_parameters(nd_nvar,0); |
|
prev_nm_free_list = _nm_free_list; |
|
prev_ndp_free_list = _ndp_free_list; |
|
_nm_free_list = 0; |
|
_ndp_free_list = 0; |
|
for ( i = nd_psn-1; i >= 0; i-- ) { |
|
ndv_realloc(nd_ps[i],obpe,oadv,oepos); |
|
ndv_realloc(nd_ps_sym[i],obpe,oadv,oepos); |
|
} |
|
if ( trace ) |
|
for ( i = nd_psn-1; i >= 0; i-- ) { |
|
ndv_realloc(nd_ps_trace[i],obpe,oadv,oepos); |
|
ndv_realloc(nd_ps_trace_sym[i],obpe,oadv,oepos); |
|
} |
|
|
|
for ( i = 0; i < nd_nbase; i++ ) { |
|
s0 = 0; |
|
for ( t = d[i]; t; t = NEXT(t) ) { |
|
NEXTND_pairs(s0,s); |
|
s->i1 = t->i1; |
|
s->i2 = t->i2; |
|
s->sig = t->sig; |
|
SG(s) = SG(t); |
|
ndl_reconstruct(LCM(t),LCM(s),obpe,oepos); |
|
} |
|
d[i] = s0; |
|
} |
|
|
|
old_red = (RHist *)MALLOC(REDTAB_LEN*sizeof(RHist)); |
|
for ( i = 0; i < REDTAB_LEN; i++ ) { |
|
old_red[i] = nd_red[i]; |
|
nd_red[i] = 0; |
|
} |
|
for ( i = 0; i < REDTAB_LEN; i++ ) |
|
for ( r = old_red[i]; r; r = NEXT(r) ) { |
|
NEWRHist(mr); |
|
mr->index = r->index; |
|
SG(mr) = SG(r); |
|
ndl_reconstruct(DL(r),DL(mr),obpe,oepos); |
|
h = ndl_hash_value(DL(mr)); |
|
NEXT(mr) = nd_red[h]; |
|
nd_red[h] = mr; |
|
mr->sig = r->sig; |
|
} |
|
for ( i = 0; i < REDTAB_LEN; i++ ) old_red[i] = 0; |
|
old_red = 0; |
|
for ( i = 0; i < nd_psn; i++ ) { |
|
NEWRHist(r); SG(r) = SG(nd_psh[i]); |
|
ndl_reconstruct(DL(nd_psh[i]),DL(r),obpe,oepos); |
|
r->sig = nd_psh[i]->sig; |
|
nd_psh[i] = r; |
|
} |
|
if ( s0 ) NEXT(s) = 0; |
|
prev_nm_free_list = 0; |
|
prev_ndp_free_list = 0; |
|
#if 0 |
|
GC_gcollect(); |
|
#endif |
|
} |
|
|
void ndl_reconstruct(UINT *d,UINT *r,int obpe,EPOS oepos) |
void ndl_reconstruct(UINT *d,UINT *r,int obpe,EPOS oepos) |
{ |
{ |
int n,i,ei,oepw,omask0,j,s,ord_l,l; |
int n,i,ei,oepw,omask0,j,s,ord_l,l; |
Line 9452 void conv_ilist(int demand,int trace,NODE g,int **indp |
|
Line 9534 void conv_ilist(int demand,int trace,NODE g,int **indp |
|
if ( indp ) *indp = ind; |
if ( indp ) *indp = ind; |
} |
} |
|
|
|
NODE conv_ilist_s(int demand,int trace,int **indp) |
|
{ |
|
int n,i,j; |
|
int *ind; |
|
NODE g0,g; |
|
|
|
n = nd_psn; |
|
ind = (int *)MALLOC(n*sizeof(int)); |
|
g0 = 0; |
|
for ( i = 0; i < n; i++ ) { |
|
ind[i] = i; |
|
NEXTNODE(g0,g); |
|
BDY(g) = (pointer)(demand?ndv_load(i):(trace?nd_ps_trace[i]:nd_ps[i])); |
|
} |
|
if ( g0 ) NEXT(g) = 0; |
|
if ( indp ) *indp = ind; |
|
return g0; |
|
} |
|
|
void parse_nd_option(NODE opt) |
void parse_nd_option(NODE opt) |
{ |
{ |
NODE t,p,u; |
NODE t,p,u; |
Line 10806 NODE nd_sba_f4(int m,int **indp) |
|
Line 10907 NODE nd_sba_f4(int m,int **indp) |
|
int *rhead; |
int *rhead; |
int spcol,sprow; |
int spcol,sprow; |
int sugar,sugarh; |
int sugar,sugarh; |
|
int nbase; |
PGeoBucket bucket; |
PGeoBucket bucket; |
struct oEGT eg0,eg1,eg_f4; |
struct oEGT eg0,eg1,eg_f4; |
Z i1,i2,sugarq; |
Z i1,i2,sugarq; |
NODE *syzlist; |
NODE *syzlist; |
|
|
Nf4_red=0; |
Nf4_red=0; |
g = 0; d = 0; |
d = 0; |
syzlist = (NODE *)MALLOC(nd_psn*sizeof(NODE)); |
syzlist = (NODE *)MALLOC(nd_psn*sizeof(NODE)); |
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
d = update_pairs_s(d,g,i,syzlist); |
d = update_pairs_s(d,i,syzlist); |
g = append_one(g,i); |
|
} |
} |
|
nd_nbase = nd_psn; |
f4red = 1; |
f4red = 1; |
while ( d ) { |
while ( d ) { |
l = nd_minsugarp_s(d,&d); |
l = nd_minsugarp_s(d,&d); |
Line 10859 NODE nd_sba_f4(int m,int **indp) |
|
Line 10961 NODE nd_sba_f4(int m,int **indp) |
|
nf = ndtondv(m,tmpred); |
nf = ndtondv(m,tmpred); |
ndv_removecont(m,nf); |
ndv_removecont(m,nf); |
nh = ndv_newps(m,nf,0); |
nh = ndv_newps(m,nf,0); |
d = update_pairs_s(d,g,nh,syzlist); |
d = update_pairs_s(d,nh,syzlist); |
g = append_one(g,nh); |
nd_sba_pos[sig->pos] = append_one(nd_sba_pos[sig->pos],nh); |
} else { |
} else { |
syzlist[sig->pos] = insert_sig(syzlist[sig->pos],sig); |
syzlist[sig->pos] = insert_sig(syzlist[sig->pos],sig); |
} |
} |
} |
} |
// YYY |
for ( i = 0; i < nd_nbase; i++ ) |
// for ( r = syzlist; r; r = NEXT(r) ) |
for ( r = syzlist[i]; r; r = NEXT(r) ) |
// d = remove_spair_s(d,(SIG)BDY(r)); |
d = remove_spair_s(d,(SIG)BDY(r)); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"f4red=%d,gblen=%d\n",f4red,length(g)); fflush(asir_out); |
fprintf(asir_out,"f4red=%d,gblen=%d\n",f4red,length(g)); fflush(asir_out); |
} |
} |
Line 10878 NODE nd_sba_f4(int m,int **indp) |
|
Line 10980 NODE nd_sba_f4(int m,int **indp) |
|
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"number of red=%d,",Nf4_red); |
fprintf(asir_out,"number of red=%d,",Nf4_red); |
} |
} |
conv_ilist(nd_demand,0,g,indp); |
g = conv_ilist_s(nd_demand,0,indp); |
return g; |
return g; |
} |
} |