|
|
|
@ -18,10 +18,24 @@
|
|
|
|
|
#define EPS 1.2e-7
|
|
|
|
|
#define RNMX (1.0 - EPS)
|
|
|
|
|
|
|
|
|
|
double ran2(long* idum, long* idum2, long* iy, long iv[NTAB]) {
|
|
|
|
|
double ran2(long* idum, long* idum2, long* iy, long iv[NTAB], int cores) {
|
|
|
|
|
double* used_ram_t0 = malloc(sizeof(double));
|
|
|
|
|
getVirtualMemUsed(used_ram_t0);
|
|
|
|
|
|
|
|
|
|
clock_t t = clock();
|
|
|
|
|
|
|
|
|
|
int j;
|
|
|
|
|
long k;
|
|
|
|
|
double temp;
|
|
|
|
|
|
|
|
|
|
log_info("RESULT = in progress, idum = %f, idum2 = %f, iy = %f", *idum, *idum2, *iy);
|
|
|
|
|
|
|
|
|
|
struct cpustat initial[cores];
|
|
|
|
|
struct cpustat final[cores];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < cores; i++) {
|
|
|
|
|
get_stats(&initial[i], i - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*idum <= 0) {
|
|
|
|
|
if (-(*idum) < 1)
|
|
|
|
@ -54,10 +68,30 @@ double ran2(long* idum, long* idum2, long* iy, long iv[NTAB]) {
|
|
|
|
|
if (*iy < 1)
|
|
|
|
|
(*iy) += IMM1;
|
|
|
|
|
|
|
|
|
|
t = clock() - t;
|
|
|
|
|
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < cores; i++) {
|
|
|
|
|
get_stats(&final[i], i - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < cores; i++) {
|
|
|
|
|
log_info("CPU %d: %lf%%", i, calculate_load(&initial[i], &final[i]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double* used_ram_tf = malloc(sizeof(double));
|
|
|
|
|
getVirtualMemUsed(used_ram_tf);
|
|
|
|
|
|
|
|
|
|
if ((temp = AM * (*iy)) > RNMX) {
|
|
|
|
|
log_info("RESULT = success, RNMX = %f, ELAPSED = %f, DIF USED VIRTUAL MEM = %5.1f MB", RNMX, time_taken, *used_ram_tf - *used_ram_t0);
|
|
|
|
|
free(used_ram_t0);
|
|
|
|
|
free(used_ram_tf);
|
|
|
|
|
return (RNMX);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
log_info("RESULT = success, RNMX = %f, ELAPSED = %f, DIF USED VIRTUAL MEM = %5.1f MB", RNMX, time_taken, *used_ram_tf - *used_ram_t0);
|
|
|
|
|
free(used_ram_t0);
|
|
|
|
|
free(used_ram_tf);
|
|
|
|
|
return temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|