diff --git a/fftma_module/gen/lib_src/Py_kgeneration.c b/fftma_module/gen/lib_src/Py_kgeneration.c index d7c7b05..7791ce6 100644 --- a/fftma_module/gen/lib_src/Py_kgeneration.c +++ b/fftma_module/gen/lib_src/Py_kgeneration.c @@ -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); } diff --git a/fftma_module/gen/lib_src/build_real.c b/fftma_module/gen/lib_src/build_real.c index 8e541c2..44624f9 100644 --- a/fftma_module/gen/lib_src/build_real.c +++ b/fftma_module/gen/lib_src/build_real.c @@ -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); diff --git a/fftma_module/gen/lib_src/cardsin.c b/fftma_module/gen/lib_src/cardsin.c index 60ec7f1..64f3462 100644 --- a/fftma_module/gen/lib_src/cardsin.c +++ b/fftma_module/gen/lib_src/cardsin.c @@ -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; } diff --git a/fftma_module/gen/lib_src/cgrid.c b/fftma_module/gen/lib_src/cgrid.c index 50ba621..ce61a3d 100644 --- a/fftma_module/gen/lib_src/cgrid.c +++ b/fftma_module/gen/lib_src/cgrid.c @@ -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); } diff --git a/fftma_module/gen/lib_src/clean_real.c b/fftma_module/gen/lib_src/clean_real.c index 3c3295d..4d4982e 100644 --- a/fftma_module/gen/lib_src/clean_real.c +++ b/fftma_module/gen/lib_src/clean_real.c @@ -9,6 +9,9 @@ #include 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); } diff --git a/fftma_module/gen/lib_src/cov_value.c b/fftma_module/gen/lib_src/cov_value.c index 412c872..31327bb 100644 --- a/fftma_module/gen/lib_src/cov_value.c +++ b/fftma_module/gen/lib_src/cov_value.c @@ -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; } diff --git a/fftma_module/gen/lib_src/covariance.c b/fftma_module/gen/lib_src/covariance.c index 5ec8ced..5dc256c 100644 --- a/fftma_module/gen/lib_src/covariance.c +++ b/fftma_module/gen/lib_src/covariance.c @@ -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); } diff --git a/fftma_module/gen/lib_src/cubic.c b/fftma_module/gen/lib_src/cubic.c index 38c7ed2..ac0439b 100644 --- a/fftma_module/gen/lib_src/cubic.c +++ b/fftma_module/gen/lib_src/cubic.c @@ -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; } diff --git a/fftma_module/gen/lib_src/fftma2.c b/fftma_module/gen/lib_src/fftma2.c index c35ac00..bf4b9de 100644 --- a/fftma_module/gen/lib_src/fftma2.c +++ b/fftma_module/gen/lib_src/fftma2.c @@ -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); diff --git a/fftma_module/gen/lib_src/fourt.c b/fftma_module/gen/lib_src/fourt.c index f54d52a..eb88520 100644 --- a/fftma_module/gen/lib_src/fourt.c +++ b/fftma_module/gen/lib_src/fourt.c @@ -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); } diff --git a/fftma_module/gen/lib_src/gammf.c b/fftma_module/gen/lib_src/gammf.c index eb98587..2b3aac8 100644 --- a/fftma_module/gen/lib_src/gammf.c +++ b/fftma_module/gen/lib_src/gammf.c @@ -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; } diff --git a/fftma_module/gen/lib_src/gasdev.c b/fftma_module/gen/lib_src/gasdev.c index 2da6775..a860f96 100644 --- a/fftma_module/gen/lib_src/gasdev.c +++ b/fftma_module/gen/lib_src/gasdev.c @@ -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; } } diff --git a/fftma_module/gen/lib_src/generate.c b/fftma_module/gen/lib_src/generate.c index f4a395f..e325368 100644 --- a/fftma_module/gen/lib_src/generate.c +++ b/fftma_module/gen/lib_src/generate.c @@ -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); } diff --git a/fftma_module/gen/lib_src/length.c b/fftma_module/gen/lib_src/length.c index 6c4a759..f7bbdbf 100644 --- a/fftma_module/gen/lib_src/length.c +++ b/fftma_module/gen/lib_src/length.c @@ -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; } diff --git a/fftma_module/gen/lib_src/maxfactor.c b/fftma_module/gen/lib_src/maxfactor.c index cda2bfd..5aafcb2 100644 --- a/fftma_module/gen/lib_src/maxfactor.c +++ b/fftma_module/gen/lib_src/maxfactor.c @@ -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; } diff --git a/fftma_module/gen/lib_src/memory.c b/fftma_module/gen/lib_src/memory.c index 40b2904..1559e71 100644 --- a/fftma_module/gen/lib_src/memory.c +++ b/fftma_module/gen/lib_src/memory.c @@ -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) { diff --git a/fftma_module/gen/lib_src/nor2log.c b/fftma_module/gen/lib_src/nor2log.c index af17aa1..2e96e68 100644 --- a/fftma_module/gen/lib_src/nor2log.c +++ b/fftma_module/gen/lib_src/nor2log.c @@ -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); } diff --git a/fftma_module/gen/lib_src/prebuild_gwn.c b/fftma_module/gen/lib_src/prebuild_gwn.c index be1f3bb..f4cd850 100644 --- a/fftma_module/gen/lib_src/prebuild_gwn.c +++ b/fftma_module/gen/lib_src/prebuild_gwn.c @@ -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); } diff --git a/fftma_module/gen/lib_src/ran2.c b/fftma_module/gen/lib_src/ran2.c index 79a564e..6c582bb 100644 --- a/fftma_module/gen/lib_src/ran2.c +++ b/fftma_module/gen/lib_src/ran2.c @@ -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); }