Fixed last commit

This commit is contained in:
Christian
2019-11-08 17:16:51 +01:00
parent 490bfd2cc6
commit 6c5f0f77c7
3 changed files with 14 additions and 8 deletions
@@ -55,8 +55,8 @@
% the presentation starts here % the presentation starts here
\title[KERL]{The KERL Code} \title[KARL]{The KARL Code}
\subtitle{\textbf{KERL} - \textbf{K}atrin wgts \textbf{E}lectron and ion spect\textbf{R}um monte car\textbf{L}o simulation} \subtitle{\textbf{KARL} - \textbf{KA}trin wgts elect\textbf{R}on and ion spectrum monte car\textbf{L}o simulation}
\author{Christian Reiling} \author{Christian Reiling}
\institute{ETP} \institute{ETP}
+10 -5
View File
@@ -39,6 +39,7 @@ void Simulation::init_pop_arrays() { // Init C-arrays used for MPI-Allgather com
pop_species = new species[number_pop_species]; pop_species = new species[number_pop_species];
pop_array_lengths = new int[number_pop_species]; pop_array_lengths = new int[number_pop_species];
global_cum_time_s = new double *[number_pop_species]; global_cum_time_s = new double *[number_pop_species];
global_offset = new int *[number_pop_species];
Population_Base *population; Population_Base *population;
@@ -50,8 +51,10 @@ void Simulation::init_pop_arrays() { // Init C-arrays used for MPI-Allgather com
pop_array_lengths[i] = population->access_container()->data_size; pop_array_lengths[i] = population->access_container()->data_size;
global_cum_time_s[i] = new double[pop_array_lengths[i]]; global_cum_time_s[i] = new double[pop_array_lengths[i]];
global_offset[i] = new int [pop_array_lengths[i]];
for (int j = 0; j<pop_array_lengths[i]; j++) { for (int j = 0; j<pop_array_lengths[i]; j++) {
global_cum_time_s[i][j] = 0; global_cum_time_s[i][j] = 0;
global_offset[i][j] = 0;
} }
i++; i++;
} }
@@ -129,8 +132,10 @@ void Simulation::deconstruct_pop_arrays() { // Deallocate memory properly
delete[] pop_array_lengths; delete[] pop_array_lengths;
for (int i = 0; i<number_pop_species; i++) { for (int i = 0; i<number_pop_species; i++) {
delete[] global_cum_time_s[i]; delete[] global_cum_time_s[i];
delete[] global_offset[i];
} }
delete[] global_cum_time_s; delete[] global_cum_time_s;
delete[] global_offset;
} }
@@ -195,9 +200,9 @@ void Simulation::sync_populations() { // Sync new densities for each species and
Population_Manager *populations = looper.get_populations(); Population_Manager *populations = looper.get_populations();
Population_Container *container; Population_Container *container;
double *global_delta_cumulated_time_s; double *global_delta_cumulated_time_s;
double *global_delta_offset; int *global_delta_offset;
double *local_delta_cumulated_time_s; double *local_delta_cumulated_time_s;
double *local_delta_offset; int *local_delta_offset;
int array_length; int array_length;
for (int i = 0; i<number_pop_species; i++) { for (int i = 0; i<number_pop_species; i++) {
container = populations->find(pop_species[i])->access_container(); container = populations->find(pop_species[i])->access_container();
@@ -206,9 +211,9 @@ void Simulation::sync_populations() { // Sync new densities for each species and
continue; continue;
} }
global_delta_cumulated_time_s = new double[array_length]; global_delta_cumulated_time_s = new double[array_length];
global_delta_offset = new double[array_length]; global_delta_offset = new int[array_length];
local_delta_cumulated_time_s = new double[array_length]; local_delta_cumulated_time_s = new double[array_length];
local_delta_offset = new double[array_length]; local_delta_offset = new int[array_length];
for (int j = 0; j<array_length; j++) { for (int j = 0; j<array_length; j++) {
local_delta_cumulated_time_s[j] = container->cum_times_s[j] - global_cum_time_s[i][j]; local_delta_cumulated_time_s[j] = container->cum_times_s[j] - global_cum_time_s[i][j];
@@ -216,7 +221,7 @@ void Simulation::sync_populations() { // Sync new densities for each species and
} }
MPI_Allreduce(local_delta_cumulated_time_s, global_delta_cumulated_time_s, array_length, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); MPI_Allreduce(local_delta_cumulated_time_s, global_delta_cumulated_time_s, array_length, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(local_delta_offset, global_delta_offset, array_length, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); MPI_Allreduce(local_delta_offset, global_delta_offset, array_length, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
for (int j = 0; j<array_length; j++) { for (int j = 0; j<array_length; j++) {
global_cum_time_s[i][j] += global_delta_cumulated_time_s[j]; global_cum_time_s[i][j] += global_delta_cumulated_time_s[j];
+2 -1
View File
@@ -32,7 +32,8 @@ class Simulation {
int number_pop_species; int number_pop_species;
species *pop_species; species *pop_species;
int *pop_array_lengths; int *pop_array_lengths;
double **global_cum_time_s, **global_offset; double **global_cum_time_s;
int **global_offset;
public: public:
Simulation(); Simulation();