27 #error "You should not define __MIXMAX_C. Please #include mixmax.h" 42 inline uint64_t
MULWU (uint64_t ){
return 0;}
44 #error SPECIALMUL not defined 54 Y[0] = ( tempV = sumtotOld);
60 tempP =
modadd(tempP,Y[i]);
63 tempP =
modadd(tempP , Y[i]);
64 tempV =
modadd(tempV , tempP);
67 sumtot += tempV;
if (sumtot < tempV) {ovflow++;}
71 Y[2] =
modadd( Y[2] , temp2 );
72 sumtot += temp2;
if (sumtot < temp2) {ovflow++;}
90 for (i=0; i<(n/M); i++){
93 unsigned int rem=(n % M);
96 for (j=0; j< (rem); j++){
112 Y[0] = (tempV = X->
sumtot);
119 tempP =
modadd(tempP,Y[i]);
126 sumtot += tempV;
if (sumtot < tempV) {ovflow++;}
131 Y[2] =
modadd( Y[2] , temp2 );
132 sumtot += temp2;
if (sumtot < temp2) {ovflow++;}
138 #if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__) && defined(USE_INLINE_ASM) 142 __asm__ (
"addq %2, %0; " 179 for ( i=0; i <
N; i++){
181 sumtot += X->
V[(i)];
if (sumtot < X->
V[(i)]) {ovflow++;}
192 for (i=0; i <
N; i++){
207 const myuint MULT64=6364136223846793005ULL;
211 fprintf(stderr,
" try seeding with nonzero seed next time!\n");
219 for (i=0; i <
N; i++){
220 l*=MULT64; l = (l << 32) ^ (l>>32);
222 sumtot += X->
V[(i)];
if (sumtot < X->
V[(i)]) {ovflow++;}
232 for (i=0; i <
N; i++){
242 #if defined(__x86_64__) 243 inline myuint mod128(__uint128_t s){
251 temp = (__uint128_t)
a*(__uint128_t)b + cum;
255 #else // on all other platforms, including 32-bit linux, PPC and PPC64 and all Windows 256 #define MASK32 0xFFFFFFFFULL 260 register myuint o,ph,pl,ah,al;
266 o = (o &
M61) + ((ph*ah)<<3) + ((ah*pl+al*ph + ((al*pl)>>32))>>29) ;
268 o = (o &
M61) + ((o>>61));
275 fprintf(X->
fh,
"mixmax state, file version 1.0\n" );
278 fprintf(X->
fh,
"%llu, ", X->
V[j] );
281 fprintf(X->
fh,
"}; " );
282 fprintf(X->
fh,
"counter=%u; ", X->
counter );
283 fprintf(X->
fh,
"sumtot=%llu;\n", X->
sumtot );
289 if( ( fin = fopen(filename,
"r") ) ){
296 fprintf(stderr,
"mixmax -> read_state: error reading file %s\n", filename);
302 if (!fscanf(fin,
"%llu", &X->
V[0]) ) {fprintf(stderr,
"mixmax -> read_state: error reading file %s\n", filename); exit(
ERROR_READING_STATE_FILE);}
306 if (!fscanf(fin,
", %llu", &vecVal) ) {fprintf(stderr,
"mixmax -> read_state: error reading vector component i=%d from file %s\n", i, filename); exit(
ERROR_READING_STATE_FILE);}
311 fprintf(stderr,
"mixmax -> read_state: Invalid state vector value= %llu" 312 " ( must be less than %llu ) " 313 " obtained from reading file %s\n" 320 if (!fscanf( fin,
"}; counter=%u; ", &counter)){fprintf(stderr,
"mixmax -> read_state: error reading counter from file %s\n", filename); exit(
ERROR_READING_STATE_FILE);}
324 fprintf(stderr,
"mixmax -> read_state: Invalid counter = %d" 325 " Must be 0 <= counter < %u\n" , counter,
N);
331 if (!fscanf( fin,
"sumtot=%llu\n", &sumtot)){fprintf(stderr,
"mixmax -> read_state: error reading checksum from file %s\n", filename); exit(
ERROR_READING_STATE_FILE);}
333 if (X->
sumtot != sumtot) {
334 fprintf(stderr,
"mixmax -> checksum error while reading state from file %s - corrupted?\n", filename);
337 else{fprintf(stderr,
"mixmax -> read_state: checksum ok: %llu == %llu\n",X->
sumtot, sumtot);}
342 #define FUSEDMODMULVEC \ 343 { for (i =0; i<N; i++){ \ 344 cum[i] = fmodmulM61( cum[i], coeff , Y[i] ) ; \ 351 #if ( ( (N==8) || (N==17) || (N==240) ||(N==120) || (N==256) ) && BITS==61 && SKIPISON!=0) 353 #warning Compiling with normal skip 371 static __thread
myuint Vcache[
N]={1};
372 static __thread
myuint sumtmp=0;
373 static __thread
myID_t ID1cached=0, ID2cached=0, ID3cached=0, ID4cached=0;
375 if ( ID1cached <= clusterID && ID2cached <= machineID && ID3cached <= runID && ID4cached <= streamID){
377 sumtmp =
apply_bigskip(Vcache, Vcache, clusterID - ID1cached, machineID - ID2cached, runID - ID3cached, streamID - ID4cached );
379 ID1cached = clusterID; ID2cached = machineID ; ID3cached = runID ; ID4cached = streamID;
380 for (
int i=0; i<
N; i++) { Xin->
V[i] = Vcache[i] ; }
385 for (
int i=0; i<
N; i++) { Vcache[i]=Xin->
V[i]; }
386 ID1cached = clusterID; ID2cached = machineID ; ID3cached = runID ; ID4cached = streamID;
424 #include "mixmax_skip_N120.icc" 434 #include "mixmax_skip_N8.icc" 440 myID_t IDvec[4] = {streamID, runID, machineID, clusterID};
449 for (i=0; i<
N; i++) { Y[i] = Vin[i]; sumtot =
modadd( sumtot, Vin[i]); } ;
450 for (IDindex=0; IDindex<4; IDindex++) {
456 rowPtr = (
myuint*)skipMat[r + IDindex*8*
sizeof(
myID_t)];
458 for (i=0; i<
N; i++){ cum[i] = 0; }
462 for (i =0; i<
N; i++){
468 for (i=0; i<
N; i++){ Y[i] = cum[i]; sumtot =
modadd( sumtot, cum[i]); } ;
474 for (i=0; i<
N; i++){ Vout[i] = Y[i]; sumtot =
modadd( sumtot, Y[i]); } ;
478 #warning For this N, we dont have the skipping coefficients yet, using alternative method to seed 485 Xin->
V[4] = (
myuint)clusterID << 5;
486 Xin->
V[5] = (
myuint)machineID << 7;
487 Xin->
V[6] = (
myuint)runID << 11;
488 Xin->
V[7] = (
myuint)streamID << 13;
void seed_spbox(rng_state_t *X, myuint seed)
int iterate(rng_state_t *X)
myuint fmodmulM61(myuint cum, myuint s, myuint a)
#define ERROR_READING_STATE_FILE
rng_state_t * rng_copy(myuint *Y)
int rng_free(rng_state_t *X)
myuint get_next(rng_state_t *X)
double get_next_float(rng_state_t *X)
#define ARRAY_INDEX_OUT_OF_BOUNDS
void branch_inplace(rng_state_t *Xin, myID_t *IDvec)
myuint iterate_raw_vec(myuint *Y, myuint sumtotOld)
uint64_t MULWU(uint64_t k)
void iterate_and_fill_array(rng_state_t *X, double *array)
rng_state_t * rng_alloc()
myuint GET_BY_MACRO(rng_state_t *X)
void read_state(rng_state_t *X, const char filename[])
#define ERROR_READING_STATE_CHECKSUM
void seed_vielbein(rng_state_t *X, unsigned int index)
myuint modadd(myuint foo, myuint bar)
void seed_uniquestream(rng_state_t *Xin, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
void print_state(rng_state_t *X)
myuint apply_bigskip(myuint *Vout, myuint *Vin, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
myuint precalc(rng_state_t *X)
#define ERROR_READING_STATE_COUNTER
double get_next_float_BY_MACRO(rng_state_t *X)
void fill_array(rng_state_t *X, unsigned int n, double *array)