27 #error "You should not define __MIXMAX_C. Please #include mixmax.h"
42inline uint64_t
MULWU (uint64_t ){
return 0;}
44#error SPECIALMUL not defined
54 Y[0] = ( tempV = sumtotOld);
55 myuint sumtot = Y[0], ovflow = 0;
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);
114 myuint sumtot = Y[0], ovflow = 0;
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++){
202 if (
X->fh==NULL){
X->fh=stdout;}
207 const myuint MULT64=6364136223846793005ULL;
211 fprintf(stderr,
" try seeding with nonzero seed next time!\n");
218 if (
X->fh==NULL){
X->fh=stdout;}
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__) && !defined(_WIN64)
243inline myuint mod128(__uint128_t s){
251 temp = (__uint128_t)
a*(__uint128_t)
b + cum;
256#define MASK32 0xFFFFFFFFULL
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);
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"
319 unsigned int counter;
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++){ \
344cum[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
357 if (Xin->
fh==NULL){Xin->
fh=stdout;}
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++) {
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;
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
#define ERROR_READING_STATE_FILE
#define ARRAY_INDEX_OUT_OF_BOUNDS
#define ERROR_READING_STATE_COUNTER
#define ERROR_READING_STATE_CHECKSUM
#define get_next_float(X)
double get_next_float_BY_MACRO(rng_state_t *X)
myuint GET_BY_MACRO(rng_state_t *X)
myuint precalc(rng_state_t *X)
void seed_spbox(rng_state_t *X, myuint seed)
myuint fmodmulM61(myuint cum, myuint s, myuint a)
myuint iterate_raw_vec(myuint *Y, myuint sumtotOld)
int iterate(rng_state_t *X)
void seed_vielbein(rng_state_t *X, unsigned int index)
void branch_inplace(rng_state_t *Xin, myID_t *IDvec)
rng_state_t * rng_alloc()
void print_state(rng_state_t *X)
rng_state_t * rng_copy(myuint *Y)
void seed_uniquestream(rng_state_t *Xin, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
int rng_free(rng_state_t *X)
void read_state(rng_state_t *X, const char filename[])
myuint modadd(myuint foo, myuint bar)
void fill_array(rng_state_t *X, unsigned int n, double *array)
myuint apply_bigskip(myuint *Vout, myuint *Vin, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
uint64_t MULWU(uint64_t k)
void iterate_and_fill_array(rng_state_t *X, double *array)