version 1.1, 2018/09/19 05:45:07 |
version 1.4, 2018/10/01 05:49:06 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM$ |
* $OpenXM: OpenXM_contrib2/asir2018/engine/init.c,v 1.3 2018/09/28 08:20:28 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 126 void init_lprime(); |
|
Line 126 void init_lprime(); |
|
void nglob_init() { |
void nglob_init() { |
oONEUP2.w = 1; oONEUP2.b[0] = 1; |
oONEUP2.w = 1; oONEUP2.b[0] = 1; |
|
|
STOQ0(1,&oUNIQ); |
STOZ0(1,&oUNIQ); |
STOQ0(2,&oTWOQ); |
STOZ0(2,&oTWOQ); |
STOQ0(3,&oTHREEQ); |
STOZ0(3,&oTHREEQ); |
STOQ0(4,&oFOURQ); |
STOZ0(4,&oFOURQ); |
STOQ0(5,&oFIVEQ); |
STOZ0(5,&oFIVEQ); |
STOQ0(6,&oSIXQ); |
STOZ0(6,&oSIXQ); |
STOQ0(7,&oSEVENQ); |
STOZ0(7,&oSEVENQ); |
STOQ0(8,&oEIGHTQ); |
STOZ0(8,&oEIGHTQ); |
|
|
STOLM0(1,&oUNILM); |
STOLM0(1,&oUNILM); |
STOLM0(3,&oTHREELM); |
STOLM0(3,&oTHREELM); |
Line 159 void nglob_init() { |
|
Line 159 void nglob_init() { |
|
init_gmpq(); |
init_gmpq(); |
} |
} |
|
|
extern double GC_get_gctime(); |
|
double suspend_start; |
double suspend_start; |
double suspended_time=0; |
double suspended_time=0; |
|
|
void get_eg(struct oEGT *p) |
void get_eg(struct oEGT *p) |
{ |
{ |
double gctime = GC_get_gctime(); |
p->exectime = get_clock()-suspended_time; p->gctime = 0; |
p->exectime = get_clock() - gctime - suspended_time; p->gctime = gctime; |
|
} |
} |
|
|
void init_eg(struct oEGT *eg) |
void init_eg(struct oEGT *eg) |
Line 177 void init_eg(struct oEGT *eg) |
|
Line 175 void init_eg(struct oEGT *eg) |
|
void add_eg(struct oEGT *base,struct oEGT *start,struct oEGT *end) |
void add_eg(struct oEGT *base,struct oEGT *start,struct oEGT *end) |
{ |
{ |
base->exectime += end->exectime - start->exectime; |
base->exectime += end->exectime - start->exectime; |
base->gctime += end->gctime - start->gctime; |
|
} |
} |
|
|
void print_eg(char *item,struct oEGT *eg) |
void print_eg(char *item,struct oEGT *eg) |
{ |
{ |
printf("%s=(%.4g,%.4g)",item,eg->exectime,eg->gctime); |
printf("%s=(%.4g)",item,eg->exectime); |
} |
} |
|
|
void print_split_eg(struct oEGT *start,struct oEGT *end) |
void print_split_eg(struct oEGT *start,struct oEGT *end) |
Line 190 void print_split_eg(struct oEGT *start,struct oEGT *en |
|
Line 187 void print_split_eg(struct oEGT *start,struct oEGT *en |
|
struct oEGT base; |
struct oEGT base; |
|
|
init_eg(&base); add_eg(&base,start,end); |
init_eg(&base); add_eg(&base,start,end); |
printf("(%.4g,%.4g)",base.exectime,base.gctime); |
printf("(%.4g)",base.exectime); |
} |
} |
|
|
void print_split_e(struct oEGT *start,struct oEGT *end) |
void print_split_e(struct oEGT *start,struct oEGT *end) |
Line 252 void create_error(ERR *err,unsigned int serial,char *m |
|
Line 249 void create_error(ERR *err,unsigned int serial,char *m |
|
MKERR(*err,list); |
MKERR(*err,list); |
} |
} |
|
|
|
static mp_limb_t *lprime64; |
|
static int lprime64_size; |
|
|
void init_lprime() |
void init_lprime() |
{ |
{ |
int s,i; |
int s,i; |
Line 261 void init_lprime() |
|
Line 261 void init_lprime() |
|
lprime_size = s/sizeof(int); |
lprime_size = s/sizeof(int); |
for ( i = 0; i < lprime_size; i++ ) |
for ( i = 0; i < lprime_size; i++ ) |
lprime[i] = lprime_init[lprime_size-i-1]; |
lprime[i] = lprime_init[lprime_size-i-1]; |
|
|
|
#if SIZEOF_LONG == 8 |
|
s = sizeof(lprime64_init); |
|
lprime64 = (mp_limb_t *)MALLOC_ATOMIC(s); |
|
lprime64_size = s/sizeof(mp_limb_t); |
|
for ( i = 0; i < lprime64_size; i++ ) |
|
lprime64[i] = lprime64_init[lprime64_size-i-1]; |
|
#endif |
} |
} |
|
|
void create_new_lprimes(int); |
void create_new_lprimes(int); |
|
void create_new_lprimes64(int); |
|
|
int get_lprime(int index) |
int get_lprime(int index) |
{ |
{ |
Line 272 int get_lprime(int index) |
|
Line 281 int get_lprime(int index) |
|
return lprime[index]; |
return lprime[index]; |
} |
} |
|
|
|
#if SIZEOF_LONG == 8 |
|
mp_limb_t get_lprime64(int index) |
|
{ |
|
if ( index >= lprime64_size ) |
|
create_new_lprimes64(index); |
|
return lprime64[index]; |
|
} |
|
#endif |
|
|
void create_new_lprimes(int index) |
void create_new_lprimes(int index) |
{ |
{ |
int count,p,i,j,d; |
int count,p,i,j,d; |
Line 295 void create_new_lprimes(int index) |
|
Line 313 void create_new_lprimes(int index) |
|
} |
} |
} |
} |
lprime_size += count; |
lprime_size += count; |
|
} |
|
|
|
mp_limb_t nextprime(mp_limb_t a) |
|
{ |
|
static FUNC f=0; |
|
Z z,r; |
|
|
|
if ( f == 0 ) mkparif("nextprime",&f); |
|
STOZ(a,z); |
|
r = (Z)evalparif(f,mknode(1,z)); |
|
return ZTOS(r); |
|
} |
|
|
|
void create_new_lprimes64(int index) |
|
{ |
|
int count,j; |
|
mp_limb_t p; |
|
|
|
if ( index < lprime64_size ) |
|
return; |
|
count = index-lprime64_size+1; |
|
if ( count < 256 ) |
|
count = 256; |
|
lprime64 = (mp_limb_t *)GC_realloc(lprime64,(lprime64_size+count)*sizeof(mp_limb_t)); |
|
for ( p = lprime64[lprime64_size-1], j = 0; j < count; j++ ) { |
|
p = nextprime(p+1); |
|
lprime64[lprime64_size+j] = p; |
|
} |
|
lprime64_size += count; |
} |
} |