Skip to content

Commit

Permalink
Fix restarts on CPU
Browse files Browse the repository at this point in the history
  • Loading branch information
branmedi committed Aug 27, 2024
1 parent 0ef8030 commit c24a9df
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/species_advance/species_advance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ checkpt_species( const species_t * sp ) {
CHECKPT_PTR( sp->g );
CHECKPT_PTR( sp->next );
CHECKPT_PTR( sp->pb_diag );
#ifdef FIELD_IONIZATION
Kokkos::View<double*, Kokkos::HostSpace> ionization_energy_h("ionization_energy_h", sp->ionization_energy.size());
Kokkos::deep_copy(ionization_energy_h, sp->ionization_energy);
checkpt_data( ionization_energy_h.data(),
ionization_energy_h.size() * sizeof(double),
ionization_energy_h.size() * sizeof(double),
1, 1, 128 );
#endif
}

species_t *
Expand All @@ -41,6 +49,17 @@ restore_species( void ) {
RESTORE_PTR( sp->g );
RESTORE_PTR( sp->next );
RESTORE_PTR( sp->pb_diag );
#ifdef FIELD_IONIZATION
// Restore the ionization_energy and create kokkos view
double *ionization_energies = (double *)restore_data();
const int num_elements = sp->ionization_energy.extent(0);
Kokkos::View<double*,Kokkos::HostSpace> ionization_energy_view("ionization_energy_view", num_elements);
Kokkos::parallel_for("Restore Ionization Energy", Kokkos::RangePolicy<>(0, num_elements), KOKKOS_LAMBDA(int i) {
ionization_energy_view(i) = ionization_energies[i];
});
Kokkos::fence();
Kokkos::deep_copy(sp->ionization_energy, ionization_energy_view);
#endif
return sp;
}

Expand Down
2 changes: 1 addition & 1 deletion src/species_advance/standard/advance_p.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2900,7 +2900,7 @@ advance_p( /**/ species_t * RESTRICT sp,
#endif
KOKKOS_TIC();
#ifdef FIELD_IONIZATION
auto epsilon_eV_list_h = Kokkos::create_mirror(sp->ionization_energy);
Kokkos::View<double*, Kokkos::HostSpace> epsilon_eV_list_h("HostView", sp->ionization_energy.extent(0));
Kokkos::deep_copy(epsilon_eV_list_h, sp->ionization_energy);
if (sp != sp_e && epsilon_eV_list_h(0) != 0){
ADVANCE_P_IONIZE(
Expand Down
2 changes: 1 addition & 1 deletion src/species_advance/standard/ionization_states.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ionization_states_kokkos(const species_t* RESTRICT sp) {
const long long int np = sp->np;
const k_particles_t& k_particles = sp->k_p_d;

auto epsilon_eV_list_h = Kokkos::create_mirror(sp->ionization_energy);
Kokkos::View<double*, Kokkos::HostSpace> epsilon_eV_list_h("epsilon_eV_list_h", sp->ionization_energy.extent(0));
Kokkos::deep_copy(epsilon_eV_list_h,sp->ionization_energy);
const int N_states = epsilon_eV_list_h.extent(0)+1; // Include charge state 0

Expand Down
2 changes: 1 addition & 1 deletion src/vpic/dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ vpic_simulation::dump_ionization_states( const char *fname,

// Iterate over each species
LIST_FOR_EACH(sp, species_list) {
auto ionization_energy_h = Kokkos::create_mirror(sp->ionization_energy);
Kokkos::View<double*, Kokkos::HostSpace> ionization_energy_h("ionization_energy_h", sp->ionization_energy.extent(0));
Kokkos::deep_copy(ionization_energy_h, sp->ionization_energy);

// Ignore species with ionization energy set to 0, except for electrons
Expand Down

0 comments on commit c24a9df

Please sign in to comment.