NeoN
A framework for CFD software
Loading...
Searching...
No Matches
initialization.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 - 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
9#include <Kokkos_Core.hpp>
10#include <chrono>
11
12#include <cpptrace/cpptrace.hpp>
13
14#ifdef NF_WITH_MPI_SUPPORT
16#endif
17
18namespace NeoN
19{
20
21inline void initialize(int argc, char* argv[])
22{
23 // NOTE: Kokkos::initialize(argc, argv) returns void, so the builder methods
24 // (set_print_configuration / set_map_device_id_by) cannot be chained onto it.
25 // Plain init also avoids Kokkos printing its configuration on every rank.
26 // Kokkos::initialize(argc, argv);
27 auto kokkosSettings = Kokkos::InitializationSettings();
28#ifdef NF_WITH_MPI_SUPPORT
29 {
30 const NeoN::mpi::Environment mpiEnv;
31 const int nDev = Kokkos::num_devices();
32 if (nDev > 0) kokkosSettings.set_device_id(mpiEnv.rank() % nDev);
33 }
34#else
35 kokkosSettings.set_map_device_id_by("random");
36#endif
37 Kokkos::initialize(kokkosSettings);
38
39 cpptrace::register_terminate_handler();
40 // setNeonDefaultPattern() reads the MPI rank internally (when MPI is up) to
41 // mute non-root ranks; it works with or without MPI support. Call it after the
42 // host has initialized MPI so the rank is known.
44}
45
46inline void finalize()
47{
48 Logging::info("Finalizing NeoN");
49 Kokkos::finalize();
50}
51
52
53}
void setNeonDefaultPattern()
void info(std::string formatString, Args... args)
convenience function to call spdlogs info with std::format
Definition logging.hpp:120
Integer types used throughout NeoN.
Definition array.hpp:18
void finalize()
void initialize(int argc, char *argv[])