diff --git a/fftma_module/gen/example.py b/fftma_module/gen/example.py index 3202101..28a3cb7 100644 --- a/fftma_module/gen/example.py +++ b/fftma_module/gen/example.py @@ -27,5 +27,5 @@ mean=15.3245987 variance=3.5682389 typ=3 -k=gen(nx, ny, nz, dx, dy, dz, seed, variograms, mean, variance, typ, 8) +k=gen(nx, ny, nz, dx, dy, dz, seed, variograms, mean, variance, typ) np.save(f"out_{N}.npy",k) diff --git a/fftma_module/gen/include/Py_py-api.h b/fftma_module/gen/include/Py_py-api.h index 3043ed9..8bf84a9 100644 --- a/fftma_module/gen/include/Py_py-api.h +++ b/fftma_module/gen/include/Py_py-api.h @@ -11,5 +11,5 @@ #include #include -int Py_getvalues(PyObject*, long*, struct grid_mod*, struct vario_mod*, struct statistic_mod*, int*); -void Py_kgeneration(long, struct grid_mod, struct statistic_mod, struct vario_mod, struct realization_mod*, struct realization_mod*, int[3], int); \ No newline at end of file +int Py_getvalues(PyObject*, long*, struct grid_mod*, struct vario_mod*, struct statistic_mod*); +void Py_kgeneration(long, struct grid_mod, struct statistic_mod, struct vario_mod, struct realization_mod*, struct realization_mod*, int[3]); diff --git a/fftma_module/gen/include/condor.h b/fftma_module/gen/include/condor.h index 869144b..310a594 100644 --- a/fftma_module/gen/include/condor.h +++ b/fftma_module/gen/include/condor.h @@ -102,7 +102,7 @@ void FFTMA_gradient(struct vario_mod variogram, struct grid_mod grid, int n[3], /* n: number of components in the vector */ /*output: */ /* realization: structure defining the realization*/ -void generate(long* seed, int n, struct realization_mod* realization, int cores); +void generate(long* seed, int n, struct realization_mod* realization); void ikrig(int option, struct statfacies_mod facies, int kk, struct welldata_mod data, struct variotable_mod variogram, struct grid_mod grid, float* krigout); diff --git a/fftma_module/gen/include/geostat.h b/fftma_module/gen/include/geostat.h index f1d2922..cbce3f9 100644 --- a/fftma_module/gen/include/geostat.h +++ b/fftma_module/gen/include/geostat.h @@ -299,7 +299,7 @@ struct realization_mod { void axes(double* ap, double* scf, int N); /*cardsin covariance value for lag h*/ -double cardsin(double h, int cores); +double cardsin(double h); /*Cholesky decomposition of matrix C */ /* C : symetric positive-definite matrix recorded */ @@ -327,7 +327,7 @@ void coordinates(int maille, int i[3], struct grid_mod grid); /*variogram: structure defined above */ /*grid: structure defined above */ /*n: number of gridblocks along X,Y and Z*/ -void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mod grid, int n[3], int cores); +void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mod grid, int n[3]); /*computation of the covariance matrix for the well data*/ /*well coordinates are given as a number of cells */ @@ -357,10 +357,10 @@ void cov_matrix(double* C, struct vario_mod variogram, struct welldata_mod well, /*dj: distance along the Y axis */ /*dk: distance along the Z axis */ /* The returned value is the computed covariance value */ -double cov_value(struct vario_mod variogram, double di, double dj, double dk, int cores); +double cov_value(struct vario_mod variogram, double di, double dj, double dk); /*cubic covariance value for lag h*/ -double cubic(double h, int cores); +double cubic(double h); /*truncation of the power spectrum to remove */ /*high frequencies - isotropic case */ @@ -403,7 +403,7 @@ double exponential(double h); /*workr: utility real part vector for storage */ /*worki: utility imaginary part vector for storage */ /*The transformed data are returned in datar and datai*/ -void fourt(chunk_array_t* datar, chunk_array_t* datai, int nn[3], int ndim, int ifrwd, int icplx, double* workr, double* worki, int cores); +void fourt(chunk_array_t* datar, chunk_array_t* datai, int nn[3], int ndim, int ifrwd, int icplx, double* workr, double* worki); /*calculates F(x) = (1/a)*exp(-x*x/2)*/ double funtrun1(double x); @@ -412,7 +412,7 @@ double funtrun1(double x); float G(float x); /*gamma covariance value for lag h and exponent alpha*/ -double gammf(double h, double alpha, int cores); +double gammf(double h, double alpha); /*returns the value ln(G(x))*/ float gammln(float xx); @@ -424,7 +424,7 @@ float gammp(float a, float x); /*and unit variance, using ran1(idum) as the source */ /*of uniform deviates */ /*idum: seed */ -double gasdev(long* idum, long* idum2, long* iy, long* iv, int cores); +double gasdev(long* idum, long* idum2, long* iy, long* iv); /*gaussian covariance value for lag h*/ double gaussian(double h); @@ -479,7 +479,7 @@ void gradual(struct grad_mod grad, float* Zo, float* Z, float* Zfinal, int n, st /*n: vector with the number of cells along the */ /* 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], int cores); +void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3]); /*incomplete gamma function evaluated by its series*/ /*representation as gamser, also returns ln(G(a)) */ @@ -504,7 +504,7 @@ void krig_stat(float* b, int n, struct vario_mod variogram, struct welldata_mod /*i: considered direction */ /*scf: correlation length */ /*ap: normalized anisotropy axes */ -int length(int N, int i, double* scf, double* ap, double D, int Nvari, int cores); +int length(int N, int i, double* scf, double* ap, double D, int Nvari); /*calculates L.Z/ /* L : lower triangular matrix recorded */ @@ -518,7 +518,7 @@ int length(int N, int i, double* scf, double* ap, double D, int Nvari, int cores void LtimeZ(double* L, float* Z, float* b, int n); /*determines the greatest prime factor of an integer*/ -int maxfactor(int n, int cores); +int maxfactor(int n); /*metrop returns a boolean varible that issues a */ /*verdict on whether to accept a reconfiguration */ @@ -544,7 +544,7 @@ double power(double h, double alpha); /*generates uniform deviates between 0 and 1*/ /*idum: seed */ -double ran2(long* idum, long* idum2, long* iy, long* iv, int cores); +double ran2(long* idum, long* idum2, long* iy, long* iv); /*calculates bt.b */ /* b : vector, bi, i = [0...n-1] */ diff --git a/fftma_module/gen/include/toolsFFTMA.h b/fftma_module/gen/include/toolsFFTMA.h index 2c6cde7..6410337 100644 --- a/fftma_module/gen/include/toolsFFTMA.h +++ b/fftma_module/gen/include/toolsFFTMA.h @@ -37,7 +37,7 @@ /*realout4: structure defining a yvelocity field */ /*realout5: structure defining a zvelocity field */ -void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct realization_mod* realin, struct realization_mod* realout, long* seed, int cores); +void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct realization_mod* realin, struct realization_mod* realout, long* seed); /* prebuild_gwn */ /* Produce a first construction in real space of the Gaussian white noise */ diff --git a/fftma_module/gen/lib_src/Py_getvalues.c b/fftma_module/gen/lib_src/Py_getvalues.c index 9303e84..7bb857c 100644 --- a/fftma_module/gen/lib_src/Py_getvalues.c +++ b/fftma_module/gen/lib_src/Py_getvalues.c @@ -1,6 +1,5 @@ #include "Py_py-api.h" #include "genlib.h" -#include "log.h" #include "geostat.h" #include "pressure.h" #include "simpio.h" @@ -42,29 +41,25 @@ #endif #endif -int Py_getvalues(PyObject* args, long* seed, struct grid_mod* grid, struct vario_mod* variogram, struct statistic_mod* stat, int* cores) { +int Py_getvalues(PyObject* args, long* seed, struct grid_mod* grid, struct vario_mod* variogram, struct statistic_mod* stat) { clock_t t = clock(); - - log_info("RESULT = in progress"); - int i, varioNargs = 12, j = 0; PyObject* listvario; PyObject* vgr; + //char* gwnfilename; stat->nblock_mean = 1; stat->nblock_var = 1; stat->mean = (double*)malloc(stat->nblock_mean * sizeof(double)); - if (stat->mean == NULL) { + if (stat->mean == NULL) return 0; - } stat->variance = (double*)malloc(stat->nblock_var * sizeof(double)); if (stat->variance == NULL) { free(stat->mean); - log_error("RESULT = failed"); return 0; } - if (!PyArg_ParseTuple(args, "iiidddlO!ddii", /*"iiidddslO!ddi",*/ + if (!PyArg_ParseTuple(args, "iiidddlO!ddi", /*"iiidddslO!ddi",*/ &(grid->NX), &(grid->NY), &(grid->NZ), @@ -77,8 +72,7 @@ int Py_getvalues(PyObject* args, long* seed, struct grid_mod* grid, struct vario &listvario, stat->mean + 0, stat->variance + 0, - &(stat->type), - cores)) { + &(stat->type))) { free(stat->mean); free(stat->variance); return 0; @@ -90,7 +84,6 @@ int Py_getvalues(PyObject* args, long* seed, struct grid_mod* grid, struct vario if (variogram->var == NULL) { free(stat->mean); free(stat->variance); - log_error("RESULT = failed"); return 0; } variogram->vario = (int*)malloc(variogram->Nvario * sizeof(int)); @@ -98,7 +91,6 @@ int Py_getvalues(PyObject* args, long* seed, struct grid_mod* grid, struct vario free(stat->mean); free(stat->variance); free(variogram->var); - log_error("RESULT = failed"); return 0; } variogram->alpha = (double*)malloc(variogram->Nvario * sizeof(double)); @@ -107,7 +99,6 @@ int Py_getvalues(PyObject* args, long* seed, struct grid_mod* grid, struct vario free(stat->variance); free(variogram->var); free(variogram->vario); - log_error("RESULT = failed"); return 0; } variogram->scf = (double*)malloc(3 * variogram->Nvario * sizeof(double)); @@ -127,7 +118,6 @@ int Py_getvalues(PyObject* args, long* seed, struct grid_mod* grid, struct vario free(variogram->vario); free(variogram->alpha); free(variogram->scf); - log_error("RESULT = failed"); return 0; } for (i = 0; i < variogram->Nvario; i++) { @@ -148,9 +138,9 @@ int Py_getvalues(PyObject* args, long* seed, struct grid_mod* grid, struct vario (variogram->ap)[i * 9 + 4] = PyFloat_AsDouble(PyTuple_GetItem(vgr, j++)); (variogram->ap)[i * 9 + 5] = PyFloat_AsDouble(PyTuple_GetItem(vgr, j++)); } + t = clock() - t; double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time - log_info("RESULT = success, ELAPSED = %f seconds", time_taken); return 1; -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/Py_kgeneration.c b/fftma_module/gen/lib_src/Py_kgeneration.c index a423110..af65bc7 100644 --- a/fftma_module/gen/lib_src/Py_kgeneration.c +++ b/fftma_module/gen/lib_src/Py_kgeneration.c @@ -4,8 +4,6 @@ #include "simpio.h" #include "toolsFFTMA.h" #include "toolsIO.h" -#include "log.h" -#include "memory.h" #include #include #include @@ -19,12 +17,7 @@ /* Z is the GWN with 0-mean and 1-variance */ /* 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(); - +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 i, N; int typelog; @@ -34,42 +27,14 @@ void Py_kgeneration(long seed, struct grid_mod grid, struct statistic_mod stat, n[1] = 0; n[2] = 0; - log_info("RESULT = in progress, N = %d", N); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - - generate(&seed, N, Z, cores); + generate(&seed, N, Z); /*FFTMA*/ - FFTMA2(variogram, grid, n, Z, Y, &seed, cores); + FFTMA2(variogram, grid, n, Z, Y, &seed); /* make a log normal realization */ if (stat.type == 1 || stat.type == 2) { typelog = stat.type + 2; nor2log(Y, typelog, Y); } - - 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); - - 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); -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/build_real.c b/fftma_module/gen/lib_src/build_real.c index a878878..6f57c3c 100644 --- a/fftma_module/gen/lib_src/build_real.c +++ b/fftma_module/gen/lib_src/build_real.c @@ -7,8 +7,6 @@ #include #include #include "chunk_array.h" -#include "log.h" -#include "memory.h" /* build_real */ /* build a realization in the spectral domain */ @@ -22,24 +20,10 @@ /*realization: vector defining the real part */ /*ireal: vector defining the i-part */ -void build_real(int n[3], int NTOT, chunk_array_t* covar, chunk_array_t* realization, chunk_array_t* ireal, int cores) { - double* used_ram_t0 = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_t0); - +void build_real(int n[3], int NTOT, chunk_array_t* covar, chunk_array_t* realization, chunk_array_t* ireal) { 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]); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - - clock_t t = clock(); - /*decomposition and multiplication in the spectral domain*/ for (k = 1; k <= n[2]; k++) { for (j = 1; j <= n[1]; j++) { @@ -61,23 +45,4 @@ void build_real(int n[3], int NTOT, chunk_array_t* covar, chunk_array_t* realiza } } } - - 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); - - 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); -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/cardsin.c b/fftma_module/gen/lib_src/cardsin.c index f62d762..e0b1ce6 100644 --- a/fftma_module/gen/lib_src/cardsin.c +++ b/fftma_module/gen/lib_src/cardsin.c @@ -1,26 +1,10 @@ #include "genlib.h" -#include "log.h" -#include "memory.h" #include #include #include /*cardsin covariance function*/ -double cardsin(double h, int cores) { - double* used_ram_t0 = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_t0); - - clock_t t = clock(); - - log_info("RESULT = in progress, h = %f", h); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - +double cardsin(double h) { float delta = 20.371; double z; @@ -31,24 +15,5 @@ double cardsin(double h, int cores) { z = 1.; } - 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); - - 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); - - free(used_ram_t0); - free(used_ram_tf); - return z; -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/cgrid.c b/fftma_module/gen/lib_src/cgrid.c index 3d4d9d1..e1b0086 100644 --- a/fftma_module/gen/lib_src/cgrid.c +++ b/fftma_module/gen/lib_src/cgrid.c @@ -1,6 +1,4 @@ #include "geostat.h" -#include "log.h" -#include "memory.h" #include #include @@ -12,25 +10,10 @@ /*n: vector with the number of cells along the */ /* 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], int cores) { - double* used_ram_t0 = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_t0); - - clock_t t = clock(); - +void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3]) { int i, N; double D; - - log_info("RESULT = in progress"); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - - + if (n == NULL || n[0] == 0 || n[1] == 0 || n[2] == 0) { for (i = 0; i < 3; i++) { switch (i) { @@ -47,31 +30,11 @@ void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3], int cores D = grid.DZ; break; } - n[i] = length(N, i, variogram.scf, variogram.ap, D, variogram.Nvario, cores); + n[i] = length(N, i, variogram.scf, variogram.ap, D, variogram.Nvario); } } else { if ((n[0] < grid.NX) || (n[1] < grid.NY) || (n[2] < grid.NZ)) { - log_error("RESULT = failed - Indicated dimensions are inappropriate in cgrid"); exit; } } - - 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); - - 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); - - free(used_ram_t0); - free(used_ram_tf); -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/clean_real.c b/fftma_module/gen/lib_src/clean_real.c index 0b9b1a5..ed0e3f0 100644 --- a/fftma_module/gen/lib_src/clean_real.c +++ b/fftma_module/gen/lib_src/clean_real.c @@ -7,15 +7,8 @@ #include #include #include -#include "log.h" -#include "memory.h" - -void clean_real(struct realization_mod* realin, int n[3], struct grid_mod grid, chunk_array_t* vectorresult, struct realization_mod* realout, int cores) { - double* used_ram_t0 = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_t0); - - clock_t t = clock(); +void clean_real(struct realization_mod* realin, int n[3], struct grid_mod grid, chunk_array_t* vectorresult, struct realization_mod* realout) { int i, j, k, maille0, maille1; double NTOT; @@ -23,19 +16,9 @@ void clean_real(struct realization_mod* realin, int n[3], struct grid_mod grid, /*is the output realization already allocated?*/ /*if not, memory allocation*/ - log_info("RESULT = in progress, NTOT = %f", NTOT); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - if (realout->vector == NULL || realout->n != realin->n) { realout->vector = (double*)malloc(realin->n * sizeof(double)); if (realout->vector == NULL) { - log_error("RESULT = failed - No memory available"); exit; } } @@ -55,23 +38,4 @@ 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* used_ram_tf = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_tf); - - 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])); - } - - 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); -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/cov_value.c b/fftma_module/gen/lib_src/cov_value.c index 06594c2..abe0c3f 100644 --- a/fftma_module/gen/lib_src/cov_value.c +++ b/fftma_module/gen/lib_src/cov_value.c @@ -1,26 +1,10 @@ #include "genlib.h" #include "geostat.h" -#include "log.h" -#include "memory.h" #include #include /*selection of model covariance*/ -double cov_value(struct vario_mod variogram, double di, double dj, double dk, int cores) { - 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); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - +double cov_value(struct vario_mod variogram, double di, double dj, double dk) { double hx, hy, hz, h; double cov; int k; @@ -64,24 +48,5 @@ double cov_value(struct vario_mod variogram, double di, double dj, double dk, in break; } } - 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); - - log_info("RESULT = success, cov = %f, hx = %f, hy = %f, hz = %f, h = %f , ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", cov, hx, hy, hz, h, time_taken, *used_ram_tf - *used_ram_t0); - - free(used_ram_t0); - free(used_ram_tf); - return cov; -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/covariance.c b/fftma_module/gen/lib_src/covariance.c index 5e30ee9..a96a652 100644 --- a/fftma_module/gen/lib_src/covariance.c +++ b/fftma_module/gen/lib_src/covariance.c @@ -1,29 +1,13 @@ #include "geostat.h" #include "chunk_array.h" #include -#include "log.h" -#include "memory.h" /*builds the sampled covariance function*/ /*dimensions are even*/ -void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mod mesh, int n[3], int cores) { - double* used_ram_t0 = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_t0); - - clock_t t = clock(); - +void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mod mesh, int n[3]) { int i, j, k, maille, n2[3], symmetric; double di, dj, dk; - log_info("RESULT = in progress"); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - for (i = 0; i < 3; i++) n2[i] = n[i] / 2; @@ -36,7 +20,7 @@ void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mo di = (double)i * mesh.DX; dj = (double)j * mesh.DY; dk = (double)k * mesh.DZ; - chunk_array_save(covar, maille, (double)cov_value(variogram, di, dj, dk, cores)); + chunk_array_save(covar, maille, (double)cov_value(variogram, di, dj, dk)); if (k > 0 && k < n2[2] && j > 0 && j < n2[1] && i > 0 && i < n2[0]) { /*area 2*/ @@ -52,7 +36,7 @@ void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mo dj = (double)j * mesh.DY; dk = (double)k * mesh.DZ; maille = 1 + (n[0] - i) + n[0] * (j + n[1] * k); - chunk_array_save(covar, maille, (double)cov_value(variogram, di, dj, dk, cores)); + chunk_array_save(covar, maille, (double)cov_value(variogram, di, dj, dk)); } if (k > 0 && k < n2[2] && j > 0 && j < n2[1]) { @@ -69,7 +53,7 @@ void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mo dj = -(double)j * mesh.DY; dk = (double)k * mesh.DZ; maille = 1 + (n[0] - i) + n[0] * (n[1] - j + n[1] * k); - chunk_array_save(covar, maille, (double)cov_value(variogram, di, dj, dk, cores)); + chunk_array_save(covar, maille, (double)cov_value(variogram, di, dj, dk)); } if (k > 0 && k < n2[2]) { @@ -86,7 +70,7 @@ void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mo dj = -(double)j * mesh.DY; dk = (double)k * mesh.DZ; maille = 1 + i + n[0] * (n[1] - j + n[1] * k); - chunk_array_save(covar, maille, (double)cov_value(variogram, di, dj, dk, cores)); + chunk_array_save(covar, maille, (double)cov_value(variogram, di, dj, dk)); } if (k > 0 && k < n2[2] && i > 0 && i < n2[0]) { @@ -99,23 +83,4 @@ void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mo } } } - - 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); - - 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); - - free(used_ram_t0); - free(used_ram_tf); -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/cubic.c b/fftma_module/gen/lib_src/cubic.c index 14d4bac..a371e76 100644 --- a/fftma_module/gen/lib_src/cubic.c +++ b/fftma_module/gen/lib_src/cubic.c @@ -1,26 +1,10 @@ #include "genlib.h" -#include "log.h" -#include "memory.h" #include #include #include /*cubic covariance function*/ -double cubic(double h, int cores) { - double* used_ram_t0 = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_t0); - - clock_t t = clock(); - - log_info("RESULT = in progress, h = %f", h); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - +double cubic(double h) { double z; if (h >= 1.) { @@ -28,25 +12,6 @@ double cubic(double h, int cores) { } else { z = 1. - 7. * (double)(h * h) + (35. / 4.) * (double)(h * h * h) - 3.5 * (double)(h * h * h * h * h) + .75 * (double)(h * h * h * h * h * h * h); } - - 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); - - 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); - - free(used_ram_t0); - free(used_ram_tf); - + return z; -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/exponential.c b/fftma_module/gen/lib_src/exponential.c index a690cd0..af1ef27 100644 --- a/fftma_module/gen/lib_src/exponential.c +++ b/fftma_module/gen/lib_src/exponential.c @@ -1,10 +1,8 @@ #include "genlib.h" #include #include -#include "log.h" /*exponential covariance function*/ double exponential(double h) { - log_info("RESULT = in progress, h = %f", h); return (exp(-3. * (double)h)); } diff --git a/fftma_module/gen/lib_src/fftma2.c b/fftma_module/gen/lib_src/fftma2.c index 90a1b3f..622d15e 100644 --- a/fftma_module/gen/lib_src/fftma2.c +++ b/fftma_module/gen/lib_src/fftma2.c @@ -4,8 +4,6 @@ #include #include #include -#include "log.h" -#include "memory.h" /*FAST FOURIER TRANSFORM MOVING AVERAGE METHOD */ /*Turns a Gaussian white noise vector into a */ @@ -25,21 +23,7 @@ /*output: */ /*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, long* seed, int cores) { - double* used_ram_t0 = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_t0); - - clock_t t = clock(); - - log_info("RESULT = in progress"); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - +void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct realization_mod* realin, struct realization_mod* realout, long* seed) { int NTOT, i, j, k, NMAX, NDIM, ntot, nmax, NXYZ, nxyz; int solver; double temp; @@ -50,7 +34,7 @@ void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct r axes(variogram.ap, variogram.scf, variogram.Nvario); /*pseudo-grid definition*/ - cgrid(variogram, grid, n, cores); + cgrid(variogram, grid, n); /*constant definition*/ NTOT = n[0] * n[1] * n[2]; @@ -79,33 +63,30 @@ void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct r testmemory(worki); /*covariance function creation*/ - covariance(covar, variogram, grid, n, cores); + covariance(covar, variogram, grid, n); chunk_array_flush(covar); /*power spectrum*/ - fourt(covar, ireal, n, NDIM, 1, 0, workr, worki, cores); + fourt(covar, ireal, n, NDIM, 1, 0, workr, worki); chunk_array_flush(covar); chunk_array_flush(ireal); /*organization of the input Gaussian white noise*/ solver = 0; - prebuild_gwn(grid, n, realin, realization, solver, seed, cores); + prebuild_gwn(grid, n, realin, realization, solver, seed); chunk_array_flush(realization); /*forward fourier transform of the GWN*/ - fourt(realization, ireal, n, NDIM, 1, 0, workr, worki, cores); + fourt(realization, ireal, n, NDIM, 1, 0, workr, worki); chunk_array_flush(realization); chunk_array_flush(ireal); /* build realization in spectral domain */ - build_real(n, NTOT, covar, realization, ireal, cores); - - double* used_ram_tf = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_tf); + build_real(n, NTOT, covar, realization, ireal); chunk_array_flush(realization); @@ -113,7 +94,7 @@ void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct r remove("covar.txt"); /*backward fourier transform*/ - fourt(realization, ireal, n, NDIM, 0, 1, workr, worki, cores); + fourt(realization, ireal, n, NDIM, 0, 1, workr, worki); chunk_array_flush(realization); chunk_array_flush(ireal); @@ -125,21 +106,5 @@ void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct r free(worki); /*output realization*/ - clean_real(realin, n, grid, realization, realout, cores); - - 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])); - } - - 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); -} \ No newline at end of file + clean_real(realin, n, grid, realization, realout); +} diff --git a/fftma_module/gen/lib_src/fourt.c b/fftma_module/gen/lib_src/fourt.c index 7465be9..59cde2a 100644 --- a/fftma_module/gen/lib_src/fourt.c +++ b/fftma_module/gen/lib_src/fourt.c @@ -2,8 +2,6 @@ #include #include #include "chunk_array.h" -#include "log.h" -#include "memory.h" /*fast fourier transform */ /* THE COOLEY-TUKEY FAST FOURIER TRANSFORM */ @@ -93,21 +91,7 @@ /* PROGRAM MODIFIED FROM A SUBROUTINE OF BRENNER */ /* 10-06-2000, MLR */ -void fourt(chunk_array_t* datar, chunk_array_t* datai, int nn[3], int ndim, int ifrwd, int icplx, double* workr, double* worki, int cores) { - double* used_ram_t0 = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_t0); - - clock_t t = clock(); - - log_info("RESULT = in progress"); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - +void fourt(chunk_array_t* datar, chunk_array_t* datai, int nn[3], int ndim, int ifrwd, int icplx, double* workr, double* worki) { int ifact[21], ntot, idim, np1, n, np2, m, ntwo, iff, idiv, iquot, irem, inon2, non2p, np0, nprev, icase, ifmin, i, j, jmax, np2hf, i2, i1max, i3, j3, i1, ifp1, ifp2, i2max, i1rng, istep, imin, imax, mmax, mmin, mstep, j1, j2max, j2, jmin, j3max, nhalf; double theta, wstpr, wstpi, wminr, wmini, wr, wi, wtemp, thetm, wmstr, wmsti, twowr, sr, si, oldsr, oldsi, stmpr, stmpi, tempr, tempi, difi, difr, sumr, sumi, TWOPI = 6.283185307179586476925286766559; double valueri, valueri1, valueri3, valueii3, valuerj3, valueij3, valuerj, valueij, valueii, valuerimin, valueiimin, valuei1, valuer1; @@ -673,23 +657,5 @@ void fourt(chunk_array_t* datar, chunk_array_t* datai, int nn[3], int ndim, int np1 = np2; nprev = n; } -L920: - t = clock() - t; - double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time - - double* used_ram_tf = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_tf); - - 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])); - } - - log_info("RESULT = success, ELAPSED = %f, DIF USED VIRTUAL MEM = %5.1f MB", time_taken, *used_ram_tf - *used_ram_t0); - - free(used_ram_t0); - free(used_ram_tf); -} \ No newline at end of file +L920: return; +} diff --git a/fftma_module/gen/lib_src/gammf.c b/fftma_module/gen/lib_src/gammf.c index 1861521..b4ea73e 100644 --- a/fftma_module/gen/lib_src/gammf.c +++ b/fftma_module/gen/lib_src/gammf.c @@ -1,50 +1,15 @@ #include "genlib.h" -#include "log.h" -#include "memory.h" #include #include #include /*gamma covariance function*/ -double gammf(double h, double alpha, int cores) { - 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); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - +double gammf(double h, double alpha) { float delta; double z; delta = pow(20., 1. / alpha) - 1.; z = 1. / (double)(pow(1. + h * delta, alpha)); - - 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_t0); - - 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; -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/gasdev.c b/fftma_module/gen/lib_src/gasdev.c index b7141cd..f295bd5 100644 --- a/fftma_module/gen/lib_src/gasdev.c +++ b/fftma_module/gen/lib_src/gasdev.c @@ -1,38 +1,22 @@ #include "genlib.h" -#include "log.h" -#include "memory.h" #include #include #define NTAB 32 -double gasdev(long* idum, long* idum2, long* iy, long iv[NTAB], int cores) { +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); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - - double ran2(long* idum, long* idum2, long* iy, long iv[NTAB], int cores); + double ran2(long* idum, long* idum2, long* iy, long iv[NTAB]); static int iset = 0; static double gset; double fac, rsq, v1, v2; if (iset == 0) { do { - v1 = 2.0 * ran2(idum, idum2, iy, iv, cores) - 1.0; - v2 = 2.0 * ran2(idum, idum2, iy, iv, cores) - 1.0; + v1 = 2.0 * ran2(idum, idum2, iy, iv) - 1.0; + v2 = 2.0 * ran2(idum, idum2, iy, iv) - 1.0; rsq = v1 * v1 + v2 * v2; } while (rsq >= 1.0 || rsq == 0.0); @@ -40,48 +24,9 @@ double gasdev(long* idum, long* idum2, long* iy, long iv[NTAB], int cores) { gset = v1 * fac; iset = 1; - 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); - - 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(used_ram_t0); - free(used_ram_tf); - return (v2 * fac); } else { iset = 0; - - 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); - - 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(used_ram_t0); - free(used_ram_tf); - return gset; } -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/gaussian.c b/fftma_module/gen/lib_src/gaussian.c index e3a0fcb..98bba6e 100644 --- a/fftma_module/gen/lib_src/gaussian.c +++ b/fftma_module/gen/lib_src/gaussian.c @@ -1,10 +1,8 @@ #include "genlib.h" #include #include -#include "log.h" /*gaussian covariance function*/ double gaussian(double h) { - log_info("RESULT = in progress, h = %f", h); return (exp(-3. * (double)(h * h))); } diff --git a/fftma_module/gen/lib_src/generate.c b/fftma_module/gen/lib_src/generate.c index e784119..8387b87 100644 --- a/fftma_module/gen/lib_src/generate.c +++ b/fftma_module/gen/lib_src/generate.c @@ -2,8 +2,6 @@ #include #include #include -#include "log.h" -#include "memory.h" /* GENERATION OF A GAUSSIAN WHITE NOISE VECTOR */ /*input: */ @@ -12,25 +10,14 @@ /*output: */ /* 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); - - log_info("RESULT = in progress, n = %d", n); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - - clock_t t = clock(); - +void generate(long* seed, int n, struct realization_mod* realization) { int i; long idum2 = 123456789, iy = 0; + long* iv; int iset = 0; + iv = (long*)malloc(NTAB * sizeof(long)); + /*negative seed*/ if (*seed > 0.0) *seed = -(*seed); @@ -39,21 +26,5 @@ void generate(long* seed, int n, struct realization_mod* realization, int cores) (*realization).n = n; (*realization).code = 0; - 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); - 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); -} \ No newline at end of file + free(iv); +} diff --git a/fftma_module/gen/lib_src/geostat.h b/fftma_module/gen/lib_src/geostat.h index 0ca813e..94f2865 100644 --- a/fftma_module/gen/lib_src/geostat.h +++ b/fftma_module/gen/lib_src/geostat.h @@ -328,7 +328,7 @@ void coordinates(int maille, int i[3], struct grid_mod grid); /*variogram: structure defined above */ /*grid: structure defined above */ /*n: number of gridblocks along X,Y and Z*/ -void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mod grid, int n[3], int cores); +void covariance(chunk_array_t* covar, struct vario_mod variogram, struct grid_mod grid, int n[3]); /*computation of the covariance matrix for the well data*/ /*well coordinates are given as a number of cells */ @@ -358,7 +358,7 @@ void cov_matrix(double* C, struct vario_mod variogram, struct welldata_mod well, /*dj: distance along the Y axis */ /*dk: distance along the Z axis */ /* The returned value is the computed covariance value */ -double cov_value(struct vario_mod variogram, double di, double dj, double dk, int cores); +double cov_value(struct vario_mod variogram, double di, double dj, double dk); /*cubic covariance value for lag h*/ double cubic(double h); @@ -404,7 +404,7 @@ double exponential(double h); /*workr: utility real part vector for storage */ /*worki: utility imaginary part vector for storage */ /*The transformed data are returned in datar and datai*/ -void fourt(chunk_array_t* datar, chunk_array_t* datai, int nn[3], int ndim, int ifrwd, int icplx, double* workr, double* worki, int cores); +void fourt(chunk_array_t* datar, chunk_array_t* datai, int nn[3], int ndim, int ifrwd, int icplx, double* workr, double* worki); /*calculates F(x) = (1/a)*exp(-x*x/2)*/ double funtrun1(double x); @@ -425,7 +425,7 @@ float gammp(float a, float x); /*and unit variance, using ran1(idum) as the source */ /*of uniform deviates */ /*idum: seed */ -double gasdev(long* idum, long* idum2, long* iy, long* iv, int cores); +double gasdev(long* idum, long* idum2, long* iy, long* iv); /*gaussian covariance value for lag h*/ double gaussian(double h); @@ -480,7 +480,7 @@ void gradual(struct grad_mod grad, float* Zo, float* Z, float* Zfinal, int n, st /*n: vector with the number of cells along the */ /* 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], int cores); +void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3]); /*incomplete gamma function evaluated by its series*/ /*representation as gamser, also returns ln(G(a)) */ @@ -505,7 +505,7 @@ void krig_stat(float* b, int n, struct vario_mod variogram, struct welldata_mod /*i: considered direction */ /*scf: correlation length */ /*ap: normalized anisotropy axes */ -int length(int N, int i, double* scf, double* ap, double D, int Nvari, int cores); +int length(int N, int i, double* scf, double* ap, double D, int Nvari); /*calculates L.Z/ /* L : lower triangular matrix recorded */ @@ -519,7 +519,7 @@ int length(int N, int i, double* scf, double* ap, double D, int Nvari, int cores void LtimeZ(double* L, float* Z, float* b, int n); /*determines the greatest prime factor of an integer*/ -int maxfactor(int n, int cores); +int maxfactor(int n); /*metrop returns a boolean varible that issues a */ /*verdict on whether to accept a reconfiguration */ @@ -545,7 +545,7 @@ double power(double h, double alpha); /*generates uniform deviates between 0 and 1*/ /*idum: seed */ -double ran2(long* idum, long* idum2, long* iy, long* iv, int cores); +double ran2(long* idum, long* idum2, long* iy, long* iv); /*calculates bt.b */ /* b : vector, bi, i = [0...n-1] */ @@ -611,4 +611,4 @@ void vf2gthres(struct statfacies_mod facies, float* thresholds); void polint(float xa[], float ya[], int n, float x, float* y, float* dy); -#endif \ No newline at end of file +#endif diff --git a/fftma_module/gen/lib_src/length.c b/fftma_module/gen/lib_src/length.c index 3cb90fe..d7f4ce0 100644 --- a/fftma_module/gen/lib_src/length.c +++ b/fftma_module/gen/lib_src/length.c @@ -1,25 +1,9 @@ -#include "log.h" -#include "memory.h" #include #include /* compute the length for one dimension*/ -int length(int N, int i, double* scf, double* ap, double D, int Nvari, int cores) { - 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); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - - int maxfactor(int n, int cores); +int length(int N, int i, double* scf, double* ap, double D, int Nvari) { + int maxfactor(int n); double temp1, temp2; int n, j, k, nmax; int nlimit = 13; @@ -45,31 +29,12 @@ int length(int N, int i, double* scf, double* ap, double D, int Nvari, int cores } if ((n % 2) != 0) n = n + 1; - nmax = maxfactor(n, cores); + nmax = maxfactor(n); while (nmax > nlimit) { n += 2; - nmax = maxfactor(n, cores); + nmax = maxfactor(n); } } - 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); - - 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(used_ram_t0); - free(used_ram_tf); - return n; -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/log.c b/fftma_module/gen/lib_src/log.c deleted file mode 100644 index 1ef1b78..0000000 --- a/fftma_module/gen/lib_src/log.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2020 rxi - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include "log.h" -#include - -#define MAX_CALLBACKS 32 - -typedef struct { - log_LogFn fn; - void *udata; - int level; -} Callback; - -static struct { - void *udata; - log_LockFn lock; - int level; - bool quiet; - Callback callbacks[MAX_CALLBACKS]; -} L; - - -static const char *level_strings[] = { - "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL" -}; - -#ifdef LOG_USE_COLOR -static const char *level_colors[] = { - "\x1b[94m", "\x1b[36m", "\x1b[32m", "\x1b[33m", "\x1b[31m", "\x1b[35m" -}; -#endif - - -static void stdout_callback(log_Event *ev) { - char buf[16]; - buf[strftime(buf, sizeof(buf), "%H:%M:%S", ev->time)] = '\0'; -#ifdef LOG_USE_COLOR - fprintf( - ev->udata, "%s %s%-5s\x1b[0m \x1b[0m%s:%d:\x1b[0m ", - buf, level_colors[ev->level], level_strings[ev->level], - ev->file, ev->line); -#else - fprintf( - ev->udata, "%s %-5s %s:%d: ", - buf, level_strings[ev->level], ev->file, ev->line); -#endif - vfprintf(ev->udata, ev->fmt, ev->ap); - fprintf(ev->udata, "\n"); - fflush(ev->udata); -} - - -static void file_callback(log_Event *ev) { - char buf[64]; - buf[strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ev->time)] = '\0'; - fprintf( - ev->udata, "%s %-5s %s:%d: ", - buf, level_strings[ev->level], ev->file, ev->line); - vfprintf(ev->udata, ev->fmt, ev->ap); - fprintf(ev->udata, "\n"); - fflush(ev->udata); -} - - -static void lock(void) { - if (L.lock) { L.lock(true, L.udata); } -} - - -static void unlock(void) { - if (L.lock) { L.lock(false, L.udata); } -} - - -const char* log_level_string(int level) { - return level_strings[level]; -} - - -void log_set_lock(log_LockFn fn, void *udata) { - L.lock = fn; - L.udata = udata; -} - - -void log_set_level(int level) { - L.level = level; -} - - -void log_set_quiet(bool enable) { - L.quiet = enable; -} - - -int log_add_callback(log_LogFn fn, void *udata, int level) { - for (int i = 0; i < MAX_CALLBACKS; i++) { - if (!L.callbacks[i].fn) { - L.callbacks[i] = (Callback) { fn, udata, level }; - return 0; - } - } - return -1; -} - - -int log_add_fp(FILE *fp, int level) { - return log_add_callback(file_callback, fp, level); -} - - -static void init_event(log_Event *ev, void *udata) { - if (!ev->time) { - time_t t = time(NULL); - ev->time = localtime(&t); - } - ev->udata = udata; -} - - -void log_log(int level, const char *file, int line, const char *fmt, ...) { - log_Event ev = { - .fmt = fmt, - .file = file, - .line = line, - .level = level, - }; - - char* env_var = getenv("ENV"); - if (env_var != NULL && strcmp("false", env_var) == 0) return; - - char* substr_mem = strstr(fmt, "MEM"); - char* substr_cpu = strstr(fmt, "CPU"); - if (env_var != NULL && strcmp("analysis", env_var) == 0 && substr_mem == NULL && substr_cpu == NULL) return; - - lock(); - - if (!L.quiet && level >= L.level) { - init_event(&ev, stderr); - va_start(ev.ap, fmt); - stdout_callback(&ev); - va_end(ev.ap); - } - - for (int i = 0; i < MAX_CALLBACKS && L.callbacks[i].fn; i++) { - Callback *cb = &L.callbacks[i]; - if (level >= cb->level) { - init_event(&ev, cb->udata); - va_start(ev.ap, fmt); - cb->fn(&ev); - va_end(ev.ap); - } - } - - unlock(); -} \ No newline at end of file diff --git a/fftma_module/gen/lib_src/log.h b/fftma_module/gen/lib_src/log.h deleted file mode 100644 index 326f46c..0000000 --- a/fftma_module/gen/lib_src/log.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2020 rxi - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the MIT license. See `log.c` for details. - */ - -#ifndef LOG_H -#define LOG_H - -#include -#include -#include -#include - -#define LOG_VERSION "0.1.0" - -typedef struct { - va_list ap; - const char *fmt; - const char *file; - struct tm *time; - void *udata; - int line; - int level; -} log_Event; - -typedef void (*log_LogFn)(log_Event *ev); -typedef void (*log_LockFn)(bool lock, void *udata); - -enum { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL }; - -#define log_trace(...) log_log(LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__) -#define log_debug(...) log_log(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__) -#define log_info(...) log_log(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__) -#define log_warn(...) log_log(LOG_WARN, __FILE__, __LINE__, __VA_ARGS__) -#define log_error(...) log_log(LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__) -#define log_fatal(...) log_log(LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__) - -const char* log_level_string(int level); -void log_set_lock(log_LockFn fn, void *udata); -void log_set_level(int level); -void log_set_quiet(bool enable); -int log_add_callback(log_LogFn fn, void *udata, int level); -int log_add_fp(FILE *fp, int level); - -void log_log(int level, const char *file, int line, const char *fmt, ...); - -#endif \ No newline at end of file diff --git a/fftma_module/gen/lib_src/maxfactor.c b/fftma_module/gen/lib_src/maxfactor.c index 8975a05..f950cf2 100644 --- a/fftma_module/gen/lib_src/maxfactor.c +++ b/fftma_module/gen/lib_src/maxfactor.c @@ -1,24 +1,7 @@ #include "genlib.h" -#include "log.h" -#include "memory.h" /*determines the greatest prime factor of an integer*/ -int maxfactor(int n, 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); - log_info("cores = %d", cores); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - +int maxfactor(int n) { int test_fact(int* pnum, int fact, int* pmaxfac); int lnum, fact; int maxfac; @@ -47,24 +30,6 @@ int maxfactor(int n, int cores) { maxfac = lnum; } } - 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); - - 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); - return maxfac; -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/memory.c b/fftma_module/gen/lib_src/memory.c deleted file mode 100644 index 198a5a4..0000000 --- a/fftma_module/gen/lib_src/memory.c +++ /dev/null @@ -1,94 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include "log.h" -#include "memory.h" - -static unsigned long long lastTotalUser, lastTotalUserLow, lastTotalSys, lastTotalIdle; -static clock_t lastCPU, lastSysCPU, lastUserCPU; -static int numProcessors; - -void getTotalVirtualMem(double* total_ram) { - const double megabyte = 1024 * 1024; - struct sysinfo si; - sysinfo(&si); - *total_ram = si.totalram / megabyte; -} - -void getVirtualMemUsed(double* used_ram) { - const double megabyte = 1024 * 1024; - struct sysinfo si; - sysinfo(&si); - *used_ram = (si.totalram - si.freeram) / megabyte; -} - -int parseLine(char* line) { - // This assumes that a digit will be found and the line ends in " Kb". - int i = strlen(line); - const char* p = line; - while (*p <'0' || *p > '9') p++; - line[i-3] = '\0'; - i = atoi(p); - return i; -} - -int getVirtualMemUsedByCurrentProcess() { - FILE* file = fopen("/proc/self/status", "r"); - int result = -1; - char line[128]; - - while (fgets(line, 128, file) != NULL){ - if (strncmp(line, "VmSize:", 7) == 0){ - result = parseLine(line); - break; - } - } - fclose(file); - return result / 1024; -} - -void skip_lines(FILE *fp, int numlines) { - int cnt = 0; - char ch; - while ((cnt < numlines) && ((ch = getc(fp)) != EOF)) { - if (ch == '\n') cnt++; - } -} - -void get_stats(struct cpustat *st, int cpunum) { - FILE *fp = fopen("/proc/stat", "r"); - int lskip = cpunum+1; - skip_lines(fp, lskip); - char cpun[255]; - fscanf(fp, "%s %d %d %d %d %d %d %d", cpun, &(st->t_user), &(st->t_nice), - &(st->t_system), &(st->t_idle), &(st->t_iowait), &(st->t_irq), - &(st->t_softirq)); - fclose(fp); - return; -} - -double calculate_load(struct cpustat *prev, struct cpustat *cur) { - int idle_prev = (prev->t_idle) + (prev->t_iowait); - int idle_cur = (cur->t_idle) + (cur->t_iowait); - - int nidle_prev = (prev->t_user) + (prev->t_nice) + (prev->t_system) + (prev->t_irq) + (prev->t_softirq); - int nidle_cur = (cur->t_user) + (cur->t_nice) + (cur->t_system) + (cur->t_irq) + (cur->t_softirq); - - int total_prev = idle_prev + nidle_prev; - int total_cur = idle_cur + nidle_cur; - - double totald = (double) total_cur - (double) total_prev; - - double idled = (double) idle_cur - (double) idle_prev; - - if (totald == 0 && idled == 0) return 0; - - double cpu_perc = (1000 * (totald - idled) / totald + 1) / 10; - - return cpu_perc; -} \ No newline at end of file diff --git a/fftma_module/gen/lib_src/memory.h b/fftma_module/gen/lib_src/memory.h deleted file mode 100644 index a462325..0000000 --- a/fftma_module/gen/lib_src/memory.h +++ /dev/null @@ -1,24 +0,0 @@ -#include "sys/types.h" -#include "sys/sysinfo.h" -#include "stdlib.h" -#include "stdio.h" -#include "string.h" -#include "sys/times.h" -#include "sys/vtimes.h" - -void getTotalVirtualMem(); -void getVirtualMemUsed(); -int getVirtualMemUsedByCurrentProcess(); - -struct cpustat { - unsigned long t_user; - unsigned long t_nice; - unsigned long t_system; - unsigned long t_idle; - unsigned long t_iowait; - unsigned long t_irq; - unsigned long t_softirq; -}; - -void get_stats(struct cpustat *st, int cpunum); -double calculate_load(struct cpustat *prev, struct cpustat *cur); \ No newline at end of file diff --git a/fftma_module/gen/lib_src/nor2log.c b/fftma_module/gen/lib_src/nor2log.c index e78bc0a..14367f9 100644 --- a/fftma_module/gen/lib_src/nor2log.c +++ b/fftma_module/gen/lib_src/nor2log.c @@ -1,5 +1,4 @@ #include "geostat.h" -#include "log.h" #include #include #include @@ -15,13 +14,6 @@ /* 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"); - int i; double coeff; @@ -53,7 +45,7 @@ void nor2log(struct realization_mod* realin, int typelog, struct realization_mod } break; default: - log_error("RESULT = failed - Unexpected case in nor2log"); + printf("Input is not normal in nor2log"); return; break; } @@ -74,15 +66,4 @@ void nor2log(struct realization_mod* realin, int typelog, struct realization_mod break; } } - - t = clock() - t; - double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time - - double* used_ram_tf = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_tf); - - 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); -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/nugget.c b/fftma_module/gen/lib_src/nugget.c index 0e9b27e..292138e 100644 --- a/fftma_module/gen/lib_src/nugget.c +++ b/fftma_module/gen/lib_src/nugget.c @@ -1,12 +1,9 @@ #include "genlib.h" #include #include -#include "log.h" /*nugget covariance function*/ double nugget(double h) { - log_info("RESULT = in progress, h = %f", h); - if (h == 0) { return (1.); } else { diff --git a/fftma_module/gen/lib_src/power.c b/fftma_module/gen/lib_src/power.c index a0b3fb0..5e6cdb8 100644 --- a/fftma_module/gen/lib_src/power.c +++ b/fftma_module/gen/lib_src/power.c @@ -1,11 +1,8 @@ #include "genlib.h" #include #include -#include "log.h" /*power covariance function*/ double power(double h, double alpha) { - log_info("RESULT = in progress, h = %f, alpha = %f", h, alpha); - return pow(h, alpha); } diff --git a/fftma_module/gen/lib_src/prebuild_gwn.c b/fftma_module/gen/lib_src/prebuild_gwn.c index d543283..1f6a7f5 100644 --- a/fftma_module/gen/lib_src/prebuild_gwn.c +++ b/fftma_module/gen/lib_src/prebuild_gwn.c @@ -7,8 +7,6 @@ #include #include #include -#include "log.h" -#include "memory.h" /* prebuild_gwn */ /* Produce a first construction in real space of the Gaussian white noise */ @@ -23,12 +21,7 @@ /* must be a Gaussian white noise */ /*realization: structure defining a realization*/ -void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin, chunk_array_t* realization, int solver, long* seed, int cores) { - double* used_ram_t0 = malloc(sizeof(double)); - getVirtualMemUsed(used_ram_t0); - - clock_t t = clock(); - +void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin, chunk_array_t* realization, int solver, long* seed) { int i, j, k, maille0, maille1; int ntot; @@ -39,20 +32,11 @@ void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin if (*seed > 0.0) *seed = -(*seed); - log_info("RESULT = in progress, n[0] = %d, n[1] = %d, n[2] = %d, solver = %d", n[0], n[1], n[2], solver); - - struct cpustat initial[cores]; - struct cpustat final[cores]; - - for (int i = 0; i < cores; i++) { - get_stats(&initial[i], i - 1); - } - ntot = n[0] * n[1] * n[2]; chunk_array_save(realization, 0, 0.); if (solver == 1) { for (i = 0; i < ntot; i++) { - double value = gasdev(seed, &idum2, &iy, iv, cores); + double value = gasdev(seed, &idum2, &iy, iv); chunk_array_save(realization, i+1, value); } } else { @@ -61,7 +45,7 @@ void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin for (i = 1; i <= n[0]; i++) { maille1 = i + (j - 1 + (k - 1) * n[1]) * n[0]; if (i <= grid.NX && j <= grid.NY && k <= grid.NZ) { - double value = gasdev(seed, &idum2, &iy, iv, cores); + double value = gasdev(seed, &idum2, &iy, iv); chunk_array_save(realization, maille1, value); } else { chunk_array_save(realization, maille1, 0.); @@ -70,23 +54,4 @@ 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 - - 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); - - 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); -} \ No newline at end of file +} diff --git a/fftma_module/gen/lib_src/ran2.c b/fftma_module/gen/lib_src/ran2.c index ec3a012..4826971 100644 --- a/fftma_module/gen/lib_src/ran2.c +++ b/fftma_module/gen/lib_src/ran2.c @@ -1,7 +1,5 @@ #include #include "genlib.h" -#include "log.h" -#include "memory.h" #define IM1 2147483563 #define IM2 2147483399 @@ -18,25 +16,11 @@ #define EPS 1.2e-7 #define RNMX (1.0 - EPS) -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(); - +double ran2(long* idum, long* idum2, long* iy, long iv[NTAB]) { 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) *idum = 1; @@ -68,30 +52,10 @@ double ran2(long* idum, long* idum2, long* iy, long iv[NTAB], int cores) { 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; } -} \ No newline at end of file +} diff --git a/fftma_module/gen/moduleFFTMA.c b/fftma_module/gen/moduleFFTMA.c index 2758a46..d5ccc8c 100644 --- a/fftma_module/gen/moduleFFTMA.c +++ b/fftma_module/gen/moduleFFTMA.c @@ -7,6 +7,7 @@ #include "toolsFFTMA.h" #include "toolsFFTPSIM.h" #include "toolsIO.h" +#include "chunk_array.h" #include #include #include @@ -21,6 +22,7 @@ /* Y is the realization with mean and variance wanted */ static PyObject* genFunc(PyObject* self, PyObject* args) { + //log_info("RESULT = in progress"); int n[3]; struct realization_mod Z, Y; struct grid_mod grid; @@ -29,12 +31,11 @@ static PyObject* genFunc(PyObject* self, PyObject* args) { struct statistic_mod stat; PyObject* out_array; npy_intp out_dims[NPY_MAXDIMS]; - int cores; - if (!Py_getvalues(args, &seed, &grid, &variogram, &stat, &cores)) + if (!Py_getvalues(args, &seed, &grid, &variogram, &stat)) return NULL; - Py_kgeneration(seed, grid, stat, variogram, &Z, &Y, n, cores); + Py_kgeneration(seed, grid, stat, variogram, &Z, &Y, n); out_dims[0] = grid.NZ; out_dims[1] = grid.NY; @@ -52,6 +53,9 @@ static PyObject* genFunc(PyObject* self, PyObject* args) { free(variogram.alpha); free(variogram.scf); free(variogram.ap); + free(variogram.vario); + + remove("realization.txt"); return out_array; } @@ -73,4 +77,4 @@ PyInit_FFTMA(void) { import_array(); return PyModule_Create(&cFFTMADef); -} \ No newline at end of file +} diff --git a/fftma_module/gen/save_logs.sh b/fftma_module/gen/save_logs.sh deleted file mode 100755 index cae06f0..0000000 --- a/fftma_module/gen/save_logs.sh +++ /dev/null @@ -1,2 +0,0 @@ -python3 setup.py install --user -ENV=analysis python3 example.py $1 2>&1 | split -l 5000000 - log_$1_improvement-double-buffer-array- \ No newline at end of file diff --git a/fftma_module/gen/setup.py b/fftma_module/gen/setup.py index fd24a07..aa752ec 100644 --- a/fftma_module/gen/setup.py +++ b/fftma_module/gen/setup.py @@ -42,9 +42,7 @@ module_FFTMA = Extension( "./lib_src/clean_real.c", "./lib_src/testmemory.c", "./lib_src/genlib.c", - "./lib_src/chunk_array.c", - "./lib_src/log.c", - "./lib_src/memory.c" + "./lib_src/chunk_array.c" ], ) diff --git a/tools/generation/fftma_gen.py b/tools/generation/fftma_gen.py index f0af73d..752fec1 100755 --- a/tools/generation/fftma_gen.py +++ b/tools/generation/fftma_gen.py @@ -207,7 +207,7 @@ def genGaussK( 0, ) # coord des vecteurs de base (1 0 0) y (0 1 0) k = gen( - Nx, Ny, Nz, dx, dy, dz, seed, [v1], 0, 1, 0, 8) # 0, 1, 0 = mean, variance, typ #Generation of a correlated standard dsitribution N(0,1) + Nx, Ny, Nz, dx, dy, dz, seed, [v1], 0, 1, 0) # 0, 1, 0 = mean, variance, typ #Generation of a correlated standard dsitribution N(0,1) return k