Add memory diff instead of total

milestone_5_without_improvements-logs
chortas 3 years ago
parent 6510ea7a88
commit a3d7a23da1

@ -20,6 +20,9 @@
/* Y is the realization with mean and variance wanted */
void Py_kgeneration(long seed, struct grid_mod grid, struct statistic_mod stat, struct vario_mod variogram, struct realization_mod* Z, struct realization_mod* Y, int n[3], int cores) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
int i, N;
@ -62,17 +65,11 @@ void Py_kgeneration(long seed, struct grid_mod grid, struct statistic_mod stat,
log_info("CPU %d: %lf%%\n", i, calculate_load(&initial[i], &final[i]));
}
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
free(total_ram);
free(used_ram);
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
log_info("RESULT = success, ELAPSED = %f seconds", time_taken);
log_info("RESULT = success, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", time_taken, *used_ram_tf - *used_ram_t0);
free(used_ram_t0);
free(used_ram_tf);
}

@ -21,11 +21,11 @@
/*ireal: vector defining the i-part */
void build_real(int n[3], int NTOT, double* covar, double* realization, double* ireal) {
clock_t t = clock();
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
int i, j, k, maille1;
double temp;
log_info("RESULT = in progress, NTOT = %d, covar = %f, n[0] = %d, n[1] = %d, n[2] = %d", NTOT, *covar, n[0], n[1], n[2]);
@ -53,7 +53,7 @@ void build_real(int n[3], int NTOT, double* covar, double* realization, double*
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
log_info("RESULT = success, realization = %f, ireal = %f, ELAPSED = %f seconds, USED VIRTUAL MEM = %5.1f MB, DIF USED VIRTUAL MEM = %5.1f MB", *realization, *ireal, time_taken, *used_ram_tf, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, realization = %f, ireal = %f, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", *realization, *ireal, time_taken, *used_ram_tf - *used_ram_t0);
free(used_ram_t0);
free(used_ram_tf);

@ -6,6 +6,9 @@
/*cardsin covariance function*/
double cardsin(double h) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress, h = %f", h);
@ -23,19 +26,13 @@ double cardsin(double h) {
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
free(total_ram);
free(used_ram);
log_info("RESULT = success, z = %f, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", z, time_taken, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, z = %f, ELAPSED = %f seconds", z, time_taken);
free(used_ram_t0);
free(used_ram_tf);
return z;
}

@ -12,6 +12,9 @@
/* X, Y and Z axes for the underlying grid */
/* i = [0 1 2] */
void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3]) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
int i, N;
@ -19,6 +22,7 @@ void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3]) {
log_info("RESULT = in progress");
if (n == NULL || n[0] == 0 || n[1] == 0 || n[2] == 0) {
for (i = 0; i < 3; i++) {
switch (i) {
@ -47,17 +51,11 @@ void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3]) {
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
free(total_ram);
free(used_ram);
log_info("RESULT = success, n[0] = %d, n[1] = %d, n[2] = %d, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", n[0], n[1], n[2], time_taken, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, n[0] = %d, n[1] = %d, n[2] = %d, ELAPSED = %f seconds", n[0], n[1], n[2], time_taken);
free(used_ram_t0);
free(used_ram_tf);
}

@ -9,6 +9,9 @@
#include <time.h>
void clean_real(struct realization_mod* realin, int n[3], struct grid_mod grid, double* vectorresult, struct realization_mod* realout) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
int i, j, k, maille0, maille1;
@ -45,17 +48,11 @@ void clean_real(struct realization_mod* realin, int n[3], struct grid_mod grid,
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
free(total_ram);
free(used_ram);
log_info("RESULT = success, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", time_taken, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, ELAPSED = %f seconds", time_taken);
free(used_ram_t0);
free(used_ram_tf);
}

@ -6,6 +6,9 @@
/*selection of model covariance*/
double cov_value(struct vario_mod variogram, double di, double dj, double dk) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress, di = %f, dj = %f, dk = %f", di, dj, dk);
@ -57,19 +60,13 @@ double cov_value(struct vario_mod variogram, double di, double dj, double dk) {
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
free(total_ram);
free(used_ram);
log_info("RESULT = success, hx = %f, hy = %f, hz = %f, h = %f, cov = %f, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", hx, hy, hz, h, cov, time_taken, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, hx = %f, hy = %f, hz = %f, h = %f, cov = %f, ELAPSED = %f seconds", hx, hy, hz, h, cov, time_taken);
free(used_ram_t0);
free(used_ram_tf);
return cov;
}

@ -5,6 +5,9 @@
/*builds the sampled covariance function*/
/*dimensions are even*/
void covariance(double* covar, struct vario_mod variogram, struct grid_mod mesh, int n[3]) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
int i, j, k, maille, n2[3], symmetric;
@ -83,17 +86,11 @@ void covariance(double* covar, struct vario_mod variogram, struct grid_mod mesh,
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
free(total_ram);
free(used_ram);
log_info("RESULT = success, di = %f, dj = %f, dk = %f, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", di, dj, dk, time_taken, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, di = %f, dj = %f, dk = %f, ELAPSED = %f seconds", di, dj, dk, time_taken);
free(used_ram_t0);
free(used_ram_tf);
}

@ -6,6 +6,9 @@
/*cubic covariance function*/
double cubic(double h) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress, h = %f", h);
@ -21,19 +24,13 @@ double cubic(double h) {
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
free(total_ram);
free(used_ram);
log_info("RESULT = success, z = %f, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", z, time_taken, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, z = %f, ELAPSED = %f seconds", z, time_taken);
free(used_ram_t0);
free(used_ram_tf);
return z;
}

@ -24,11 +24,11 @@
/*realout: structure defining a realization - */
void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct realization_mod* realin, struct realization_mod* realout) {
clock_t t = clock();
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress");
int NTOT, i, j, k, NMAX, NDIM, ntot, nmax, NXYZ, nxyz;
@ -107,7 +107,7 @@ void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct r
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
log_info("RESULT = success, NTOT = %d, NMAX = %d, NDIM = %d, ntot = %d, nmax = %d, NXYZ = %d, nxyz = %d, ELAPSED = %f seconds, USED VIRTUAL MEM = %5.1f MB, DIF USED VIRTUAL MEM = %5.1f MB", NTOT, NMAX, NDIM, ntot, nmax, NXYZ, nxyz, time_taken, *used_ram_tf, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, NTOT = %d, NMAX = %d, NDIM = %d, ntot = %d, nmax = %d, NXYZ = %d, nxyz = %d, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", NTOT, NMAX, NDIM, ntot, nmax, NXYZ, nxyz, time_taken, *used_ram_tf - *used_ram_t0);
free(used_ram_t0);
free(used_ram_tf);

@ -92,6 +92,9 @@
/* 10-06-2000, MLR */
void fourt(double* datar, double* datai, int nn[3], int ndim, int ifrwd, int icplx, double* workr, double* worki) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress");
@ -590,18 +593,11 @@ L920:
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
free(total_ram);
free(used_ram);
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
log_info("RESULT = success, ELAPSED = %f, DIF USED VIRTUAL MEM = %5.1f MB", time_taken, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, ELAPSED = %f", time_taken);
return;
free(used_ram_t0);
free(used_ram_tf);
}

@ -6,6 +6,9 @@
/*gamma covariance function*/
double gammf(double h, double alpha) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress, h = %f, alpha = %f", h, alpha);
@ -19,18 +22,13 @@ double gammf(double h, double alpha) {
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
free(total_ram);
free(used_ram);
log_info("RESULT = success, delta = %f, z = %f, ELAPSED = %f seconds", delta, z, time_taken);
log_info("RESULT = success, delta = %f, z = %f, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", delta, z, time_taken, *used_ram_tf - *used_ram_t0);
free(used_ram_t0);
free(used_ram_tf);
return z;
}

@ -9,6 +9,9 @@ double gasdev(long* idum, long* idum2, long* iy, long iv[NTAB]) {
/*returns a normally distributed deviate with 0 mean*/
/*and unit variance, using ran2(idum) as the source */
/*of uniform deviates */
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress, idum = %f, idum2 = %f, iy = %f", *idum, *idum2, *iy);
@ -32,19 +35,14 @@ double gasdev(long* idum, long* idum2, long* iy, long iv[NTAB]) {
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
log_info("RESULT = success, gset = %f, fac = %f, v1 = %f, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", gset, fac, v1, time_taken, *used_ram_tf - *used_ram_t0);
free(total_ram);
free(used_ram);
free(used_ram_t0);
free(used_ram_tf);
log_info("RESULT = success, gset = %f, fac = %f, v1 = %f, ELAPSED = %f seconds", gset, fac, v1, time_taken);
return (v2 * fac);
} else {
iset = 0;
@ -52,19 +50,14 @@ double gasdev(long* idum, long* idum2, long* iy, long iv[NTAB]) {
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
log_info("RESULT = success, gset = %f, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", gset, time_taken, *used_ram_tf - *used_ram_t0);
free(total_ram);
free(used_ram);
free(used_ram_t0);
free(used_ram_tf);
log_info("RESULT = success, gset = %f, ELAPSED = %f seconds", gset, time_taken);
return gset;
}
}

@ -13,6 +13,9 @@
/* realization: structure defining the realization*/
void generate(long* seed, int n, struct realization_mod* realization, int cores) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress, n = %d", n);
@ -59,19 +62,13 @@ void generate(long* seed, int n, struct realization_mod* realization, int cores)
log_info("CPU %d: %lf%%\n", i, calculate_load(&initial[i], &final[i]));
}
free(iv);
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
free(iv);
free(total_ram);
free(used_ram);
log_info("RESULT = success, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", time_taken, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, ELAPSED = %f seconds", time_taken);
free(used_ram_t0);
free(used_ram_tf);
}

@ -4,6 +4,9 @@
/* compute the length for one dimension*/
int length(int N, int i, double* scf, double* ap, double D, int Nvari) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress, N = %d, i = %d, D = %f, Nvari = %d", N, i, D, Nvari);
@ -44,18 +47,13 @@ int length(int N, int i, double* scf, double* ap, double D, int Nvari) {
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
log_info("RESULT = success, n = %d, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", n, time_taken, *used_ram_tf - *used_ram_t0);
free(total_ram);
free(used_ram);
free(used_ram_t0);
free(used_ram_tf);
log_info("RESULT = success, n = %d, ELAPSED = %f seconds", n, time_taken);
return n;
}

@ -3,6 +3,9 @@
/*determines the greatest prime factor of an integer*/
int maxfactor(int n) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress, n = %d", n);
@ -39,18 +42,13 @@ int maxfactor(int n) {
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
free(total_ram);
free(used_ram);
log_info("RESULT = success, maxfac = %d, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", maxfac, time_taken, *used_ram_tf - *used_ram_t0);
free(used_ram_t0);
free(used_ram_tf);
log_info("RESULT = success, maxfac = %d, ELAPSED = %f seconds", maxfac, time_taken);
return maxfac;
}

@ -24,7 +24,7 @@ void getVirtualMemUsed(double* used_ram) {
const double megabyte = 1024 * 1024;
struct sysinfo si;
sysinfo(&si);
*used_ram = si.freeram / megabyte;
*used_ram = (si.totalram - si.freeram) / megabyte;
}
int parseLine(char* line) {

@ -15,6 +15,9 @@
/* lognormal numbers */
void nor2log(struct realization_mod* realin, int typelog, struct realization_mod* realout) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
log_info("RESULT = in progress");
@ -75,17 +78,11 @@ void nor2log(struct realization_mod* realin, int typelog, struct realization_mod
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
free(total_ram);
free(used_ram);
log_info("RESULT = success, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", time_taken, *used_ram_tf - *used_ram_t0);
log_info("RESULT = success, ELAPSED = %f seconds", time_taken);
free(used_ram_t0);
free(used_ram_tf);
}

@ -22,6 +22,9 @@
/*realization: structure defining a realization*/
void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin, double* realization, int solver) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
int i, j, k, maille0, maille1;
@ -54,17 +57,11 @@ void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("RESULT = success, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", time_taken, *used_ram_tf - *used_ram_t0);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
free(total_ram);
free(used_ram);
log_info("RESULT = success, ELAPSED = %f seconds", time_taken);
free(used_ram_t0);
free(used_ram_tf);
}

@ -18,6 +18,9 @@
#define RNMX (1.0 - EPS)
double ran2(long* idum, long* idum2, long* iy, long iv[NTAB]) {
double* used_ram_t0 = malloc(sizeof(double));
getVirtualMemUsed(used_ram_t0);
clock_t t = clock();
int j;
@ -60,24 +63,18 @@ double ran2(long* idum, long* idum2, long* iy, long iv[NTAB]) {
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
double* total_ram = malloc(sizeof(double));
getTotalVirtualMem(total_ram);
double* used_ram = malloc(sizeof(double));
getVirtualMemUsed(used_ram);
log_info("TOTAL VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM = %5.1f MB, USED VIRTUAL MEM BY CURRENT PROCESS = %d MB",
*total_ram, *used_ram, getVirtualMemUsedByCurrentProcess());
free(total_ram);
free(used_ram);
double* used_ram_tf = malloc(sizeof(double));
getVirtualMemUsed(used_ram_tf);
if ((temp = AM * (*iy)) > RNMX) {
log_info("RESULT = success, ELAPSED = %f", time_taken);
log_info("RESULT = success, ELAPSED = %f, DIF USED VIRTUAL MEM = %5.1f MB", time_taken, *used_ram_tf - *used_ram_t0);
return (RNMX);
}
else {
log_info("RESULT = success, temp = %f, ELAPSED = %f seconds", temp, time_taken);
log_info("RESULT = success, temp = %f, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", temp, time_taken, *used_ram_tf - *used_ram_t0);
return temp;
}
free(used_ram_t0);
free(used_ram_tf);
}

Loading…
Cancel
Save