|
|
|
@ -19,7 +19,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]) {
|
|
|
|
|
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) {
|
|
|
|
|
clock_t t = clock();
|
|
|
|
|
|
|
|
|
|
int i, N;
|
|
|
|
@ -33,14 +33,27 @@ void Py_kgeneration(long seed, struct grid_mod grid, struct statistic_mod stat,
|
|
|
|
|
|
|
|
|
|
log_info("RESULT = in progress, N = %d", N);
|
|
|
|
|
|
|
|
|
|
struct cpustat st0_0, st0_1;
|
|
|
|
|
get_stats(&st0_0, -1);
|
|
|
|
|
struct cpustat initial[cores];
|
|
|
|
|
struct cpustat final[cores];
|
|
|
|
|
|
|
|
|
|
generate(&seed, N, Z);
|
|
|
|
|
for (int i = 0; i < cores; i++) {
|
|
|
|
|
get_stats(&initial[i], i - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
generate(&seed, N, Z, cores);
|
|
|
|
|
|
|
|
|
|
/*FFTMA*/
|
|
|
|
|
FFTMA2(variogram, grid, n, Z, Y);
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
|
|
|
double* total_ram = malloc(sizeof(double));
|
|
|
|
|
getTotalVirtualMem(total_ram);
|
|
|
|
|
|
|
|
|
@ -50,17 +63,13 @@ void Py_kgeneration(long seed, struct grid_mod grid, struct statistic_mod stat,
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
|
get_stats(&st0_1, -1);
|
|
|
|
|
log_info("CPU: %lf%%\n", calculate_load(&st0_0, &st0_1));
|
|
|
|
|
|
|
|
|
|
/* make a log normal realization */
|
|
|
|
|
if (stat.type == 1 || stat.type == 2) {
|
|
|
|
|
typelog = stat.type + 2;
|
|
|
|
|
nor2log(Y, typelog, Y);
|
|
|
|
|
for (int i = 0; i < cores; i++) {
|
|
|
|
|
get_stats(&final[i], i - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t = clock() - t;
|
|
|
|
|
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
|
|
|
|
|
for (int i = 0; i < cores; i++) {
|
|
|
|
|
log_info("CPU %d: %lf%%\n", i, calculate_load(&initial[i], &final[i]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log_info("RESULT = success, ELAPSED = %f seconds", time_taken);
|
|
|
|
|
}
|
|
|
|
|