Skip to content

Commit ecb0df5

Browse files
committed
fix(api): call to mpi/kokkos finalis in API finalise and also atexit to work with either from extern and app
1 parent 3ef2681 commit ecb0df5

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

apps/api/src/api.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
#include <udf_handle.hpp>
2323
#include <utility>
2424
#include <vector>
25-
25+
#ifndef NO_MPI
26+
# include <mpi_w/wrap_mpi.hpp>
27+
#endif
2628
constexpr int ID_VERIF = 2025;
2729

2830
#define CHECK_OR_RETURN(cond, msg) \
@@ -66,7 +68,12 @@ namespace Api
6668
void
6769
finalise()
6870
{
69-
71+
if constexpr (AutoGenerated::FlagCompileTime::use_mpi)
72+
{
73+
#ifndef NO_MPI
74+
WrapMPI::finalize();
75+
#endif
76+
}
7077
if (!Kokkos::is_finalized() && Kokkos::is_initialized())
7178
{
7279
Kokkos::finalize();

apps/api/src/api_raw.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ delete_handle(Handle* handle)
115115
{
116116
if (handle != nullptr)
117117
{
118+
118119
delete *handle; // NOLINT
119120
*handle = nullptr;
120121
}

apps/core/src/case_data.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,6 @@ namespace Core
178178
}
179179
}
180180

181-
if constexpr (AutoGenerated::FlagCompileTime::use_mpi)
182-
{
183-
#ifndef NO_MPI
184-
std::atexit(WrapMPI::finalize);
185-
#endif
186-
}
187-
188181
info.current_rank = static_cast<size_t>(rank);
189182
info.n_rank = static_cast<size_t>(size);
190183

apps/core/src/host_export_handler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ ExportHandler::pre_post_export(
5353
event_span = simulation.mc_unit->events.get_span();
5454
}
5555

56+
// TODO: Multi rank context : tally are not merged before exporting then
57+
// events tally only correspond to rank 0
58+
5659
// Update the main exporter with the current simulation data
5760
main_exporter->update_fields(current_time,
5861
simulation.getCliqData(),

0 commit comments

Comments
 (0)