From 15ffa1b7a86d9e562d226320788882939b9a8758 Mon Sep 17 00:00:00 2001 From: haykh Date: Thu, 13 Mar 2025 01:56:06 -0400 Subject: [PATCH 1/4] types made uniform --- src/archetypes/energy_dist.h | 10 +- src/archetypes/particle_injector.h | 6 +- src/archetypes/spatial_dist.h | 12 +-- src/checkpoint/reader.cpp | 50 +++++----- src/checkpoint/reader.h | 12 +-- src/checkpoint/writer.cpp | 80 ++++++++-------- src/checkpoint/writer.h | 24 ++--- src/engines/engine.hpp | 27 +++--- src/engines/engine_init.cpp | 2 +- src/engines/engine_printer.cpp | 15 ++- src/engines/engine_run.cpp | 6 +- src/engines/srpic.hpp | 24 ++--- src/framework/containers/fields.cpp | 6 +- src/framework/containers/fields.h | 2 +- src/framework/containers/particles.cpp | 49 +++++----- src/framework/containers/particles.h | 18 ++-- src/framework/containers/species.h | 6 +- src/framework/domain/checkpoint.cpp | 30 +++--- src/framework/domain/comm_mpi.hpp | 38 ++++---- src/framework/domain/communications.cpp | 35 ++++--- src/framework/domain/domain.h | 12 +-- src/framework/domain/grid.cpp | 14 +-- src/framework/domain/grid.h | 20 ++-- src/framework/domain/mesh.h | 40 ++++---- src/framework/domain/metadomain.cpp | 18 ++-- src/framework/domain/metadomain.h | 18 ++-- src/framework/domain/output.cpp | 40 ++++---- src/framework/parameters.cpp | 46 +++++----- src/framework/parameters.h | 2 +- src/framework/simulation.cpp | 16 ++-- src/framework/tests/comm_mpi.cpp | 4 +- src/framework/tests/metadomain.cpp | 30 +++--- src/global/arch/directions.h | 10 +- src/global/arch/kokkos_aliases.cpp | 28 +++--- src/global/arch/kokkos_aliases.h | 23 +++-- src/global/defaults.h | 12 +-- src/global/enums.h | 4 +- src/global/global.h | 14 ++- src/global/utils/diag.cpp | 34 +++---- src/global/utils/diag.h | 14 +-- src/global/utils/param_container.cpp | 74 ++++++++------- src/global/utils/progressbar.cpp | 39 ++++---- src/global/utils/progressbar.h | 19 ++-- src/global/utils/timer.cpp | 24 ++--- src/global/utils/timer.h | 26 +++--- src/global/utils/tools.h | 58 ++++++------ src/kernels/ampere_gr.hpp | 20 ++-- src/kernels/ampere_sr.hpp | 40 ++++---- src/kernels/comm.hpp | 117 ++++++++++++------------ src/kernels/digital_filter.hpp | 6 +- src/kernels/faraday_gr.hpp | 2 +- src/kernels/faraday_sr.hpp | 6 +- src/kernels/fields_bcs.hpp | 18 ++-- src/kernels/injectors.hpp | 65 +++++++------ src/kernels/particle_moments.hpp | 2 +- src/kernels/prtls_to_phys.hpp | 4 +- src/metrics/kerr_schild.h | 2 +- src/metrics/kerr_schild_0.h | 4 +- src/metrics/metric_base.h | 2 +- src/metrics/minkowski.h | 7 +- src/metrics/qkerr_schild.h | 2 +- src/metrics/qspherical.h | 5 +- src/metrics/spherical.h | 7 +- src/output/fields.h | 2 +- src/output/tests/writer-nompi.cpp | 21 ++--- src/output/utils/attr_writer.h | 10 +- src/output/writer.cpp | 73 ++++++++------- src/output/writer.h | 24 ++--- 68 files changed, 779 insertions(+), 751 deletions(-) diff --git a/src/archetypes/energy_dist.h b/src/archetypes/energy_dist.h index e9bc9051a..231ea5b0b 100644 --- a/src/archetypes/energy_dist.h +++ b/src/archetypes/energy_dist.h @@ -78,14 +78,14 @@ namespace arch { real_t g_max, real_t pl_ind) : EnergyDistribution { metric } - , pool { pool } , g_min { g_min } , g_max { g_max } - , pl_ind { pl_ind } {} + , pl_ind { pl_ind } + , pool { pool } {} Inline void operator()(const coord_t& x_Code, vec_t& v, - unsigned short sp = 0) const override { + unsigned short = 0) const override { auto rand_gen = pool.get_state(); auto rand_X1 = Random(rand_gen); auto rand_gam = ONE; @@ -225,7 +225,7 @@ namespace arch { Inline void operator()(const coord_t& x_Code, vec_t& v, - unsigned short s = 0) const override { + unsigned short sp = 0) const override { if (cmp::AlmostZero(temperature)) { v[0] = ZERO; v[1] = ZERO; @@ -245,7 +245,7 @@ namespace arch { // boost only when using cartesian coordinates if (not cmp::AlmostZero(boost_velocity)) { boost(v); - if (not zero_current and s % 2 == 0) { + if (not zero_current and sp % 2 == 0) { v[0] = -v[0]; v[1] = -v[1]; v[2] = -v[2]; diff --git a/src/archetypes/particle_injector.h b/src/archetypes/particle_injector.h index cbcbbd389..3884e6ced 100644 --- a/src/archetypes/particle_injector.h +++ b/src/archetypes/particle_injector.h @@ -208,13 +208,13 @@ namespace arch { auto ppc0 = params.template get("particles.ppc0"); array_t ni { "ni", M::Dim }; auto ni_h = Kokkos::create_mirror_view(ni); - std::size_t ncells = 1; + ncells_t ncells = 1; for (auto d = 0; d < M::Dim; ++d) { ni_h(d) = domain.mesh.n_active()[d]; ncells *= domain.mesh.n_active()[d]; } Kokkos::deep_copy(ni, ni_h); - const auto nparticles = static_cast( + const auto nparticles = static_cast( (long double)(ppc0 * number_density * 0.5) * (long double)(ncells)); Kokkos::parallel_for( @@ -320,7 +320,7 @@ namespace arch { incl_ghosts.push_back({ false, false }); } const auto extent = domain.mesh.ExtentToRange(box, incl_ghosts); - tuple_t x_min { 0 }, x_max { 0 }; + tuple_t x_min { 0 }, x_max { 0 }; for (auto d = 0; d < M::Dim; ++d) { x_min[d] = extent[d].first; x_max[d] = extent[d].second; diff --git a/src/archetypes/spatial_dist.h b/src/archetypes/spatial_dist.h index be2836da2..d036c0166 100644 --- a/src/archetypes/spatial_dist.h +++ b/src/archetypes/spatial_dist.h @@ -74,15 +74,15 @@ namespace arch { metric.template convert(x_Ph, x_Cd); real_t dens { ZERO }; if constexpr (M::Dim == Dim::_1D) { - dens = density(static_cast(x_Cd[0]) + N_GHOSTS, idx); + dens = density(static_cast(x_Cd[0]) + N_GHOSTS, idx); } else if constexpr (M::Dim == Dim::_2D) { - dens = density(static_cast(x_Cd[0]) + N_GHOSTS, - static_cast(x_Cd[1]) + N_GHOSTS, + dens = density(static_cast(x_Cd[0]) + N_GHOSTS, + static_cast(x_Cd[1]) + N_GHOSTS, idx); } else if constexpr (M::Dim == Dim::_3D) { - dens = density(static_cast(x_Cd[0]) + N_GHOSTS, - static_cast(x_Cd[1]) + N_GHOSTS, - static_cast(x_Cd[2]) + N_GHOSTS, + dens = density(static_cast(x_Cd[0]) + N_GHOSTS, + static_cast(x_Cd[1]) + N_GHOSTS, + static_cast(x_Cd[2]) + N_GHOSTS, idx); } else { raise::KernelError(HERE, "Invalid dimension"); diff --git a/src/checkpoint/reader.cpp b/src/checkpoint/reader.cpp index 9fc2d2640..6e32cb3b9 100644 --- a/src/checkpoint/reader.cpp +++ b/src/checkpoint/reader.cpp @@ -40,15 +40,13 @@ namespace checkpoint { } } - auto ReadParticleCount( - adios2::IO& io, - adios2::Engine& reader, - unsigned short s, - std::size_t local_dom, - std::size_t ndomains) -> std::pair { + auto ReadParticleCount(adios2::IO& io, + adios2::Engine& reader, + unsigned short s, + std::size_t local_dom, + std::size_t ndomains) -> std::pair { logger::Checkpoint(fmt::format("Reading particle count for: %d", s + 1), HERE); - auto npart_var = io.InquireVariable( - fmt::format("s%d_npart", s + 1)); + auto npart_var = io.InquireVariable(fmt::format("s%d_npart", s + 1)); if (npart_var) { raise::ErrorIf(npart_var.Shape()[0] != ndomains, "npart_var.Shape()[0] != ndomains", @@ -57,21 +55,21 @@ namespace checkpoint { "npart_var.Shape().size() != 1", HERE); npart_var.SetSelection(adios2::Box({ local_dom }, { 1 })); - std::size_t npart; + npart_t npart; reader.Get(npart_var, &npart, adios2::Mode::Sync); const auto loc_npart = npart; #if !defined(MPI_ENABLED) - std::size_t offset_npart = 0; + npart_t offset_npart = 0; #else - std::vector glob_nparts(ndomains); + std::vector glob_nparts(ndomains); MPI_Allgather(&loc_npart, 1, - mpi::get_type(), + mpi::get_type(), glob_nparts.data(), 1, - mpi::get_type(), + mpi::get_type(), MPI_COMM_WORLD); - std::size_t offset_npart = 0; + npart_t offset_npart = 0; for (auto d { 0u }; d < local_dom; ++d) { offset_npart += glob_nparts[d]; } @@ -89,8 +87,8 @@ namespace checkpoint { const std::string& quantity, unsigned short s, array_t& array, - std::size_t count, - std::size_t offset) { + npart_t count, + npart_t offset) { logger::Checkpoint( fmt::format("Reading quantity: s%d_%s", s + 1, quantity.c_str()), HERE); @@ -115,8 +113,8 @@ namespace checkpoint { unsigned short s, array_t& array, std::size_t nplds, - std::size_t count, - std::size_t offset) { + npart_t count, + npart_t offset) { logger::Checkpoint(fmt::format("Reading quantity: s%d_plds", s + 1), HERE); auto var = io.InquireVariable(fmt::format("s%d_plds", s + 1)); if (var) { @@ -168,28 +166,28 @@ namespace checkpoint { const std::string&, unsigned short, array_t&, - std::size_t, - std::size_t); + npart_t, + npart_t); template void ReadParticleData(adios2::IO&, adios2::Engine&, const std::string&, unsigned short, array_t&, - std::size_t, - std::size_t); + npart_t, + npart_t); template void ReadParticleData(adios2::IO&, adios2::Engine&, const std::string&, unsigned short, array_t&, - std::size_t, - std::size_t); + npart_t, + npart_t); template void ReadParticleData(adios2::IO&, adios2::Engine&, const std::string&, unsigned short, array_t&, - std::size_t, - std::size_t); + npart_t, + npart_t); } // namespace checkpoint diff --git a/src/checkpoint/reader.h b/src/checkpoint/reader.h index e5a91ab75..883a1d125 100644 --- a/src/checkpoint/reader.h +++ b/src/checkpoint/reader.h @@ -4,7 +4,7 @@ * @implements * - checkpoint::ReadFields -> void * - checkpoint::ReadParticleData -> void - * - checkpoint::ReadParticleCount -> std::pair + * - checkpoint::ReadParticleCount -> std::pair * @cpp: * - reader.cpp * @namespaces: @@ -34,7 +34,7 @@ namespace checkpoint { adios2::Engine&, unsigned short, std::size_t, - std::size_t) -> std::pair; + std::size_t) -> std::pair; template void ReadParticleData(adios2::IO&, @@ -42,16 +42,16 @@ namespace checkpoint { const std::string&, unsigned short, array_t&, - std::size_t, - std::size_t); + npart_t, + npart_t); void ReadParticlePayloads(adios2::IO&, adios2::Engine&, unsigned short, array_t&, std::size_t, - std::size_t, - std::size_t); + npart_t, + npart_t); } // namespace checkpoint diff --git a/src/checkpoint/writer.cpp b/src/checkpoint/writer.cpp index a12e3ef26..c5f7e5181 100644 --- a/src/checkpoint/writer.cpp +++ b/src/checkpoint/writer.cpp @@ -21,8 +21,8 @@ namespace checkpoint { void Writer::init(adios2::ADIOS* ptr_adios, - std::size_t interval, - long double interval_time, + timestep_t interval, + simtime_t interval_time, int keep) { m_keep = keep; m_enabled = keep != 0; @@ -36,8 +36,8 @@ namespace checkpoint { m_io = p_adios->DeclareIO("Entity::Checkpoint"); m_io.SetEngine("BPFile"); - m_io.DefineVariable("Step"); - m_io.DefineVariable("Time"); + m_io.DefineVariable("Step"); + m_io.DefineVariable("Time"); m_io.DefineAttribute("NGhosts", ntt::N_GHOSTS); CallOnce([]() { @@ -48,13 +48,13 @@ namespace checkpoint { }); } - void Writer::defineFieldVariables(const ntt::SimEngine& S, - const std::vector& glob_shape, - const std::vector& loc_corner, - const std::vector& loc_shape) { - auto gs6 = std::vector(glob_shape.begin(), glob_shape.end()); - auto lc6 = std::vector(loc_corner.begin(), loc_corner.end()); - auto ls6 = std::vector(loc_shape.begin(), loc_shape.end()); + void Writer::defineFieldVariables(const ntt::SimEngine& S, + const std::vector& glob_shape, + const std::vector& loc_corner, + const std::vector& loc_shape) { + auto gs6 = std::vector(glob_shape.begin(), glob_shape.end()); + auto lc6 = std::vector(loc_corner.begin(), loc_corner.end()); + auto ls6 = std::vector(loc_shape.begin(), loc_shape.end()); gs6.push_back(6); lc6.push_back(0); ls6.push_back(6); @@ -62,9 +62,9 @@ namespace checkpoint { m_io.DefineVariable("em", gs6, lc6, ls6); if (S == ntt::SimEngine::GRPIC) { m_io.DefineVariable("em0", gs6, lc6, ls6); - auto gs3 = std::vector(glob_shape.begin(), glob_shape.end()); - auto lc3 = std::vector(loc_corner.begin(), loc_corner.end()); - auto ls3 = std::vector(loc_shape.begin(), loc_shape.end()); + auto gs3 = std::vector(glob_shape.begin(), glob_shape.end()); + auto lc3 = std::vector(loc_corner.begin(), loc_corner.end()); + auto ls3 = std::vector(loc_shape.begin(), loc_shape.end()); gs3.push_back(3); lc3.push_back(0); ls3.push_back(3); @@ -80,10 +80,10 @@ namespace checkpoint { "Number of payloads does not match the number of species", HERE); for (auto s { 0u }; s < nspec; ++s) { - m_io.DefineVariable(fmt::format("s%d_npart", s + 1), - { adios2::UnknownDim }, - { adios2::UnknownDim }, - { adios2::UnknownDim }); + m_io.DefineVariable(fmt::format("s%d_npart", s + 1), + { adios2::UnknownDim }, + { adios2::UnknownDim }, + { adios2::UnknownDim }); for (auto d { 0u }; d < dim; ++d) { m_io.DefineVariable(fmt::format("s%d_i%d", s + 1, d + 1), @@ -135,11 +135,11 @@ namespace checkpoint { } } - auto Writer::shouldSave(std::size_t step, long double time) -> bool { + auto Writer::shouldSave(timestep_t step, simtime_t time) -> bool { return m_enabled and m_tracker.shouldWrite(step, time); } - void Writer::beginSaving(std::size_t step, long double time) { + void Writer::beginSaving(timestep_t step, simtime_t time) { raise::ErrorIf(!m_enabled, "Checkpoint is not enabled", HERE); raise::ErrorIf(p_adios == nullptr, "ADIOS pointer is null", HERE); if (m_writing_mode) { @@ -160,8 +160,8 @@ namespace checkpoint { } m_writer.BeginStep(); - m_writer.Put(m_io.InquireVariable("Step"), &step); - m_writer.Put(m_io.InquireVariable("Time"), &time); + m_writer.Put(m_io.InquireVariable("Step"), &step); + m_writer.Put(m_io.InquireVariable("Time"), &time); } void Writer::endSaving() { @@ -226,9 +226,9 @@ namespace checkpoint { template void Writer::saveParticleQuantity(const std::string& quantity, - std::size_t glob_total, - std::size_t loc_offset, - std::size_t loc_size, + npart_t glob_total, + npart_t loc_offset, + npart_t loc_size, const array_t& data) { const auto slice = range_tuple_t(0, loc_size); auto var = m_io.InquireVariable(quantity); @@ -244,9 +244,9 @@ namespace checkpoint { void Writer::saveParticlePayloads(const std::string& quantity, std::size_t nplds, - std::size_t glob_total, - std::size_t loc_offset, - std::size_t loc_size, + npart_t glob_total, + npart_t loc_offset, + npart_t loc_size, const array_t& data) { const auto slice = range_tuple_t(0, loc_size); auto var = m_io.InquireVariable(quantity); @@ -292,23 +292,23 @@ namespace checkpoint { const ndfield_t&); template void Writer::saveParticleQuantity(const std::string&, - std::size_t, - std::size_t, - std::size_t, + npart_t, + npart_t, + npart_t, const array_t&); template void Writer::saveParticleQuantity(const std::string&, - std::size_t, - std::size_t, - std::size_t, + npart_t, + npart_t, + npart_t, const array_t&); template void Writer::saveParticleQuantity(const std::string&, - std::size_t, - std::size_t, - std::size_t, + npart_t, + npart_t, + npart_t, const array_t&); template void Writer::saveParticleQuantity(const std::string&, - std::size_t, - std::size_t, - std::size_t, + npart_t, + npart_t, + npart_t, const array_t&); } // namespace checkpoint diff --git a/src/checkpoint/writer.h b/src/checkpoint/writer.h index 346bee24a..992c54c96 100644 --- a/src/checkpoint/writer.h +++ b/src/checkpoint/writer.h @@ -47,11 +47,11 @@ namespace checkpoint { ~Writer() = default; - void init(adios2::ADIOS*, std::size_t, long double, int); + void init(adios2::ADIOS*, timestep_t, simtime_t, int); - auto shouldSave(std::size_t, long double) -> bool; + auto shouldSave(timestep_t, simtime_t) -> bool; - void beginSaving(std::size_t, long double); + void beginSaving(timestep_t, simtime_t); void endSaving(); void saveAttrs(const ntt::SimulationParams&, long double); @@ -64,22 +64,22 @@ namespace checkpoint { template void saveParticleQuantity(const std::string&, - std::size_t, - std::size_t, - std::size_t, + npart_t, + npart_t, + npart_t, const array_t&); void saveParticlePayloads(const std::string&, std::size_t, - std::size_t, - std::size_t, - std::size_t, + npart_t, + npart_t, + npart_t, const array_t&); void defineFieldVariables(const ntt::SimEngine&, - const std::vector&, - const std::vector&, - const std::vector&); + const std::vector&, + const std::vector&, + const std::vector&); void defineParticleVariables(const ntt::Coord&, Dimension, diff --git a/src/engines/engine.hpp b/src/engines/engine.hpp index dac553dcd..9525874a6 100644 --- a/src/engines/engine.hpp +++ b/src/engines/engine.hpp @@ -67,14 +67,14 @@ namespace ntt { Metadomain m_metadomain; user::PGen m_pgen; - const bool is_resuming; - const long double runtime; - const real_t dt; - const std::size_t max_steps; - const std::size_t start_step; - const long double start_time; - long double time; - std::size_t step; + const bool is_resuming; + const simtime_t runtime; + const real_t dt; + const timestep_t max_steps; + const timestep_t start_step; + const simtime_t start_time; + simtime_t time; + timestep_t step; public: static constexpr bool pgen_is_ok { @@ -91,8 +91,7 @@ namespace ntt { , m_metadomain { m_params.get("simulation.domain.number"), m_params.get>( "simulation.domain.decomposition"), - m_params.get>( - "grid.resolution"), + m_params.get>("grid.resolution"), m_params.get>("grid.extent"), m_params.get>( "grid.boundaries.fields"), @@ -104,11 +103,11 @@ namespace ntt { "particles.species") } , m_pgen { m_params, m_metadomain } , is_resuming { m_params.get("checkpoint.is_resuming") } - , runtime { m_params.get("simulation.runtime") } + , runtime { m_params.get("simulation.runtime") } , dt { m_params.get("algorithms.timestep.dt") } - , max_steps { static_cast(runtime / dt) } - , start_step { m_params.get("checkpoint.start_step") } - , start_time { m_params.get("checkpoint.start_time") } + , max_steps { static_cast(runtime / dt) } + , start_step { m_params.get("checkpoint.start_step") } + , start_time { m_params.get("checkpoint.start_time") } , time { start_time } , step { start_step } { raise::ErrorIf(not pgen_is_ok, "Problem generator is not compatible with the picked engine/metric/dimension", HERE); diff --git a/src/engines/engine_init.cpp b/src/engines/engine_init.cpp index 0239724e1..7ce242bc6 100644 --- a/src/engines/engine_init.cpp +++ b/src/engines/engine_init.cpp @@ -53,7 +53,7 @@ namespace ntt { #if defined(OUTPUT_ENABLED) // read simulation data from the checkpoint raise::ErrorIf( - m_params.template get("checkpoint.start_step") == 0, + m_params.template get("checkpoint.start_step") == 0, "Resuming simulation from a checkpoint requires a valid start_step", HERE); logger::Checkpoint("Resuming simulation from a checkpoint", HERE); diff --git a/src/engines/engine_printer.cpp b/src/engines/engine_printer.cpp index 2a7ee4405..c1a36a323 100644 --- a/src/engines/engine_printer.cpp +++ b/src/engines/engine_printer.cpp @@ -38,7 +38,7 @@ namespace ntt { color::BRIGHT_BLACK, fmt::repeat("═", 58).c_str(), color::RESET); - for (std::size_t i { 0 }; i < lines.size(); ++i) { + for (auto i { 0u }; i < lines.size(); ++i) { report += fmt::format("%s║%s %s%s%s%s%s║%s\n", color::BRIGHT_BLACK, color::RESET, @@ -108,7 +108,7 @@ namespace ntt { auto bytes_to_human_readable( std::size_t bytes) -> std::pair { const std::vector units { "B", "KB", "MB", "GB", "TB" }; - std::size_t unit_idx = 0; + idx_t unit_idx = 0; auto size = static_cast(bytes); while ((size >= 1024) && (unit_idx < units.size() - 1)) { size /= 1024; @@ -236,12 +236,11 @@ namespace ntt { add_param(report, 4, "Runtime", "%.3Le [%d steps]", runtime, max_steps); report += "\n"; add_category(report, 4, "Global domain"); - add_param( - report, - 4, - "Resolution", - "%s", - params.template stringize("grid.resolution").c_str()); + add_param(report, + 4, + "Resolution", + "%s", + params.template stringize("grid.resolution").c_str()); add_param(report, 4, "Extent", diff --git a/src/engines/engine_run.cpp b/src/engines/engine_run.cpp index 506fd121d..2d4b0d5ed 100644 --- a/src/engines/engine_run.cpp +++ b/src/engines/engine_run.cpp @@ -34,11 +34,11 @@ namespace ntt { }, m_params.get("diagnostics.blocking_timers") }; - const auto diag_interval = m_params.get( + const auto diag_interval = m_params.get( "diagnostics.interval"); auto time_history = pbar::DurationHistory { 1000 }; - const auto clear_interval = m_params.template get( + const auto clear_interval = m_params.template get( "particles.clear_interval"); // main algorithm loop @@ -71,7 +71,7 @@ namespace ntt { traits::has_method::value) { auto lambda_custom_field_output = [&](const std::string& name, ndfield_t& buff, - std::size_t idx, + index_t idx, const Domain& dom) { m_pgen.CustomFieldOutput(name, buff, idx, dom); }; diff --git a/src/engines/srpic.hpp b/src/engines/srpic.hpp index 9f5e4551f..0a9cc311b 100644 --- a/src/engines/srpic.hpp +++ b/src/engines/srpic.hpp @@ -79,7 +79,7 @@ namespace ntt { "algorithms.toggles.fieldsolver"); const auto deposit_enabled = m_params.template get( "algorithms.toggles.deposit"); - const auto clear_interval = m_params.template get( + const auto clear_interval = m_params.template get( "particles.clear_interval"); if (step == 0) { @@ -558,7 +558,7 @@ namespace ntt { auto range = range_with_axis_BCs(domain); const auto nfilter = m_params.template get( "algorithms.current_filters"); - tuple_t size; + tuple_t size; if constexpr (M::Dim == Dim::_1D || M::Dim == Dim::_2D || M::Dim == Dim::_3D) { size[0] = domain.mesh.n_active(in::x1); } @@ -644,8 +644,8 @@ namespace ntt { return; } const auto intersect_range = domain.mesh.ExtentToRange(box, incl_ghosts); - tuple_t range_min { 0 }; - tuple_t range_max { 0 }; + tuple_t range_min { 0 }; + tuple_t range_max { 0 }; for (unsigned short d { 0 }; d < M::Dim; ++d) { range_min[d] = intersect_range[d].first; @@ -757,8 +757,8 @@ namespace ntt { } else { raise::Error("Invalid dimension", HERE); } - std::vector xi_min, xi_max; - const std::vector all_dirs { in::x1, in::x2, in::x3 }; + std::vector xi_min, xi_max; + const std::vector all_dirs { in::x1, in::x2, in::x3 }; for (unsigned short d { 0 }; d < static_cast(M::Dim); ++d) { const auto dd = all_dirs[d]; if (dim == dd) { @@ -862,15 +862,15 @@ namespace ntt { return; } const auto intersect_range = domain.mesh.ExtentToRange(box, incl_ghosts); - tuple_t range_min { 0 }; - tuple_t range_max { 0 }; + tuple_t range_min { 0 }; + tuple_t range_max { 0 }; for (unsigned short d { 0 }; d < M::Dim; ++d) { range_min[d] = intersect_range[d].first; range_max[d] = intersect_range[d].second; } - auto atm_fields = m_pgen.AtmFields(time); - std::size_t il_edge; + auto atm_fields = m_pgen.AtmFields(time); + ncells_t il_edge; if (sign > 0) { il_edge = range_min[dd] - N_GHOSTS; } else { @@ -1202,8 +1202,8 @@ namespace ntt { "possible only in -x1 (@ rmin)", HERE); } - real_t xg_min { ZERO }, xg_max { ZERO }; - std::size_t ig_min, ig_max; + real_t xg_min { ZERO }, xg_max { ZERO }; + ncells_t ig_min, ig_max; if (sign > 0) { // + direction ig_min = m_metadomain.mesh().n_active(dim) - buffer_ncells; ig_max = m_metadomain.mesh().n_active(dim); diff --git a/src/framework/containers/fields.cpp b/src/framework/containers/fields.cpp index a62886b06..7202ff282 100644 --- a/src/framework/containers/fields.cpp +++ b/src/framework/containers/fields.cpp @@ -8,8 +8,8 @@ namespace ntt { template - Fields::Fields(const std::vector& res) { - std::size_t nx1, nx2, nx3; + Fields::Fields(const std::vector& res) { + ncells_t nx1, nx2, nx3; nx1 = res[0] + 2 * N_GHOSTS; if constexpr ((D == Dim::_3D) || (D == Dim::_2D)) { nx2 = res[1] + 2 * N_GHOSTS; @@ -52,4 +52,4 @@ namespace ntt { template struct Fields; template struct Fields; -} // namespace ntt \ No newline at end of file +} // namespace ntt diff --git a/src/framework/containers/fields.h b/src/framework/containers/fields.h index d0bd7d020..ee9d656d6 100644 --- a/src/framework/containers/fields.h +++ b/src/framework/containers/fields.h @@ -109,7 +109,7 @@ namespace ntt { */ Fields() {} - Fields(const std::vector& res); + Fields(const std::vector& res); Fields(Fields&& other) noexcept : em { std::move(other.em) } diff --git a/src/framework/containers/particles.cpp b/src/framework/containers/particles.cpp index d78055824..048d57cde 100644 --- a/src/framework/containers/particles.cpp +++ b/src/framework/containers/particles.cpp @@ -25,7 +25,7 @@ namespace ntt { const std::string& label, float m, float ch, - std::size_t maxnpart, + npart_t maxnpart, const PrtlPusher& pusher, bool use_gca, const Cooling& cooling, @@ -72,10 +72,10 @@ namespace ntt { template auto Particles::NpartsPerTagAndOffsets() const - -> std::pair, array_t> { - auto this_tag = tag; - const auto num_tags = ntags(); - array_t npptag { "nparts_per_tag", ntags() }; + -> std::pair, array_t> { + auto this_tag = tag; + const auto num_tags = ntags(); + array_t npptag { "nparts_per_tag", ntags() }; // count # of particles per each tag auto npptag_scat = Kokkos::Experimental::create_scatter_view(npptag); @@ -94,14 +94,14 @@ namespace ntt { // copy the count to a vector on the host auto npptag_h = Kokkos::create_mirror_view(npptag); Kokkos::deep_copy(npptag_h, npptag); - std::vector npptag_vec(num_tags); + std::vector npptag_vec(num_tags); for (auto t { 0u }; t < num_tags; ++t) { npptag_vec[t] = npptag_h(t); } // count the offsets on the host and copy to device - array_t tag_offsets("tag_offsets", num_tags - 3); - auto tag_offsets_h = Kokkos::create_mirror_view(tag_offsets); + array_t tag_offsets("tag_offsets", num_tags - 3); + auto tag_offsets_h = Kokkos::create_mirror_view(tag_offsets); tag_offsets_h(0) = npptag_vec[2]; // offset for tag = 3 for (auto t { 1u }; t < num_tags - 3; ++t) { @@ -113,25 +113,23 @@ namespace ntt { } template - void RemoveDeadInArray(array_t& arr, - const array_t& indices_alive) { - auto n_alive = indices_alive.extent(0); - auto buffer = Kokkos::View("buffer", n_alive); + void RemoveDeadInArray(array_t& arr, const array_t& indices_alive) { + npart_t n_alive = indices_alive.extent(0); + auto buffer = Kokkos::View("buffer", n_alive); Kokkos::parallel_for( "PopulateBufferAlive", n_alive, Lambda(index_t p) { buffer(p) = arr(indices_alive(p)); }); Kokkos::deep_copy( - Kokkos::subview(arr, std::make_pair(static_cast(0), n_alive)), + Kokkos::subview(arr, std::make_pair(static_cast(0), n_alive)), buffer); } template - void RemoveDeadInArray(array_t& arr, - const array_t& indices_alive) { - auto n_alive = indices_alive.extent(0); - auto buffer = array_t { "buffer", n_alive, arr.extent(1) }; + void RemoveDeadInArray(array_t& arr, const array_t& indices_alive) { + npart_t n_alive = indices_alive.extent(0); + auto buffer = array_t { "buffer", n_alive, arr.extent(1) }; Kokkos::parallel_for( "PopulateBufferAlive", CreateRangePolicy({ 0, 0 }, { n_alive, arr.extent(1) }), @@ -139,21 +137,21 @@ namespace ntt { Kokkos::deep_copy( Kokkos::subview(arr, - std::make_pair(static_cast(0), n_alive), + std::make_pair(static_cast(0), n_alive), Kokkos::ALL), buffer); } template void Particles::RemoveDead() { - const auto n_part = npart(); - std::size_t n_alive = 0, n_dead = 0; - auto& this_tag = tag; + const auto n_part = npart(); + npart_t n_alive = 0, n_dead = 0; + auto& this_tag = tag; Kokkos::parallel_reduce( "CountDeadAlive", rangeActiveParticles(), - Lambda(index_t p, std::size_t & nalive, std::size_t & ndead) { + Lambda(index_t p, npart_t & nalive, npart_t & ndead) { nalive += (this_tag(p) == ParticleTag::alive); ndead += (this_tag(p) == ParticleTag::dead); if (this_tag(p) != ParticleTag::alive and this_tag(p) != ParticleTag::dead) { @@ -163,8 +161,8 @@ namespace ntt { n_alive, n_dead); - array_t indices_alive { "indices_alive", n_alive }; - array_t alive_counter { "counter_alive", 1 }; + array_t indices_alive { "indices_alive", n_alive }; + array_t alive_counter { "counter_alive", 1 }; Kokkos::parallel_for( "AliveIndices", @@ -221,8 +219,7 @@ namespace ntt { Kokkos::Experimental::fill( "TagAliveParticles", AccelExeSpace(), - Kokkos::subview(this_tag, - std::make_pair(static_cast(0), n_alive)), + Kokkos::subview(this_tag, std::make_pair(static_cast(0), n_alive)), ParticleTag::alive); Kokkos::Experimental::fill( diff --git a/src/framework/containers/particles.h b/src/framework/containers/particles.h index d84bd0cc9..5241822e2 100644 --- a/src/framework/containers/particles.h +++ b/src/framework/containers/particles.h @@ -37,8 +37,8 @@ namespace ntt { struct Particles : public ParticleSpecies { private: // Number of currently active (used) particles - std::size_t m_npart { 0 }; - bool m_is_sorted { false }; + npart_t m_npart { 0 }; + bool m_is_sorted { false }; #if !defined(MPI_ENABLED) const std::size_t m_ntags { 2 }; @@ -84,7 +84,7 @@ namespace ntt { const std::string& label, float m, float ch, - std::size_t maxnpart, + npart_t maxnpart, const PrtlPusher& pusher, bool use_gca, const Cooling& cooling, @@ -116,7 +116,7 @@ namespace ntt { * @returns A 1D Kokkos range policy of size of `npart` */ inline auto rangeActiveParticles() const -> range_t { - return CreateRangePolicy({ 0 }, { npart() }); + return CreateParticleRangePolicy(0u, npart()); } /** @@ -124,7 +124,7 @@ namespace ntt { * @returns A 1D Kokkos range policy of size of `npart` */ inline auto rangeAllParticles() const -> range_t { - return CreateRangePolicy({ 0 }, { maxnpart() }); + return CreateParticleRangePolicy(0u, maxnpart()); } /* getters -------------------------------------------------------------- */ @@ -132,7 +132,7 @@ namespace ntt { * @brief Get the number of active particles */ [[nodiscard]] - auto npart() const -> std::size_t { + auto npart() const -> npart_t { return m_npart; } @@ -188,14 +188,14 @@ namespace ntt { * ... etc. */ auto NpartsPerTagAndOffsets() const - -> std::pair, array_t>; + -> std::pair, array_t>; /* setters -------------------------------------------------------------- */ /** * @brief Set the number of particles - * @param npart The number of particles as a std::size_t + * @param npart The number of particles as a npart_t */ - void set_npart(std::size_t n) { + void set_npart(npart_t n) { raise::ErrorIf( n > maxnpart(), fmt::format( diff --git a/src/framework/containers/species.h b/src/framework/containers/species.h index 1f52733aa..6dd437819 100644 --- a/src/framework/containers/species.h +++ b/src/framework/containers/species.h @@ -28,7 +28,7 @@ namespace ntt { // Species charge in units of q0 const float m_charge; // Max number of allocated particles for the species - std::size_t m_maxnpart; + npart_t m_maxnpart; // Pusher assigned for the species const PrtlPusher m_pusher; @@ -68,7 +68,7 @@ namespace ntt { const std::string& label, float m, float ch, - std::size_t maxnpart, + npart_t maxnpart, const PrtlPusher& pusher, bool use_gca, const Cooling& cooling, @@ -111,7 +111,7 @@ namespace ntt { } [[nodiscard]] - auto maxnpart() const -> std::size_t { + auto maxnpart() const -> npart_t { return m_maxnpart; } diff --git a/src/framework/domain/checkpoint.cpp b/src/framework/domain/checkpoint.cpp index 6dfb137db..978a1ad10 100644 --- a/src/framework/domain/checkpoint.cpp +++ b/src/framework/domain/checkpoint.cpp @@ -32,7 +32,7 @@ namespace ntt { "local_domain is a placeholder", HERE); - std::vector glob_shape_with_ghosts, off_ncells_with_ghosts; + std::vector glob_shape_with_ghosts, off_ncells_with_ghosts; for (auto d { 0u }; d < M::Dim; ++d) { off_ncells_with_ghosts.push_back( local_domain->offset_ncells()[d] + @@ -49,8 +49,8 @@ namespace ntt { g_checkpoint_writer.init( ptr_adios, - params.template get("checkpoint.interval"), - params.template get("checkpoint.interval_time"), + params.template get("checkpoint.interval"), + params.template get("checkpoint.interval_time"), params.template get("checkpoint.keep")); if (g_checkpoint_writer.enabled()) { g_checkpoint_writer.defineFieldVariables(S, @@ -66,10 +66,10 @@ namespace ntt { template auto Metadomain::WriteCheckpoint(const SimulationParams& params, - std::size_t current_step, - std::size_t finished_step, - long double current_time, - long double finished_time) -> bool { + timestep_t current_step, + timestep_t finished_step, + simtime_t current_time, + simtime_t finished_time) -> bool { raise::ErrorIf( l_subdomain_indices().size() != 1, "Checkpointing for now is only supported for one subdomain per rank", @@ -98,17 +98,17 @@ namespace ntt { #endif // MPI_ENABLED for (auto s { 0u }; s < local_domain->species.size(); ++s) { - auto npart = local_domain->species[s].npart(); - std::size_t offset = 0; - auto glob_tot = npart; + auto npart = local_domain->species[s].npart(); + npart_t offset = 0; + auto glob_tot = npart; #if defined(MPI_ENABLED) - auto glob_npart = std::vector(g_ndomains); + auto glob_npart = std::vector(g_ndomains); MPI_Allgather(&npart, 1, - mpi::get_type(), + mpi::get_type(), glob_npart.data(), 1, - mpi::get_type(), + mpi::get_type(), MPI_COMM_WORLD); glob_tot = 0; for (auto r = 0; r < g_mpi_size; ++r) { @@ -118,7 +118,7 @@ namespace ntt { glob_tot += glob_npart[r]; } #endif // MPI_ENABLED - g_checkpoint_writer.savePerDomainVariable( + g_checkpoint_writer.savePerDomainVariable( fmt::format("s%d_npart", s + 1), dom_tot, dom_offset, @@ -263,7 +263,7 @@ namespace ntt { raise::ErrorIf(ptr_adios == nullptr, "adios == nullptr", HERE); auto fname = fmt::format( "checkpoints/step-%08lu.bp", - params.template get("checkpoint.start_step")); + params.template get("checkpoint.start_step")); logger::Checkpoint(fmt::format("Reading checkpoint from %s", fname.c_str()), HERE); diff --git a/src/framework/domain/comm_mpi.hpp b/src/framework/domain/comm_mpi.hpp index e5bc2d21e..8c6e532de 100644 --- a/src/framework/domain/comm_mpi.hpp +++ b/src/framework/domain/comm_mpi.hpp @@ -129,7 +129,7 @@ namespace comm { } } } else { - std::size_t nsend { comps.second - comps.first }, + ncells_t nsend { comps.second - comps.first }, nrecv { comps.second - comps.first }; ndarray_t(D) + 1> send_fld, recv_fld; @@ -287,29 +287,29 @@ namespace comm { } } - void ParticleSendRecvCount(int send_rank, - int recv_rank, - std::size_t send_count, - std::size_t& recv_count) { + void ParticleSendRecvCount(int send_rank, + int recv_rank, + npart_t send_count, + npart_t& recv_count) { if ((send_rank >= 0) && (recv_rank >= 0)) { MPI_Sendrecv(&send_count, 1, - mpi::get_type(), + mpi::get_type(), send_rank, 0, &recv_count, 1, - mpi::get_type(), + mpi::get_type(), recv_rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); } else if (send_rank >= 0) { - MPI_Send(&send_count, 1, mpi::get_type(), send_rank, 0, MPI_COMM_WORLD); + MPI_Send(&send_count, 1, mpi::get_type(), send_rank, 0, MPI_COMM_WORLD); } else if (recv_rank >= 0) { MPI_Recv(&recv_count, 1, - mpi::get_type(), + mpi::get_type(), recv_rank, 0, MPI_COMM_WORLD, @@ -320,14 +320,14 @@ namespace comm { } template - void CommunicateParticles(Particles& species, - const array_t& outgoing_indices, - const array_t& tag_offsets, - const std::vector& npptag_vec, - const std::vector& npptag_recv_vec, - const std::vector& send_ranks, - const std::vector& recv_ranks, - const dir::dirs_t& dirs_to_comm) { + void CommunicateParticles(Particles& species, + const array_t& outgoing_indices, + const array_t& tag_offsets, + const std::vector& npptag_vec, + const std::vector& npptag_recv_vec, + const std::vector& send_ranks, + const std::vector& recv_ranks, + const dir::dirs_t& dirs_to_comm) { // number of arrays of each type to send/recv const unsigned short NREALS = 4 + static_cast( D == Dim::_2D and C != Coord::Cart); @@ -341,7 +341,7 @@ namespace comm { const auto npart_send = outgoing_indices.extent(0) - npart_dead; const auto npart_recv = std::accumulate(npptag_recv_vec.begin(), npptag_recv_vec.end(), - static_cast(0)); + static_cast(0)); array_t recv_buff_int { "recv_buff_int", npart_recv * NINTS }; array_t recv_buff_real { "recv_buff_real", npart_recv * NREALS }; array_t recv_buff_prtldx { "recv_buff_prtldx", npart_recv * NPRTLDX }; @@ -376,7 +376,7 @@ namespace comm { auto tag_offsets_h = Kokkos::create_mirror_view(tag_offsets); Kokkos::deep_copy(tag_offsets_h, tag_offsets); - std::size_t idx_offset = npart_dead; + npart_t idx_offset = npart_dead; if (tag_send > 2) { idx_offset += tag_offsets_h(tag_send - 3); } diff --git a/src/framework/domain/communications.cpp b/src/framework/domain/communications.cpp index 7dc5d285a..946756f49 100644 --- a/src/framework/domain/communications.cpp +++ b/src/framework/domain/communications.cpp @@ -36,10 +36,10 @@ namespace ntt { using comm_params_t = std::pair>; template - auto GetSendRecvRanks(Metadomain* metadomain, - Domain& domain, - dir::direction_t direction) - -> std::pair { + auto GetSendRecvRanks( + Metadomain* metadomain, + Domain& domain, + dir::direction_t direction) -> std::pair { Domain* send_to_nghbr_ptr = nullptr; Domain* recv_from_nghbr_ptr = nullptr; // set pointers to the correct send/recv domains @@ -119,11 +119,11 @@ namespace ntt { } template - auto GetSendRecvParams(Metadomain* metadomain, - Domain& domain, - dir::direction_t direction, - bool synchronize) - -> std::pair { + auto GetSendRecvParams( + Metadomain* metadomain, + Domain& domain, + dir::direction_t direction, + bool synchronize) -> std::pair { const auto [send_indrank, recv_indrank] = GetSendRecvRanks(metadomain, domain, direction); const auto [send_ind, send_rank] = send_indrank; @@ -140,7 +140,7 @@ namespace ntt { auto recv_slice = std::vector {}; const in components[] = { in::x1, in::x2, in::x3 }; // find the field components and indices to be sent/received - for (std::size_t d { 0 }; d < direction.size(); ++d) { + for (auto d { 0u }; d < direction.size(); ++d) { const auto c = components[d]; const auto dir = direction[d]; if (not synchronize) { @@ -510,11 +510,11 @@ namespace ntt { const auto npart_holes = npart - npart_alive; // # of particles to receive per each tag (direction) - std::vector npptag_recv_vec(ntags - 2, 0); + std::vector npptag_recv_vec(ntags - 2, 0); // coordinate shifts per each direction - array_t shifts_in_x1 { "shifts_in_x1", ntags - 2 }; - array_t shifts_in_x2 { "shifts_in_x2", ntags - 2 }; - array_t shifts_in_x3 { "shifts_in_x3", ntags - 2 }; + array_t shifts_in_x1 { "shifts_in_x1", ntags - 2 }; + array_t shifts_in_x2 { "shifts_in_x2", ntags - 2 }; + array_t shifts_in_x3 { "shifts_in_x3", ntags - 2 }; auto shifts_in_x1_h = Kokkos::create_mirror_view(shifts_in_x1); auto shifts_in_x2_h = Kokkos::create_mirror_view(shifts_in_x2); auto shifts_in_x3_h = Kokkos::create_mirror_view(shifts_in_x3); @@ -527,7 +527,7 @@ namespace ntt { std::vector recv_ranks, recv_inds; // total # of reaceived particles from all directions - std::size_t npart_recv = 0u; + npart_t npart_recv = 0u; for (const auto& direction : dir::Directions::all) { // tags corresponding to the direction (both send & recv) @@ -559,7 +559,7 @@ namespace ntt { // request the # of particles to-be-received ... // ... and send the # of particles to-be-sent - std::size_t nrecv = 0; + npart_t nrecv = 0; comm::ParticleSendRecvCount(send_rank, recv_rank, nsend, nrecv); npart_recv += nrecv; npptag_recv_vec[tag_recv - 2] = nrecv; @@ -604,8 +604,7 @@ namespace ntt { Kokkos::deep_copy(shifts_in_x2, shifts_in_x2_h); Kokkos::deep_copy(shifts_in_x3, shifts_in_x3_h); - array_t outgoing_indices { "outgoing_indices", - npart - npart_alive }; + array_t outgoing_indices { "outgoing_indices", npart - npart_alive }; // clang-format off Kokkos::parallel_for( "PrepareOutgoingPrtls", diff --git a/src/framework/domain/domain.h b/src/framework/domain/domain.h index bc7c6e4b5..7966cdb54 100644 --- a/src/framework/domain/domain.h +++ b/src/framework/domain/domain.h @@ -73,8 +73,8 @@ namespace ntt { Domain(bool, unsigned int index, const std::vector& offset_ndomains, - const std::vector& offset_ncells, - const std::vector& ncells, + const std::vector& offset_ncells, + const std::vector& ncells, const boundaries_t& extent, const std::map& metric_params, const std::vector&) @@ -88,8 +88,8 @@ namespace ntt { Domain(unsigned int index, const std::vector& offset_ndomains, - const std::vector& offset_ncells, - const std::vector& ncells, + const std::vector& offset_ncells, + const std::vector& ncells, const boundaries_t& extent, const std::map& metric_params, const std::vector& species_params) @@ -124,7 +124,7 @@ namespace ntt { } [[nodiscard]] - auto offset_ncells() const -> std::vector { + auto offset_ncells() const -> std::vector { return m_offset_ncells; } @@ -156,7 +156,7 @@ namespace ntt { // offset of the domain in # of domains std::vector m_offset_ndomains; // offset of the domain in cells (# of cells in each dimension) - std::vector m_offset_ncells; + std::vector m_offset_ncells; // neighboring domain indices dir::map_t m_neighbor_idx; // MPI rank of the domain (used only when MPI enabled) diff --git a/src/framework/domain/grid.cpp b/src/framework/domain/grid.cpp index 9302386e1..baa23fb5c 100644 --- a/src/framework/domain/grid.cpp +++ b/src/framework/domain/grid.cpp @@ -50,7 +50,7 @@ namespace ntt { template auto Grid::rangeCells(const box_region_t& region) const -> range_t { - tuple_t imin, imax; + tuple_t imin, imax; for (unsigned short i = 0; i < (unsigned short)D; i++) { switch (region[i]) { case CellLayer::allLayer: @@ -87,9 +87,9 @@ namespace ntt { // !TODO: too ugly, implement a better solution (combine with device) template - auto Grid::rangeCellsOnHost(const box_region_t& region) const - -> range_h_t { - tuple_t imin, imax; + auto Grid::rangeCellsOnHost( + const box_region_t& region) const -> range_h_t { + tuple_t imin, imax; for (unsigned short i = 0; i < (unsigned short)D; i++) { switch (region[i]) { case CellLayer::allLayer: @@ -164,9 +164,9 @@ namespace ntt { } template - auto Grid::rangeCells(const tuple_t, D>& ranges) const - -> range_t { - tuple_t imin, imax; + auto Grid::rangeCells( + const tuple_t, D>& ranges) const -> range_t { + tuple_t imin, imax; for (unsigned short i = 0; i < (unsigned short)D; i++) { raise::ErrorIf((ranges[i][0] < -(int)N_GHOSTS) || (ranges[i][1] > (int)N_GHOSTS), diff --git a/src/framework/domain/grid.h b/src/framework/domain/grid.h index 97a939117..af5b6c8d5 100644 --- a/src/framework/domain/grid.h +++ b/src/framework/domain/grid.h @@ -73,7 +73,7 @@ namespace ntt { template struct Grid { - Grid(const std::vector& res) : m_resolution { res } { + Grid(const std::vector& res) : m_resolution { res } { raise::ErrorIf(m_resolution.size() != D, "invalid dimension", HERE); } @@ -81,7 +81,7 @@ namespace ntt { /* getters -------------------------------------------------------------- */ [[nodiscard]] - auto i_min(in i) const -> std::size_t { + auto i_min(in i) const -> ncells_t { switch (i) { case in::x1: return (m_resolution.size() > 0) ? N_GHOSTS : 0; @@ -96,7 +96,7 @@ namespace ntt { } [[nodiscard]] - auto i_max(in i) const -> std::size_t { + auto i_max(in i) const -> ncells_t { switch (i) { case in::x1: return (m_resolution.size() > 0) ? (m_resolution[0] + N_GHOSTS) : 1; @@ -111,7 +111,7 @@ namespace ntt { } [[nodiscard]] - auto n_active(in i) const -> std::size_t { + auto n_active(in i) const -> ncells_t { switch (i) { case in::x1: return (m_resolution.size() > 0) ? m_resolution[0] : 1; @@ -126,12 +126,12 @@ namespace ntt { } [[nodiscard]] - auto n_active() const -> std::vector { + auto n_active() const -> std::vector { return m_resolution; } [[nodiscard]] - auto n_all(in i) const -> std::size_t { + auto n_all(in i) const -> ncells_t { switch (i) { case in::x1: return (m_resolution.size() > 0) ? (m_resolution[0] + 2 * N_GHOSTS) : 1; @@ -146,9 +146,9 @@ namespace ntt { } [[nodiscard]] - auto n_all() const -> std::vector { - std::vector nall; - for (std::size_t i = 0; i < D; ++i) { + auto n_all() const -> std::vector { + std::vector nall; + for (auto i = 0u; i < D; ++i) { nall.push_back(m_resolution[i] + 2 * N_GHOSTS); } return nall; @@ -204,7 +204,7 @@ namespace ntt { auto rangeCellsOnHost(const box_region_t&) const -> range_h_t; protected: - std::vector m_resolution; + std::vector m_resolution; }; } // namespace ntt diff --git a/src/framework/domain/mesh.h b/src/framework/domain/mesh.h index b0bd1a567..98fe68895 100644 --- a/src/framework/domain/mesh.h +++ b/src/framework/domain/mesh.h @@ -38,14 +38,14 @@ namespace ntt { M metric; - Mesh(const std::vector& res, + Mesh(const std::vector& res, const boundaries_t& ext, const std::map& metric_params) : Grid { res } , metric { res, ext, metric_params } , m_extent { ext } {} - Mesh(const std::vector& res, + Mesh(const std::vector& res, const boundaries_t& ext, const std::map& metric_params, const boundaries_t& flds_bc, @@ -131,15 +131,15 @@ namespace ntt { * @note indices are already shifted by N_GHOSTS (i.e. they start at N_GHOSTS not 0) */ [[nodiscard]] - auto ExtentToRange(boundaries_t box, boundaries_t incl_ghosts) - -> boundaries_t { + auto ExtentToRange(boundaries_t box, + boundaries_t incl_ghosts) -> boundaries_t { raise::ErrorIf(box.size() != M::Dim, "Invalid box dimension", HERE); raise::ErrorIf(incl_ghosts.size() != M::Dim, "Invalid incl_ghosts dimension", HERE); - boundaries_t range; + boundaries_t range; if (not Intersects(box)) { - for (std::size_t i { 0 }; i < box.size(); ++i) { + for (auto i { 0u }; i < box.size(); ++i) { range.push_back({ 0, 0 }); } return range; @@ -184,9 +184,9 @@ namespace ntt { raise::Error("invalid dimension", HERE); throw; } - range.push_back({ static_cast(xi_min_Cd) + + range.push_back({ static_cast(xi_min_Cd) + (incl_ghosts[d].first ? 0 : N_GHOSTS), - static_cast(xi_max_Cd) + + static_cast(xi_max_Cd) + (incl_ghosts[d].second ? 2 * N_GHOSTS : N_GHOSTS) }); } ++d; @@ -222,18 +222,18 @@ namespace ntt { auto flds_bc() const -> boundaries_t { if constexpr (D == Dim::_1D) { return { - {flds_bc_in({ -1 }), flds_bc_in({ -1 })} + { flds_bc_in({ -1 }), flds_bc_in({ -1 }) } }; } else if constexpr (D == Dim::_2D) { return { - {flds_bc_in({ -1, 0 }), flds_bc_in({ 1, 0 })}, - {flds_bc_in({ 0, -1 }), flds_bc_in({ 0, 1 })} + { flds_bc_in({ -1, 0 }), flds_bc_in({ 1, 0 }) }, + { flds_bc_in({ 0, -1 }), flds_bc_in({ 0, 1 }) } }; } else if constexpr (D == Dim::_3D) { return { - {flds_bc_in({ -1, 0, 0 }), flds_bc_in({ 1, 0, 0 })}, - {flds_bc_in({ 0, -1, 0 }), flds_bc_in({ 0, 1, 0 })}, - {flds_bc_in({ 0, 0, -1 }), flds_bc_in({ 0, 0, 1 })} + { flds_bc_in({ -1, 0, 0 }), flds_bc_in({ 1, 0, 0 }) }, + { flds_bc_in({ 0, -1, 0 }), flds_bc_in({ 0, 1, 0 }) }, + { flds_bc_in({ 0, 0, -1 }), flds_bc_in({ 0, 0, 1 }) } }; } else { raise::Error("invalid dimension", HERE); @@ -245,18 +245,18 @@ namespace ntt { auto prtl_bc() const -> boundaries_t { if constexpr (D == Dim::_1D) { return { - {prtl_bc_in({ -1 }), prtl_bc_in({ -1 })} + { prtl_bc_in({ -1 }), prtl_bc_in({ -1 }) } }; } else if constexpr (D == Dim::_2D) { return { - {prtl_bc_in({ -1, 0 }), prtl_bc_in({ 1, 0 })}, - {prtl_bc_in({ 0, -1 }), prtl_bc_in({ 0, 1 })} + { prtl_bc_in({ -1, 0 }), prtl_bc_in({ 1, 0 }) }, + { prtl_bc_in({ 0, -1 }), prtl_bc_in({ 0, 1 }) } }; } else if constexpr (D == Dim::_3D) { return { - {prtl_bc_in({ -1, 0, 0 }), prtl_bc_in({ 1, 0, 0 })}, - {prtl_bc_in({ 0, -1, 0 }), prtl_bc_in({ 0, 1, 0 })}, - {prtl_bc_in({ 0, 0, -1 }), prtl_bc_in({ 0, 0, 1 })} + { prtl_bc_in({ -1, 0, 0 }), prtl_bc_in({ 1, 0, 0 }) }, + { prtl_bc_in({ 0, -1, 0 }), prtl_bc_in({ 0, 1, 0 }) }, + { prtl_bc_in({ 0, 0, -1 }), prtl_bc_in({ 0, 0, 1 }) } }; } else { raise::Error("invalid dimension", HERE); diff --git a/src/framework/domain/metadomain.cpp b/src/framework/domain/metadomain.cpp index ed4373df2..dd0d6ffe7 100644 --- a/src/framework/domain/metadomain.cpp +++ b/src/framework/domain/metadomain.cpp @@ -32,10 +32,10 @@ namespace ntt { template Metadomain::Metadomain(unsigned int global_ndomains, const std::vector& global_decomposition, - const std::vector& global_ncells, - const boundaries_t& global_extent, - const boundaries_t& global_flds_bc, - const boundaries_t& global_prtl_bc, + const std::vector& global_ncells, + const boundaries_t& global_extent, + const boundaries_t& global_flds_bc, + const boundaries_t& global_prtl_bc, const std::map& metric_params, const std::vector& species_params) : g_ndomains { global_ndomains } @@ -104,13 +104,13 @@ namespace ntt { raise::ErrorIf(d_ncells.size() != (std::size_t)D, "Invalid number of dimensions received", HERE); - auto d_offset_ncells = std::vector> {}; + auto d_offset_ncells = std::vector> {}; auto d_offset_ndoms = std::vector> {}; for (auto& d : d_ncells) { g_ndomains_per_dim.push_back(d.size()); - auto offset_ncell = std::vector { 0 }; + auto offset_ncell = std::vector { 0 }; auto offset_ndom = std::vector { 0 }; - for (std::size_t i { 1 }; i < d.size(); ++i) { + for (auto i { 1u }; i < d.size(); ++i) { auto di = d[i - 1]; offset_ncell.push_back(offset_ncell.back() + di); offset_ndom.push_back(offset_ndom.back() + 1); @@ -121,8 +121,8 @@ namespace ntt { /* compute tensor products of the domain decompositions --------------- */ // works similar to np.meshgrid() - const auto domain_ncells = tools::TensorProduct(d_ncells); - const auto domain_offset_ncells = tools::TensorProduct( + const auto domain_ncells = tools::TensorProduct(d_ncells); + const auto domain_offset_ncells = tools::TensorProduct( d_offset_ncells); const auto domain_offset_ndoms = tools::TensorProduct( d_offset_ndoms); diff --git a/src/framework/domain/metadomain.h b/src/framework/domain/metadomain.h index 5177571d0..e7e1340e2 100644 --- a/src/framework/domain/metadomain.h +++ b/src/framework/domain/metadomain.h @@ -103,7 +103,7 @@ namespace ntt { */ Metadomain(unsigned int, const std::vector&, - const std::vector&, + const std::vector&, const boundaries_t&, const boundaries_t&, const boundaries_t&, @@ -118,20 +118,20 @@ namespace ntt { #if defined(OUTPUT_ENABLED) void InitWriter(adios2::ADIOS*, const SimulationParams&, bool is_resuming); auto Write(const SimulationParams&, - std::size_t, - std::size_t, - long double, - long double, + timestep_t, + timestep_t, + simtime_t, + simtime_t, std::function&, std::size_t, const Domain&)> = {}) -> bool; void InitCheckpointWriter(adios2::ADIOS*, const SimulationParams&); auto WriteCheckpoint(const SimulationParams&, - std::size_t, - std::size_t, - long double, - long double) -> bool; + timestep_t, + timestep_t, + simtime_t, + simtime_t) -> bool; void ContinueFromCheckpoint(adios2::ADIOS*, const SimulationParams&); #endif diff --git a/src/framework/domain/output.cpp b/src/framework/domain/output.cpp index 6961d2826..1b29dcf7d 100644 --- a/src/framework/domain/output.cpp +++ b/src/framework/domain/output.cpp @@ -96,9 +96,9 @@ namespace ntt { g_writer.defineSpectraOutputs(spectra_species); for (const auto& type : { "fields", "particles", "spectra" }) { g_writer.addTracker(type, - params.template get( + params.template get( "output." + std::string(type) + ".interval"), - params.template get( + params.template get( "output." + std::string(type) + ".interval_time")); } if (is_resuming and std::filesystem::exists(g_writer.fname())) { @@ -182,10 +182,10 @@ namespace ntt { template auto Metadomain::Write( const SimulationParams& params, - std::size_t current_step, - std::size_t finished_step, - long double current_time, - long double finished_time, + timestep_t current_step, + timestep_t finished_step, + simtime_t current_time, + simtime_t finished_time, std::function< void(const std::string&, ndfield_t&, std::size_t, const Domain&)> CustomFieldOutput) -> bool { @@ -234,8 +234,8 @@ namespace ntt { const double l = l_offset; const double f = math::ceil(l / d) * d - l; - const auto first_cell = static_cast(f); - const auto l_size_dwn = static_cast(math::ceil((n - f) / d)); + const auto first_cell = static_cast(f); + const auto l_size_dwn = static_cast(math::ceil((n - f) / d)); const auto is_last = l_offset + l_size == g_size; @@ -472,19 +472,19 @@ namespace ntt { if (write_particles) { g_writer.beginWriting(WriteMode::Particles, current_step, current_time); - const auto prtl_stride = params.template get( + const auto prtl_stride = params.template get( "output.particles.stride"); for (const auto& prtl : g_writer.speciesWriters()) { auto& species = local_domain->species[prtl.species() - 1]; if (not species.is_sorted()) { species.RemoveDead(); } - const std::size_t nout = species.npart() / prtl_stride; - array_t buff_x1, buff_x2, buff_x3; - array_t buff_ux1 { "u1", nout }; - array_t buff_ux2 { "ux2", nout }; - array_t buff_ux3 { "ux3", nout }; - array_t buff_wei { "w", nout }; + const npart_t nout = species.npart() / prtl_stride; + array_t buff_x1, buff_x2, buff_x3; + array_t buff_ux1 { "u1", nout }; + array_t buff_ux2 { "ux2", nout }; + array_t buff_ux3 { "ux3", nout }; + array_t buff_wei { "w", nout }; if constexpr (M::Dim == Dim::_1D or M::Dim == Dim::_2D or M::Dim == Dim::_3D) { buff_x1 = array_t { "x1", nout }; @@ -512,16 +512,16 @@ namespace ntt { local_domain->mesh.metric)); // clang-format on } - std::size_t offset = 0; - std::size_t glob_tot = nout; + npart_t offset = 0; + npart_t glob_tot = nout; #if defined(MPI_ENABLED) - auto glob_nout = std::vector(g_ndomains); + auto glob_nout = std::vector(g_ndomains); MPI_Allgather(&nout, 1, - mpi::get_type(), + mpi::get_type(), glob_nout.data(), 1, - mpi::get_type(), + mpi::get_type(), MPI_COMM_WORLD); glob_tot = 0; for (auto r = 0; r < g_mpi_size; ++r) { diff --git a/src/framework/parameters.cpp b/src/framework/parameters.cpp index 4a9b3056a..e3bddfd70 100644 --- a/src/framework/parameters.cpp +++ b/src/framework/parameters.cpp @@ -32,7 +32,7 @@ namespace ntt { template auto get_dx0_V0( - const std::vector& resolution, + const std::vector& resolution, const boundaries_t& extent, const std::map& params) -> std::pair { const auto metric = M(resolution, extent, params); @@ -78,9 +78,9 @@ namespace ntt { promiseToDefine("simulation.domain.decomposition"); /* [grid] --------------------------------------------------------------- */ - const auto res = toml::find>(toml_data, - "grid", - "resolution"); + const auto res = toml::find>(toml_data, + "grid", + "resolution"); raise::ErrorIf(res.size() < 1 || res.size() > 3, "invalid `grid.resolution`", HERE); @@ -198,7 +198,7 @@ namespace ntt { const auto def_pusher = (is_massless ? defaults::ph_pusher : defaults::em_pusher); const auto maxnpart_real = toml::find(sp, "maxnpart"); - const auto maxnpart = static_cast(maxnpart_real); + const auto maxnpart = static_cast(maxnpart_real); auto pusher = toml::find_or(sp, "pusher", std::string(def_pusher)); const auto npayloads = toml::find_or(sp, "n_payloads", @@ -335,7 +335,7 @@ namespace ntt { set("simulation.name", toml::find(toml_data, "simulation", "name")); set("simulation.runtime", - toml::find(toml_data, "simulation", "runtime")); + toml::find(toml_data, "simulation", "runtime")); /* [grid.boundaraies] --------------------------------------------------- */ auto flds_bc = toml::find>>( @@ -454,7 +454,7 @@ namespace ntt { set("output.interval", toml::find_or(toml_data, "output", "interval", defaults::output::interval)); set("output.interval_time", - toml::find_or(toml_data, "output", "interval_time", -1.0)); + toml::find_or(toml_data, "output", "interval_time", -1.0)); set("output.separate_files", toml::find_or(toml_data, "output", "separate_files", true)); @@ -542,23 +542,23 @@ namespace ntt { // intervals for (const auto& type : { "fields", "particles", "spectra" }) { - const auto q_int = toml::find_or(toml_data, - "output", - std::string(type), - "interval", - 0); - const auto q_int_time = toml::find_or(toml_data, - "output", - std::string(type), - "interval_time", - -1.0); + const auto q_int = toml::find_or(toml_data, + "output", + std::string(type), + "interval", + 0); + const auto q_int_time = toml::find_or(toml_data, + "output", + std::string(type), + "interval_time", + -1.0); set("output." + std::string(type) + ".enable", toml::find_or(toml_data, "output", std::string(type), "enable", true)); if (q_int == 0 && q_int_time == -1.0) { set("output." + std::string(type) + ".interval", - get("output.interval")); + get("output.interval")); set("output." + std::string(type) + ".interval_time", - get("output.interval_time")); + get("output.interval_time")); } else { set("output." + std::string(type) + ".interval", q_int); set("output." + std::string(type) + ".interval_time", q_int_time); @@ -590,7 +590,7 @@ namespace ntt { "interval", defaults::checkpoint::interval)); set("checkpoint.interval_time", - toml::find_or(toml_data, "checkpoint", "interval_time", -1.0)); + toml::find_or(toml_data, "checkpoint", "interval_time", -1.0)); set("checkpoint.keep", toml::find_or(toml_data, "checkpoint", "keep", defaults::checkpoint::keep)); @@ -888,9 +888,9 @@ namespace ntt { } } - void SimulationParams::setCheckpointParams(bool is_resuming, - std::size_t start_step, - long double start_time) { + void SimulationParams::setCheckpointParams(bool is_resuming, + timestep_t start_step, + simtime_t start_time) { set("checkpoint.is_resuming", is_resuming); set("checkpoint.start_step", start_step); set("checkpoint.start_time", start_time); diff --git a/src/framework/parameters.h b/src/framework/parameters.h index 0f9e29370..83192f447 100644 --- a/src/framework/parameters.h +++ b/src/framework/parameters.h @@ -37,7 +37,7 @@ namespace ntt { void setImmutableParams(const toml::value&); void setMutableParams(const toml::value&); - void setCheckpointParams(bool, std::size_t, long double); + void setCheckpointParams(bool, timestep_t, simtime_t); void setSetupParams(const toml::value&); void checkPromises() const; diff --git a/src/framework/simulation.cpp b/src/framework/simulation.cpp index 9961eb3eb..bea50ff09 100644 --- a/src/framework/simulation.cpp +++ b/src/framework/simulation.cpp @@ -40,9 +40,9 @@ namespace ntt { fmt::toLower(toml::find(raw_params, "grid", "metric", "metric")) .c_str()); - const auto res = toml::find>(raw_params, - "grid", - "resolution"); + const auto res = toml::find>(raw_params, + "grid", + "resolution"); raise::ErrorIf(res.size() < 1 || res.size() > 3, "invalid `grid.resolution`", HERE); @@ -51,7 +51,7 @@ namespace ntt { // !TODO: when mixing checkpoint metadata with input, // ... need to properly take care of the diffs m_params.setRawData(raw_params); - std::size_t checkpoint_step = 0; + timestep_t checkpoint_step = 0; if (is_resuming) { logger::Checkpoint("Reading params from a checkpoint", HERE); if (not std::filesystem::exists("checkpoints")) { @@ -61,7 +61,7 @@ namespace ntt { std::filesystem::directory_iterator("checkpoints")) { const auto fname = entry.path().filename().string(); if (fname.find("step-") == 0) { - const std::size_t step = std::stoi(fname.substr(5, fname.size() - 5 - 3)); + const timestep_t step = std::stoi(fname.substr(5, fname.size() - 5 - 3)); if (step > checkpoint_step) { checkpoint_step = step; } @@ -78,9 +78,9 @@ namespace ntt { } logger::Checkpoint(fmt::format("Using %08lu", checkpoint_step), HERE); const auto raw_checkpoint_params = toml::parse(checkpoint_inputfname); - const auto start_time = toml::find(raw_checkpoint_params, - "metadata", - "time"); + const auto start_time = toml::find(raw_checkpoint_params, + "metadata", + "time"); m_params.setImmutableParams(raw_checkpoint_params); m_params.setMutableParams(raw_params); m_params.setCheckpointParams(true, checkpoint_step, start_time); diff --git a/src/framework/tests/comm_mpi.cpp b/src/framework/tests/comm_mpi.cpp index 2f65defd6..5d2c8d4f0 100644 --- a/src/framework/tests/comm_mpi.cpp +++ b/src/framework/tests/comm_mpi.cpp @@ -15,7 +15,7 @@ auto main(int argc, char* argv[]) -> int { Kokkos::initialize(argc, argv); try { - const std::size_t nx1 = 15, nx2 = 15; + const ncells_t nx1 = 15, nx2 = 15; ndfield_t fld_b1 { "fld", nx1 + 2 * N_GHOSTS, nx2 + 2 * N_GHOSTS }; ndfield_t fld_b2 { "fld", nx1 + 2 * N_GHOSTS, nx2 + 2 * N_GHOSTS }; @@ -58,4 +58,4 @@ auto main(int argc, char* argv[]) -> int { Kokkos::finalize(); return 0; -} \ No newline at end of file +} diff --git a/src/framework/tests/metadomain.cpp b/src/framework/tests/metadomain.cpp index 8f5865499..829a2b82f 100644 --- a/src/framework/tests/metadomain.cpp +++ b/src/framework/tests/metadomain.cpp @@ -22,31 +22,31 @@ auto main(int argc, char* argv[]) -> int { using namespace ntt; using namespace metric; { - const std::vector res { 64, 32 }; - const boundaries_t extent { - {1.0, 10.0}, - {0.0, constant::PI} + const std::vector res { 64, 32 }; + const boundaries_t extent { + { 1.0, 10.0 }, + { 0.0, constant::PI } }; const boundaries_t fldsbc { - {FldsBC::ATMOSPHERE, FldsBC::ABSORB}, - { FldsBC::AXIS, FldsBC::AXIS} + { FldsBC::ATMOSPHERE, FldsBC::MATCH }, + { FldsBC::AXIS, FldsBC::AXIS } }; const boundaries_t prtlbc { - {PrtlBC::ATMOSPHERE, PrtlBC::ABSORB}, - { PrtlBC::AXIS, PrtlBC::AXIS} + { PrtlBC::ATMOSPHERE, PrtlBC::ABSORB }, + { PrtlBC::AXIS, PrtlBC::AXIS } }; const std::map params { - {"r0", -ONE}, - { "h", (real_t)0.25} + { "r0", -ONE }, + { "h", (real_t)0.25 } }; #if defined(OUTPUT_ENABLED) Metadomain> metadomain { - 4, { -1, -1 }, - res, extent, fldsbc, prtlbc, params, {}, "disabled" + 4u, { -1, -1 }, + res, extent, fldsbc, prtlbc, params, {} }; #else Metadomain> metadomain { - 4, { -1, -1 }, + 4u, { -1, -1 }, res, extent, fldsbc, prtlbc, params, {} }; #endif @@ -132,7 +132,7 @@ auto main(int argc, char* argv[]) -> int { raise::ErrorIf(self.offset_ndomains()[0] != 1, "Domain::offset_ndomains() failed", HERE); - raise::ErrorIf(self.mesh.flds_bc_in({ +1, 0 }) != FldsBC::ABSORB, + raise::ErrorIf(self.mesh.flds_bc_in({ +1, 0 }) != FldsBC::MATCH, "Mesh::flds_bc_in() failed", HERE); raise::ErrorIf(self.mesh.prtl_bc_in({ +1, 0 }) != PrtlBC::ABSORB, @@ -203,4 +203,4 @@ auto main(int argc, char* argv[]) -> int { } Kokkos::finalize(); return 0; -} \ No newline at end of file +} diff --git a/src/global/arch/directions.h b/src/global/arch/directions.h index ccd4e67b0..2ea009814 100644 --- a/src/global/arch/directions.h +++ b/src/global/arch/directions.h @@ -50,14 +50,14 @@ namespace dir { auto operator-() const -> direction_t { auto result = direction_t {}; - for (std::size_t i = 0; i < (short)D; ++i) { + for (auto i = 0u; i < (unsigned short)D; ++i) { result[i] = -(*this)[i]; } return result; } auto operator==(const direction_t& other) const -> bool { - for (std::size_t i = 0; i < (short)D; ++i) { + for (auto i = 0u; i < (unsigned short)D; ++i) { if ((*this)[i] != other[i]) { return false; } @@ -79,7 +79,7 @@ namespace dir { */ auto get_assoc_orth() const -> std::vector { auto result = std::vector {}; - for (std::size_t i = 0; i < this->size(); ++i) { + for (auto i = 0u; i < this->size(); ++i) { if ((*this)[i] != 0) { direction_t dir; dir[i] = (*this)[i]; @@ -91,7 +91,7 @@ namespace dir { auto get_sign() const -> short { short sign = 0; - for (std::size_t i = 0; i < this->size(); ++i) { + for (auto i = 0u; i < this->size(); ++i) { if ((*this)[i] != 0) { raise::ErrorIf(sign != 0, "Undefined signature for non-orth direction", @@ -105,7 +105,7 @@ namespace dir { auto get_dim() const -> in { short dir = -1; - for (std::size_t i = 0; i < this->size(); ++i) { + for (auto i = 0u; i < this->size(); ++i) { if ((*this)[i] != 0) { raise::ErrorIf(dir > 0, "Undefined dim for non-orth direction", HERE); dir = i; diff --git a/src/global/arch/kokkos_aliases.cpp b/src/global/arch/kokkos_aliases.cpp index 6c15e3d52..d6622b0e5 100644 --- a/src/global/arch/kokkos_aliases.cpp +++ b/src/global/arch/kokkos_aliases.cpp @@ -4,10 +4,14 @@ #include +auto CreateParticleRangePolicy(npart_t p1, npart_t p2) -> range_t { + return Kokkos::RangePolicy(p1, p2); +} + template <> auto CreateRangePolicy( - const tuple_t& i1, - const tuple_t& i2) -> range_t { + const tuple_t& i1, + const tuple_t& i2) -> range_t { index_t i1min = i1[0]; index_t i1max = i2[0]; return Kokkos::RangePolicy(i1min, i1max); @@ -15,8 +19,8 @@ auto CreateRangePolicy( template <> auto CreateRangePolicy( - const tuple_t& i1, - const tuple_t& i2) -> range_t { + const tuple_t& i1, + const tuple_t& i2) -> range_t { index_t i1min = i1[0]; index_t i1max = i2[0]; index_t i2min = i1[1]; @@ -27,8 +31,8 @@ auto CreateRangePolicy( template <> auto CreateRangePolicy( - const tuple_t& i1, - const tuple_t& i2) -> range_t { + const tuple_t& i1, + const tuple_t& i2) -> range_t { index_t i1min = i1[0]; index_t i1max = i2[0]; index_t i2min = i1[1]; @@ -42,8 +46,8 @@ auto CreateRangePolicy( template <> auto CreateRangePolicyOnHost( - const tuple_t& i1, - const tuple_t& i2) -> range_h_t { + const tuple_t& i1, + const tuple_t& i2) -> range_h_t { index_t i1min = i1[0]; index_t i1max = i2[0]; return Kokkos::RangePolicy(i1min, i1max); @@ -51,8 +55,8 @@ auto CreateRangePolicyOnHost( template <> auto CreateRangePolicyOnHost( - const tuple_t& i1, - const tuple_t& i2) -> range_h_t { + const tuple_t& i1, + const tuple_t& i2) -> range_h_t { index_t i1min = i1[0]; index_t i1max = i2[0]; index_t i2min = i1[1]; @@ -63,8 +67,8 @@ auto CreateRangePolicyOnHost( template <> auto CreateRangePolicyOnHost( - const tuple_t& i1, - const tuple_t& i2) -> range_h_t { + const tuple_t& i1, + const tuple_t& i2) -> range_h_t { index_t i1min = i1[0]; index_t i1max = i2[0]; index_t i2min = i1[1]; diff --git a/src/global/arch/kokkos_aliases.h b/src/global/arch/kokkos_aliases.h index f9aac9685..e1a759bed 100644 --- a/src/global/arch/kokkos_aliases.h +++ b/src/global/arch/kokkos_aliases.h @@ -219,27 +219,34 @@ namespace kokkos_aliases_hidden { template using range_h_t = typename kokkos_aliases_hidden::range_h_impl::type; +/** + * @brief Function template for generating 1D Kokkos range policy for particles. + * @param p1 `npart_t`: min. + * @param p2 `npart_t`: max. + */ +auto CreateParticleRangePolicy(npart_t, npart_t) -> range_t; + /** * @brief Function template for generating ND Kokkos range policy. * @tparam D Dimension - * @param i1 array of size D `std::size_t`: { min }. - * @param i2 array of size D `std::size_t`: { max }. + * @param i1 array of size D `ncells_t`: { min }. + * @param i2 array of size D `ncells_t`: { max }. * @returns Kokkos::RangePolicy or Kokkos::MDRangePolicy in the accelerator execution space. */ template -auto CreateRangePolicy(const tuple_t&, - const tuple_t&) -> range_t; +auto CreateRangePolicy(const tuple_t&, + const tuple_t&) -> range_t; /** * @brief Function template for generating ND Kokkos range policy on the host. * @tparam D Dimension - * @param i1 array of size D `std::size_t`: { min }. - * @param i2 array of size D `std::size_t`: { max }. + * @param i1 array of size D `ncells_t`: { min }. + * @param i2 array of size D `ncells_t`: { max }. * @returns Kokkos::RangePolicy or Kokkos::MDRangePolicy in the host execution space. */ template -auto CreateRangePolicyOnHost(const tuple_t&, - const tuple_t&) -> range_h_t; +auto CreateRangePolicyOnHost(const tuple_t&, + const tuple_t&) -> range_h_t; // Random number pool/generator type alias using random_number_pool_t = Kokkos::Random_XorShift1024_Pool; diff --git a/src/global/defaults.h b/src/global/defaults.h index f44fd1844..b81369022 100644 --- a/src/global/defaults.h +++ b/src/global/defaults.h @@ -24,7 +24,7 @@ namespace ntt::defaults { const std::string em_pusher = "Boris"; const std::string ph_pusher = "Photon"; - const std::size_t clear_interval = 100; + const timestep_t clear_interval = 100; namespace qsph { const real_t r0 = 0.0; @@ -53,9 +53,9 @@ namespace ntt::defaults { namespace output { const std::string format = "hdf5"; - const std::size_t interval = 100; + const timestep_t interval = 100; const unsigned short mom_smooth = 0; - const std::size_t prtl_stride = 100; + const npart_t prtl_stride = 100; const real_t spec_emin = 1e-3; const real_t spec_emax = 1e3; const bool spec_log = true; @@ -63,12 +63,12 @@ namespace ntt::defaults { } // namespace output namespace checkpoint { - const std::size_t interval = 1000; - const int keep = 2; + const timestep_t interval = 1000; + const int keep = 2; } // namespace checkpoint namespace diag { - const std::size_t interval = 1; + const timestep_t interval = 1; } // namespace diag namespace gca { diff --git a/src/global/enums.h b/src/global/enums.h index 8f2495c13..5860f8346 100644 --- a/src/global/enums.h +++ b/src/global/enums.h @@ -56,7 +56,7 @@ namespace ntt { const char* const* arr_c, const std::size_t n, const char* elem) -> T { - for (std::size_t i = 0; i < n; ++i) { + for (auto i = 0u; i < n; ++i) { if (strcmp(arr_c[i], elem) == 0) { return (T)(arr[i]); } @@ -70,7 +70,7 @@ namespace ntt { constexpr auto baseContains(const char* const* arr_c, const std::size_t n, const char* elem) -> bool { - for (std::size_t i = 0; i < n; ++i) { + for (auto i = 0u; i < n; ++i) { if (strcmp(arr_c[i], elem) == 0) { return true; } diff --git a/src/global/global.h b/src/global/global.h index 77fa8c51c..577b13f1a 100644 --- a/src/global/global.h +++ b/src/global/global.h @@ -92,6 +92,7 @@ #ifndef GLOBAL_GLOBAL_H #define GLOBAL_GLOBAL_H +#include #include #include #include @@ -111,7 +112,7 @@ namespace files { namespace ntt { - inline constexpr unsigned int N_GHOSTS = 2; + inline constexpr std::size_t N_GHOSTS = 2; // Coordinate shift to account for ghost cells #define COORD(I) \ (static_cast(static_cast((I)) - static_cast(N_GHOSTS))) @@ -339,10 +340,19 @@ using coord_t = tuple_t; template using vec_t = tuple_t; +// time/duration +using timestamp_t = std::chrono::time_point; +using duration_t = double; +using simtime_t = double; +using timestep_t = std::size_t; +using ncells_t = std::size_t; +using npart_t = unsigned long long int; + +// index/number using index_t = const std::size_t; using idx_t = unsigned short; -using range_tuple_t = std::pair; +using range_tuple_t = std::pair; template using boundaries_t = std::vector>; diff --git a/src/global/utils/diag.cpp b/src/global/utils/diag.cpp index c053cdacf..fbd0c4215 100644 --- a/src/global/utils/diag.cpp +++ b/src/global/utils/diag.cpp @@ -22,9 +22,9 @@ namespace diag { auto npart_stats( - std::size_t npart, - std::size_t maxnpart) -> std::vector> { - auto stats = std::vector>(); + npart_t npart, + npart_t maxnpart) -> std::vector> { + auto stats = std::vector>(); #if !defined(MPI_ENABLED) stats.push_back( { npart, @@ -34,22 +34,22 @@ namespace diag { int rank, size; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); - std::vector mpi_npart(size, 0); - std::vector mpi_maxnpart(size, 0); + std::vector mpi_npart(size, 0); + std::vector mpi_maxnpart(size, 0); MPI_Gather(&npart, 1, - mpi::get_type(), + mpi::get_type(), mpi_npart.data(), 1, - mpi::get_type(), + mpi::get_type(), MPI_ROOT_RANK, MPI_COMM_WORLD); MPI_Gather(&maxnpart, 1, - mpi::get_type(), + mpi::get_type(), mpi_maxnpart.data(), 1, - mpi::get_type(), + mpi::get_type(), MPI_ROOT_RANK, MPI_COMM_WORLD); if (rank != MPI_ROOT_RANK) { @@ -75,16 +75,16 @@ namespace diag { return stats; } - void printDiagnostics(std::size_t step, - std::size_t tot_steps, - long double time, - long double dt, + void printDiagnostics(timestep_t step, + timestep_t tot_steps, + simtime_t time, + simtime_t dt, timer::Timers& timers, pbar::DurationHistory& time_history, - std::size_t ncells, + ncells_t ncells, const std::vector& species_labels, - const std::vector& species_npart, - const std::vector& species_maxnpart, + const std::vector& species_npart, + const std::vector& species_maxnpart, bool print_prtl_clear, bool print_output, bool print_checkpoint, @@ -168,7 +168,7 @@ namespace diag { c_reset); }); #endif - for (std::size_t i = 0; i < species_labels.size(); ++i) { + for (auto i = 0u; i < species_labels.size(); ++i) { const auto part_stats = npart_stats(species_npart[i], species_maxnpart[i]); if (part_stats.size() == 0) { continue; diff --git a/src/global/utils/diag.h b/src/global/utils/diag.h index 30cca5705..6d3c5937d 100644 --- a/src/global/utils/diag.h +++ b/src/global/utils/diag.h @@ -39,16 +39,16 @@ namespace diag { * @param checkpoint (if true, checkpoint was written) * @param colorful_print (if true, print with colors) */ - void printDiagnostics(std::size_t, - std::size_t, - long double, - long double, + void printDiagnostics(timestep_t, + timestep_t, + simtime_t, + simtime_t, timer::Timers&, pbar::DurationHistory&, - std::size_t, + ncells_t, const std::vector&, - const std::vector&, - const std::vector&, + const std::vector&, + const std::vector&, bool, bool, bool, diff --git a/src/global/utils/param_container.cpp b/src/global/utils/param_container.cpp index 6e4f5e0f4..e1dd57c9e 100644 --- a/src/global/utils/param_container.cpp +++ b/src/global/utils/param_container.cpp @@ -32,8 +32,8 @@ namespace prm { } template - auto write(adios2::IO& io, const std::string& name, T var) - -> decltype(void(T()), void()) { + auto write(adios2::IO& io, const std::string& name, T var) -> decltype(void(T()), + void()) { io.DefineAttribute(name, var); } @@ -48,8 +48,8 @@ namespace prm { } template - auto write_pair(adios2::IO& io, const std::string& name, std::pair var) - -> typename std::enable_if::value, void>::type { + auto write_pair(adios2::IO& io, const std::string& name, std::pair var) -> + typename std::enable_if::value, void>::type { std::vector var_str; var_str.push_back(var.first.to_string()); var_str.push_back(var.second.to_string()); @@ -57,8 +57,9 @@ namespace prm { } template - auto write_pair(adios2::IO& io, const std::string& name, std::pair var) - -> decltype(void(T()), void()) { + auto write_pair(adios2::IO& io, + const std::string& name, + std::pair var) -> decltype(void(T()), void()) { std::vector var_vec; var_vec.push_back(var.first); var_vec.push_back(var.second); @@ -76,8 +77,9 @@ namespace prm { } template - auto write_vec(adios2::IO& io, const std::string& name, std::vector var) - -> decltype(void(T()), void()) { + auto write_vec(adios2::IO& io, + const std::string& name, + std::vector var) -> decltype(void(T()), void()) { io.DefineAttribute(name, var.data(), var.size()); } @@ -97,8 +99,8 @@ namespace prm { template auto write_vec_pair(adios2::IO& io, const std::string& name, - std::vector> var) - -> decltype(void(T()), void()) { + std::vector> var) -> decltype(void(T()), + void()) { std::vector var_vec; for (const auto& v : var) { var_vec.push_back(v.first); @@ -124,8 +126,8 @@ namespace prm { template auto write_vec_vec(adios2::IO& io, const std::string& name, - std::vector> var) - -> decltype(void(T()), void()) { + std::vector> var) -> decltype(void(T()), + void()) { std::vector var_vec; for (const auto& vec : var) { for (const auto& v : vec) { @@ -215,34 +217,36 @@ namespace prm { } void Parameters::write(adios2::IO& io) const { - register_write_function(); + register_write_function(); register_write_function(); + register_write_function(); + register_write_function(); register_write_function(); - register_write_function(); register_write_function(); register_write_function(); - register_write_function(); register_write_function(); + register_write_function(); + register_write_function(); register_write_function(); - register_write_function(); register_write_function(); + register_write_function(); + register_write_function(); register_write_function(); register_write_function(); register_write_function(); register_write_function(); register_write_function(); register_write_function(); - register_write_function(); - register_write_function(); - register_write_function_for_pair(); register_write_function_for_pair(); + register_write_function_for_pair(); + register_write_function_for_pair(); register_write_function_for_pair(); - register_write_function_for_pair(); register_write_function_for_pair(); register_write_function_for_pair(); - register_write_function_for_pair(); register_write_function_for_pair(); + register_write_function_for_pair(); + register_write_function_for_pair(); register_write_function_for_pair(); register_write_function_for_pair(); register_write_function_for_pair(); @@ -253,14 +257,15 @@ namespace prm { register_write_function_for_pair(); register_write_function_for_pair(); - register_write_function_for_vector(); register_write_function_for_vector(); + register_write_function_for_vector(); + register_write_function_for_vector(); register_write_function_for_vector(); - register_write_function_for_vector(); register_write_function_for_vector(); register_write_function_for_vector(); - register_write_function_for_vector(); register_write_function_for_vector(); + register_write_function_for_vector(); + register_write_function_for_vector(); register_write_function_for_vector(); register_write_function_for_vector(); register_write_function_for_vector(); @@ -271,14 +276,15 @@ namespace prm { register_write_function_for_vector(); register_write_function_for_vector(); - register_write_function_for_vector_of_pair(); register_write_function_for_vector_of_pair(); + register_write_function_for_vector_of_pair(); + register_write_function_for_vector_of_pair(); register_write_function_for_vector_of_pair(); - register_write_function_for_vector_of_pair(); register_write_function_for_vector_of_pair(); register_write_function_for_vector_of_pair(); - register_write_function_for_vector_of_pair(); register_write_function_for_vector_of_pair(); + register_write_function_for_vector_of_pair(); + register_write_function_for_vector_of_pair(); register_write_function_for_vector_of_pair(); register_write_function_for_vector_of_pair(); register_write_function_for_vector_of_pair(); @@ -289,14 +295,15 @@ namespace prm { register_write_function_for_vector_of_pair(); register_write_function_for_vector_of_pair(); - register_write_function_for_vector_of_vector(); register_write_function_for_vector_of_vector(); + register_write_function_for_vector_of_vector(); + register_write_function_for_vector_of_vector(); register_write_function_for_vector_of_vector(); - register_write_function_for_vector_of_vector(); register_write_function_for_vector_of_vector(); register_write_function_for_vector_of_vector(); - register_write_function_for_vector_of_vector(); register_write_function_for_vector_of_vector(); + register_write_function_for_vector_of_vector(); + register_write_function_for_vector_of_vector(); register_write_function_for_vector_of_vector(); register_write_function_for_vector_of_vector(); register_write_function_for_vector_of_vector(); @@ -307,14 +314,15 @@ namespace prm { register_write_function_for_vector_of_vector(); register_write_function_for_vector_of_vector(); - register_write_function_for_dict(); register_write_function_for_dict(); + register_write_function_for_dict(); + register_write_function_for_dict(); register_write_function_for_dict(); - register_write_function_for_dict(); register_write_function_for_dict(); register_write_function_for_dict(); - register_write_function_for_dict(); register_write_function_for_dict(); + register_write_function_for_dict(); + register_write_function_for_dict(); register_write_function_for_dict(); register_write_function_for_dict(); register_write_function_for_dict(); diff --git a/src/global/utils/progressbar.cpp b/src/global/utils/progressbar.cpp index 74f952382..eaa8118fc 100644 --- a/src/global/utils/progressbar.cpp +++ b/src/global/utils/progressbar.cpp @@ -1,5 +1,7 @@ #include "utils/progressbar.h" +#include "global.h" + #include "utils/error.h" #include "utils/formatting.h" @@ -19,14 +21,15 @@ namespace pbar { - auto normalize_duration_fmt(long double t, const std::string& u) - -> std::pair { - const std::vector> units { - {"µs", 1e0}, - { "ms", 1e3}, - { "s", 1e6}, - {"min", 6e7}, - { "hr", 3.6e9} + auto normalize_duration_fmt( + duration_t t, + const std::string& u) -> std::pair { + const std::vector> units { + { "µs", 1e0 }, + { "ms", 1e3 }, + { "s", 1e6 }, + { "min", 6e7 }, + { "hr", 3.6e9 } }; auto it = std::find_if(units.begin(), units.end(), [&u](const auto& pr) { return pr.first == u; @@ -51,17 +54,17 @@ namespace pbar { units[newu_idx].first }; } - auto to_human_readable(long double t, const std::string& u) -> std::string { + auto to_human_readable(duration_t t, const std::string& u) -> std::string { const auto [tt, tu] = normalize_duration_fmt(t, u); const auto t1 = static_cast(tt); - const auto t2 = tt - static_cast(t1); + const auto t2 = tt - static_cast(t1); const auto [tt2, tu2] = normalize_duration_fmt(t2, tu); return fmt::format("%d%s %d%s", t1, tu.c_str(), static_cast(tt2), tu2.c_str()); } auto ProgressBar(const DurationHistory& history, - std::size_t step, - std::size_t max_steps, + timestep_t step, + timestep_t max_steps, DiagFlags& flags) -> std::string { auto avg_duration = history.average(); @@ -69,13 +72,13 @@ namespace pbar { int rank, size; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); - std::vector mpi_avg_durations(size, 0.0); + std::vector mpi_avg_durations(size, 0.0); MPI_Gather(&avg_duration, 1, - mpi::get_type(), + mpi::get_type(), mpi_avg_durations.data(), 1, - mpi::get_type(), + mpi::get_type(), MPI_ROOT_RANK, MPI_COMM_WORLD); if (rank != MPI_ROOT_RANK) { @@ -88,11 +91,11 @@ namespace pbar { const auto avg = to_human_readable(avg_duration, "µs"); const auto elapsed = to_human_readable(history.elapsed(), "µs"); const auto remain = to_human_readable( - static_cast(max_steps - step) * avg_duration, + static_cast(max_steps - step) * avg_duration, "µs"); - const auto pct = static_cast(step) / - static_cast(max_steps); + const auto pct = static_cast(step) / + static_cast(max_steps); const int nfilled = std::min(static_cast(pct * params::width), params::width); const int nempty = params::width - nfilled; diff --git a/src/global/utils/progressbar.h b/src/global/utils/progressbar.h index f218bc3f4..588413cb4 100644 --- a/src/global/utils/progressbar.h +++ b/src/global/utils/progressbar.h @@ -38,7 +38,7 @@ namespace pbar { class DurationHistory { std::size_t capacity; - std::vector durations; + std::vector durations; const std::chrono::time_point start; std::chrono::time_point prev_start; @@ -60,30 +60,31 @@ namespace pbar { prev_start = now; } - auto average() const -> long double { + auto average() const -> duration_t { if (durations.size() > 0) { return std::accumulate(durations.begin(), durations.end(), 0.0) / - static_cast(durations.size()); + static_cast(durations.size()); } else { return 0.0; } } - auto elapsed() const -> long double { + auto elapsed() const -> duration_t { return std::chrono::duration_cast( std::chrono::system_clock::now() - start) .count(); } }; - auto normalize_duration_fmt(long double t, const std::string& u) - -> std::pair; + auto normalize_duration_fmt( + duration_t t, + const std::string& u) -> std::pair; - auto to_human_readable(long double t, const std::string& u) -> std::string; + auto to_human_readable(duration_t t, const std::string& u) -> std::string; auto ProgressBar(const DurationHistory& history, - std::size_t step, - std::size_t max_steps, + timestep_t step, + timestep_t max_steps, DiagFlags& flags) -> std::string; } // namespace pbar diff --git a/src/global/utils/timer.cpp b/src/global/utils/timer.cpp index a12d79b96..d3c14d05e 100644 --- a/src/global/utils/timer.cpp +++ b/src/global/utils/timer.cpp @@ -1,5 +1,7 @@ #include "utils/timer.h" +#include "global.h" + #include "utils/colors.h" #include "utils/formatting.h" @@ -18,8 +20,8 @@ namespace timer { auto Timers::gather(const std::vector& ignore_in_tot, - std::size_t npart, - std::size_t ncells) const + npart_t npart, + ncells_t ncells) const -> std::map> { auto timer_stats = std::map< @@ -44,22 +46,22 @@ namespace timer { MPI_COMM_WORLD); } // accumulate nparts and ncells from MPI blocks - auto all_nparts = std::vector(size, 0); - auto all_ncells = std::vector(size, 0); + auto all_nparts = std::vector(size, 0); + auto all_ncells = std::vector(size, 0); MPI_Gather(&npart, 1, - mpi::get_type(), + mpi::get_type(), all_nparts.data(), 1, - mpi::get_type(), + mpi::get_type(), MPI_ROOT_RANK, MPI_COMM_WORLD); MPI_Gather(&ncells, 1, - mpi::get_type(), + mpi::get_type(), all_ncells.data(), 1, - mpi::get_type(), + mpi::get_type(), MPI_ROOT_RANK, MPI_COMM_WORLD); if (rank != MPI_ROOT_RANK) { @@ -128,9 +130,9 @@ namespace timer { return timer_stats; } - auto Timers::printAll(TimerFlags flags, - std::size_t npart, - std::size_t ncells) const -> std::string { + auto Timers::printAll(TimerFlags flags, + npart_t npart, + ncells_t ncells) const -> std::string { const std::vector extras { "PrtlClear", "Output", "Checkpoint" }; const auto stats = gather(extras, npart, ncells); if (stats.empty()) { diff --git a/src/global/utils/timer.h b/src/global/utils/timer.h index 3e9c1433e..8abe8ab0a 100644 --- a/src/global/utils/timer.h +++ b/src/global/utils/timer.h @@ -41,8 +41,6 @@ #include namespace timer { - using timestamp = std::chrono::time_point; - using duration_t = long double; inline void convertTime(duration_t& value, std::string& units) { if (value > 1e6) { @@ -58,10 +56,10 @@ namespace timer { } class Timers { - std::map> m_timers; - std::vector m_names; - const bool m_blocking; - const std::function m_synchronize; + std::map> m_timers; + std::vector m_names; + const bool m_blocking; + const std::function m_synchronize; public: Timers(std::initializer_list names, @@ -75,7 +73,7 @@ namespace timer { for (const auto& name : names) { m_timers.insert({ name, - {std::chrono::system_clock::now(), 0.0} + { std::chrono::system_clock::now(), 0.0 } }); m_names.push_back(name); } @@ -89,7 +87,9 @@ namespace timer { void stop(const std::string& name) { if (m_blocking) { - m_synchronize(); + if (m_synchronize != nullptr) { + m_synchronize(); + } #if defined(MPI_ENABLED) MPI_Barrier(MPI_COMM_WORLD); #endif @@ -139,15 +139,15 @@ namespace timer { */ [[nodiscard]] auto gather(const std::vector& ignore_in_tot, - std::size_t npart, - std::size_t ncells) const + npart_t npart, + ncells_t ncells) const -> std::map>; [[nodiscard]] - auto printAll(TimerFlags flags = Timer::Default, - std::size_t npart = 0, - std::size_t ncells = 0) const -> std::string; + auto printAll(TimerFlags flags = Timer::Default, + npart_t npart = 0, + ncells_t ncells = 0) const -> std::string; }; } // namespace timer diff --git a/src/global/utils/tools.h b/src/global/utils/tools.h index 30687d01b..95765e2de 100644 --- a/src/global/utils/tools.h +++ b/src/global/utils/tools.h @@ -4,10 +4,10 @@ * @implements * - tools::ArrayImbalance -> unsigned short * - tools::TensorProduct<> -> boundaries_t - * - tools::decompose1D -> std::vector + * - tools::decompose1D -> std::vector * - tools::divideInProportions2D -> std::tuple * - tools::divideInProportions3D -> std::tuple - * - tools::Decompose -> std::vector> + * - tools::Decompose -> std::vector> * - tools::Tracker * @namespaces: * - tools:: @@ -60,8 +60,8 @@ namespace tools { * @return Tensor product of list */ template - inline auto TensorProduct(const std::vector>& list) - -> std::vector> { + inline auto TensorProduct( + const std::vector>& list) -> std::vector> { std::vector> result = { {} }; for (const auto& sublist : list) { std::vector> temp; @@ -81,16 +81,16 @@ namespace tools { * @param ndomains Number of domains * @param ncells Number of cells */ - inline auto decompose1D(unsigned int ndomains, std::size_t ncells) - -> std::vector { - auto size = (std::size_t)((double)ncells / (double)ndomains); - auto ncells_domain = std::vector(ndomains, size); - for (std::size_t i { 0 }; i < ncells - size * ndomains; ++i) { + inline auto decompose1D(unsigned int ndomains, + ncells_t ncells) -> std::vector { + auto size = (ncells_t)((double)ncells / (double)ndomains); + auto ncells_domain = std::vector(ndomains, size); + for (auto i { 0u }; i < ncells - size * ndomains; ++i) { ncells_domain[i] += 1; } auto sum = std::accumulate(ncells_domain.begin(), ncells_domain.end(), - (std::size_t)0); + (ncells_t)0); raise::ErrorIf(sum != ncells, "Decomposition error: sum != ncells", HERE); raise::ErrorIf(ncells_domain.size() != (std::size_t)ndomains, "Decomposition error: size != ndomains", @@ -107,8 +107,10 @@ namespace tools { * @param s1 Proportion of the first dimension * @param s2 Proportion of the second dimension */ - inline auto divideInProportions2D(unsigned int ntot, unsigned int s1, unsigned int s2) - -> std::tuple { + inline auto divideInProportions2D( + unsigned int ntot, + unsigned int s1, + unsigned int s2) -> std::tuple { auto n1 = (unsigned int)(std::sqrt((double)ntot * (double)s1 / (double)s2)); if (n1 == 0) { return { 1, ntot }; @@ -130,11 +132,11 @@ namespace tools { * @param s2 Proportion of the second dimension * @param s3 Proportion of the third dimension */ - inline auto divideInProportions3D(unsigned int ntot, - unsigned int s1, - unsigned int s2, - unsigned int s3) - -> std::tuple { + inline auto divideInProportions3D( + unsigned int ntot, + unsigned int s1, + unsigned int s2, + unsigned int s3) -> std::tuple { auto n1 = (unsigned int)(std::cbrt( (double)ntot * (double)(SQR(s1)) / (double)(s2 * s3))); if (n1 > ntot) { @@ -163,10 +165,10 @@ namespace tools { * * @note If decomposition has -1, it will be calculated automatically */ - inline auto Decompose(unsigned int ndomains, - const std::vector& ncells, - const std::vector& decomposition) - -> std::vector> { + inline auto Decompose( + unsigned int ndomains, + const std::vector& ncells, + const std::vector& decomposition) -> std::vector> { const auto dimension = ncells.size(); raise::ErrorIf(dimension != decomposition.size(), "Decomposition error: dimension != decomposition.size", @@ -277,16 +279,16 @@ namespace tools { bool m_initialized { false }; std::string m_type; - std::size_t m_interval; - long double m_interval_time; + timestep_t m_interval; + simtime_t m_interval_time; bool m_use_time; - long double m_last_output_time { -1.0 }; + simtime_t m_last_output_time { -1.0 }; public: Tracker() = default; - Tracker(const std::string& type, std::size_t interval, long double interval_time) + Tracker(const std::string& type, timestep_t interval, simtime_t interval_time) : m_initialized { true } , m_type { type } , m_interval { interval } @@ -295,9 +297,7 @@ namespace tools { ~Tracker() = default; - void init(const std::string& type, - std::size_t interval, - long double interval_time) { + void init(const std::string& type, timestep_t interval, simtime_t interval_time) { m_type = type; m_interval = interval; m_interval_time = interval_time; @@ -305,7 +305,7 @@ namespace tools { m_initialized = true; } - auto shouldWrite(std::size_t step, long double time) -> bool { + auto shouldWrite(timestep_t step, simtime_t time) -> bool { raise::ErrorIf(!m_initialized, "Tracker not initialized", HERE); if (m_use_time) { if ((m_last_output_time < 0) or diff --git a/src/kernels/ampere_gr.hpp b/src/kernels/ampere_gr.hpp index 5af0fa4ef..782dece0d 100644 --- a/src/kernels/ampere_gr.hpp +++ b/src/kernels/ampere_gr.hpp @@ -37,7 +37,7 @@ namespace kernel::gr { ndfield_t Dout; const ndfield_t H; const M metric; - const std::size_t i2max; + const ncells_t i2max; const real_t coeff; bool is_axis_i2min { false }, is_axis_i2max { false }; @@ -47,7 +47,7 @@ namespace kernel::gr { const ndfield_t& H, const M& metric, real_t coeff, - std::size_t ni2, + ncells_t ni2, const boundaries_t& boundaries) : Din { Din } , Dout { Dout } @@ -67,9 +67,9 @@ namespace kernel::gr { Inline void operator()(index_t i1, index_t i2) const { if constexpr (D == Dim::_2D) { - constexpr std::size_t i2min { N_GHOSTS }; - const real_t i1_ { COORD(i1) }; - const real_t i2_ { COORD(i2) }; + constexpr ncells_t i2min { N_GHOSTS }; + const real_t i1_ { COORD(i1) }; + const real_t i2_ { COORD(i2) }; const real_t inv_sqrt_detH_0pH { ONE / metric.sqrt_det_h({ i1_, i2_ + HALF }) }; @@ -118,7 +118,7 @@ namespace kernel::gr { ndfield_t Df; const ndfield_t J; const M metric; - const std::size_t i2max; + const ncells_t i2max; const real_t coeff; bool is_axis_i2min { false }; bool is_axis_i2max { false }; @@ -132,7 +132,7 @@ namespace kernel::gr { const ndfield_t& J, const M& metric, real_t coeff, - std::size_t ni2, + ncells_t ni2, const boundaries_t& boundaries) : Df { Df } , J { J } @@ -148,9 +148,9 @@ namespace kernel::gr { Inline void operator()(index_t i1, index_t i2) const { if constexpr (D == Dim::_2D) { - constexpr std::size_t i2min { N_GHOSTS }; - const real_t i1_ { COORD(i1) }; - const real_t i2_ { COORD(i2) }; + constexpr ncells_t i2min { N_GHOSTS }; + const real_t i1_ { COORD(i1) }; + const real_t i2_ { COORD(i2) }; const real_t inv_sqrt_detH_0pH { ONE / metric.sqrt_det_h({ i1_, i2_ + HALF }) }; diff --git a/src/kernels/ampere_sr.hpp b/src/kernels/ampere_sr.hpp index e4faec6ce..dbe9d3dbf 100644 --- a/src/kernels/ampere_sr.hpp +++ b/src/kernels/ampere_sr.hpp @@ -32,17 +32,17 @@ namespace kernel::sr { static_assert(M::is_metric, "M must be a metric class"); static constexpr auto D = M::Dim; - ndfield_t EB; - const M metric; - const std::size_t i2max; - const real_t coeff; - bool is_axis_i2min { false }, is_axis_i2max { false }; + ndfield_t EB; + const M metric; + const ncells_t i2max; + const real_t coeff; + bool is_axis_i2min { false }, is_axis_i2max { false }; public: Ampere_kernel(const ndfield_t& EB, const M& metric, real_t coeff, - std::size_t ni2, + ncells_t ni2, const boundaries_t& boundaries) : EB { EB } , metric { metric } @@ -57,9 +57,9 @@ namespace kernel::sr { Inline void operator()(index_t i1, index_t i2) const { if constexpr (D == Dim::_2D) { - constexpr std::size_t i2min { N_GHOSTS }; - const real_t i1_ { COORD(i1) }; - const real_t i2_ { COORD(i2) }; + constexpr ncells_t i2min { N_GHOSTS }; + const real_t i1_ { COORD(i1) }; + const real_t i2_ { COORD(i2) }; const real_t inv_sqrt_detH_0pH { ONE / metric.sqrt_det_h({ i1_, i2_ + HALF }) }; @@ -122,18 +122,18 @@ namespace kernel::sr { */ template class CurrentsAmpere_kernel { - static constexpr auto D = M::Dim; - static constexpr std::size_t i2min = N_GHOSTS; + static constexpr auto D = M::Dim; + static constexpr ncells_t i2min = N_GHOSTS; - ndfield_t E; - ndfield_t J; - const M metric; - const std::size_t i2max; + ndfield_t E; + ndfield_t J; + const M metric; + const ncells_t i2max; // coeff = -dt * q0 * n0 / B0 - const real_t coeff; - const real_t inv_n0; - bool is_axis_i2min { false }; - bool is_axis_i2max { false }; + const real_t coeff; + const real_t inv_n0; + bool is_axis_i2min { false }; + bool is_axis_i2max { false }; public: /** @@ -145,7 +145,7 @@ namespace kernel::sr { const M& metric, real_t coeff, real_t inv_n0, - std::size_t ni2, + ncells_t ni2, const boundaries_t& boundaries) : E { E } , J { J } diff --git a/src/kernels/comm.hpp b/src/kernels/comm.hpp index b280ce38b..7873870b1 100644 --- a/src/kernels/comm.hpp +++ b/src/kernels/comm.hpp @@ -24,35 +24,36 @@ namespace kernel::comm { template class PrepareOutgoingPrtls_kernel { - const array_t shifts_in_x1, shifts_in_x2, shifts_in_x3; - array_t outgoing_indices; + const array_t shifts_in_x1, shifts_in_x2, shifts_in_x3; + array_t outgoing_indices; - const std::size_t npart, npart_alive, npart_dead, ntags; + const npart_t npart, npart_alive, npart_dead; + const std::size_t ntags; array_t i1, i1_prev, i2, i2_prev, i3, i3_prev; const array_t tag; - const array_t tag_offsets; + const array_t tag_offsets; - array_t current_offset; + array_t current_offset; public: - PrepareOutgoingPrtls_kernel(const array_t& shifts_in_x1, - const array_t& shifts_in_x2, - const array_t& shifts_in_x3, - array_t& outgoing_indices, - std::size_t npart, - std::size_t npart_alive, - std::size_t npart_dead, - std::size_t ntags, - array_t& i1, - array_t& i1_prev, - array_t& i2, - array_t& i2_prev, - array_t& i3, - array_t& i3_prev, - const array_t& tag, - const array_t& tag_offsets) + PrepareOutgoingPrtls_kernel(const array_t& shifts_in_x1, + const array_t& shifts_in_x2, + const array_t& shifts_in_x3, + array_t& outgoing_indices, + npart_t npart, + npart_t npart_alive, + npart_t npart_dead, + std::size_t ntags, + array_t& i1, + array_t& i1_prev, + array_t& i2, + array_t& i2_prev, + array_t& i3, + array_t& i3_prev, + const array_t& tag, + const array_t& tag_offsets) : shifts_in_x1 { shifts_in_x1 } , shifts_in_x2 { shifts_in_x2 } , shifts_in_x3 { shifts_in_x3 } @@ -225,45 +226,45 @@ namespace kernel::comm { const array_t recv_buff_pld; const unsigned short NINTS, NREALS, NPRTLDX, NPLDS; - const std::size_t npart, npart_holes; + const npart_t npart, npart_holes; - array_t i1, i1_prev, i2, i2_prev, i3, i3_prev; - array_t dx1, dx1_prev, dx2, dx2_prev, dx3, dx3_prev; - array_t ux1, ux2, ux3, weight, phi; - array_t pld; - array_t tag; - const array_t outgoing_indices; + array_t i1, i1_prev, i2, i2_prev, i3, i3_prev; + array_t dx1, dx1_prev, dx2, dx2_prev, dx3, dx3_prev; + array_t ux1, ux2, ux3, weight, phi; + array_t pld; + array_t tag; + const array_t outgoing_indices; public: - ExtractReceivedPrtls_kernel(const array_t& recv_buff_int, - const array_t& recv_buff_real, - const array_t& recv_buff_prtldx, - const array_t& recv_buff_pld, - unsigned short NINTS, - unsigned short NREALS, - unsigned short NPRTLDX, - unsigned short NPLDS, - std::size_t npart, - array_t& i1, - array_t& i1_prev, - array_t& dx1, - array_t& dx1_prev, - array_t& i2, - array_t& i2_prev, - array_t& dx2, - array_t& dx2_prev, - array_t& i3, - array_t& i3_prev, - array_t& dx3, - array_t& dx3_prev, - array_t& ux1, - array_t& ux2, - array_t& ux3, - array_t& weight, - array_t& phi, - array_t& pld, - array_t& tag, - const array_t& outgoing_indices) + ExtractReceivedPrtls_kernel(const array_t& recv_buff_int, + const array_t& recv_buff_real, + const array_t& recv_buff_prtldx, + const array_t& recv_buff_pld, + unsigned short NINTS, + unsigned short NREALS, + unsigned short NPRTLDX, + unsigned short NPLDS, + npart_t npart, + array_t& i1, + array_t& i1_prev, + array_t& dx1, + array_t& dx1_prev, + array_t& i2, + array_t& i2_prev, + array_t& dx2, + array_t& dx2_prev, + array_t& i3, + array_t& i3_prev, + array_t& dx3, + array_t& dx3_prev, + array_t& ux1, + array_t& ux2, + array_t& ux3, + array_t& weight, + array_t& phi, + array_t& pld, + array_t& tag, + const array_t& outgoing_indices) : recv_buff_int { recv_buff_int } , recv_buff_real { recv_buff_real } , recv_buff_prtldx { recv_buff_prtldx } @@ -296,7 +297,7 @@ namespace kernel::comm { , outgoing_indices { outgoing_indices } {} Inline void operator()(index_t p) const { - std::size_t idx; + npart_t idx; if (p >= npart_holes) { idx = npart + p - npart_holes; } else { diff --git a/src/kernels/digital_filter.hpp b/src/kernels/digital_filter.hpp index 5d05fad2d..f01eb0fb8 100644 --- a/src/kernels/digital_filter.hpp +++ b/src/kernels/digital_filter.hpp @@ -19,7 +19,7 @@ #define FILTER_IN_I1(ARR, COMP, I, J) \ INV_2*(ARR)((I), (J), (COMP)) + \ - INV_4*((ARR)((I)-1, (J), (COMP)) + (ARR)((I) + 1, (J), (COMP))) + INV_4*((ARR)((I) - 1, (J), (COMP)) + (ARR)((I) + 1, (J), (COMP))) namespace kernel { using namespace ntt; @@ -30,12 +30,12 @@ namespace kernel { const ndfield_t buffer; bool is_axis_i2min { false }, is_axis_i2max { false }; static constexpr auto i2_min = N_GHOSTS; - const std::size_t i2_max; + const ncells_t i2_max; public: DigitalFilter_kernel(ndfield_t& array, const ndfield_t& buffer, - const std::size_t (&size_)[D], + const ncells_t (&size_)[D], const boundaries_t& boundaries) : array { array } , buffer { buffer } diff --git a/src/kernels/faraday_gr.hpp b/src/kernels/faraday_gr.hpp index 19eede5f2..7fb327e61 100644 --- a/src/kernels/faraday_gr.hpp +++ b/src/kernels/faraday_gr.hpp @@ -36,7 +36,7 @@ namespace kernel::gr { ndfield_t Bout; const ndfield_t E; const M metric; - const std::size_t i2max; + const ncells_t i2max; const real_t coeff; bool is_axis_i2min { false }; diff --git a/src/kernels/faraday_sr.hpp b/src/kernels/faraday_sr.hpp index 727974248..be3e60dd0 100644 --- a/src/kernels/faraday_sr.hpp +++ b/src/kernels/faraday_sr.hpp @@ -52,9 +52,9 @@ namespace kernel::sr { Inline void operator()(index_t i1, index_t i2) const { if constexpr (D == Dim::_2D) { - constexpr std::size_t i2min { N_GHOSTS }; - const real_t i1_ { COORD(i1) }; - const real_t i2_ { COORD(i2) }; + constexpr ncells_t i2min { N_GHOSTS }; + const real_t i1_ { COORD(i1) }; + const real_t i2_ { COORD(i2) }; const real_t inv_sqrt_detH_0pH { ONE / metric.sqrt_det_h({ i1_, i2_ + HALF }) }; diff --git a/src/kernels/fields_bcs.hpp b/src/kernels/fields_bcs.hpp index 363ff3ad2..dbb47f42c 100644 --- a/src/kernels/fields_bcs.hpp +++ b/src/kernels/fields_bcs.hpp @@ -493,11 +493,11 @@ namespace kernel::bc { */ template struct AxisBoundaries_kernel { - ndfield_t Fld; - const std::size_t i_edge; - const bool setE, setB; + ndfield_t Fld; + const ncells_t i_edge; + const bool setE, setB; - AxisBoundaries_kernel(ndfield_t Fld, std::size_t i_edge, BCTags tags) + AxisBoundaries_kernel(ndfield_t Fld, ncells_t i_edge, BCTags tags) : Fld { Fld } , i_edge { i_edge } , setE { tags & BC::Ex1 or tags & BC::Ex2 or tags & BC::Ex3 } @@ -558,15 +558,15 @@ namespace kernel::bc { static_cast(M::Dim), "Invalid Orientation"); - ndfield_t Fld; - const I fset; - const M metric; - const std::size_t i_edge; + ndfield_t Fld; + const I fset; + const M metric; + const ncells_t i_edge; EnforcedBoundaries_kernel(ndfield_t& Fld, const I& fset, const M& metric, - std::size_t i_edge, + ncells_t i_edge, BCTags tags) : Fld { Fld } , fset { fset } diff --git a/src/kernels/injectors.hpp b/src/kernels/injectors.hpp index 9d3fd7d81..09bc7a180 100644 --- a/src/kernels/injectors.hpp +++ b/src/kernels/injectors.hpp @@ -47,7 +47,7 @@ namespace kernel { array_t weights_2; array_t tags_2; - std::size_t offset1, offset2; + npart_t offset1, offset2; const M metric; const array_t ni; const ED energy_dist; @@ -58,8 +58,8 @@ namespace kernel { spidx_t spidx2, Particles& species1, Particles& species2, - std::size_t offset1, - std::size_t offset2, + npart_t offset1, + npart_t offset2, const M& metric, const array_t& ni, const ED& energy_dist, @@ -201,20 +201,20 @@ namespace kernel { array_t in_phi; array_t in_wei; - array_t idx { "idx" }; - array_t i1s, i2s, i3s; - array_t dx1s, dx2s, dx3s; - array_t ux1s, ux2s, ux3s; - array_t phis; - array_t weights; - array_t tags; + array_t idx { "idx" }; + array_t i1s, i2s, i3s; + array_t dx1s, dx2s, dx3s; + array_t ux1s, ux2s, ux3s; + array_t phis; + array_t weights; + array_t tags; - const std::size_t offset; + const npart_t offset; M global_metric; - real_t x1_min, x1_max, x2_min, x2_max, x3_min, x3_max; - std::size_t i1_offset, i2_offset, i3_offset; + real_t x1_min, x1_max, x2_min, x2_max, x3_min, x3_max; + ncells_t i1_offset, i2_offset, i3_offset; GlobalInjector_kernel(Particles& species, const M& global_metric, @@ -269,18 +269,18 @@ namespace kernel { void copy_from_vector(const std::string& name, array_t& arr, const std::map>& data, - std::size_t n_inject) { + npart_t n_inject) { raise::ErrorIf(data.find(name) == data.end(), name + " not found in data", HERE); raise::ErrorIf(data.at(name).size() != n_inject, "Inconsistent data size", HERE); arr = array_t { name, n_inject }; auto arr_h = Kokkos::create_mirror_view(arr); - for (std::size_t i = 0; i < data.at(name).size(); ++i) { + for (auto i = 0u; i < data.at(name).size(); ++i) { arr_h(i) = data.at(name)[i]; } Kokkos::deep_copy(arr, arr_h); } - auto number_injected() const -> std::size_t { + auto number_injected() const -> npart_t { auto idx_h = Kokkos::create_mirror_view(idx); Kokkos::deep_copy(idx_h, idx); return idx_h(); @@ -298,7 +298,7 @@ namespace kernel { global_metric.template transform_xyz(x_Cd, u_Ph, u_XYZ); const auto i1 = static_cast( - static_cast(x_Cd[0]) - i1_offset); + static_cast(x_Cd[0]) - i1_offset); const auto dx1 = static_cast( x_Cd[0] - static_cast(i1 + i1_offset)); @@ -322,9 +322,8 @@ namespace kernel { vec_t u_Ph { in_ux1(p), in_ux2(p), in_ux3(p) }; coord_t x_Cd_ { ZERO }; - auto index { - offset + Kokkos::atomic_fetch_add(&idx(), static_cast(1)) - }; + auto index { offset + + Kokkos::atomic_fetch_add(&idx(), static_cast(1)) }; global_metric.template convert({ in_x1(p), in_x2(p) }, x_Cd); x_Cd_[0] = x_Cd[0]; @@ -340,11 +339,11 @@ namespace kernel { raise::KernelError(HERE, "Unknown simulation engine"); } const auto i1 = static_cast( - static_cast(x_Cd[0]) - i1_offset); + static_cast(x_Cd[0]) - i1_offset); const auto dx1 = static_cast( x_Cd[0] - static_cast(i1 + i1_offset)); const auto i2 = static_cast( - static_cast(x_Cd[1]) - i2_offset); + static_cast(x_Cd[1]) - i2_offset); const auto dx2 = static_cast( x_Cd[1] - static_cast(i2 + i2_offset)); @@ -385,15 +384,15 @@ namespace kernel { raise::KernelError(HERE, "Unknown simulation engine"); } const auto i1 = static_cast( - static_cast(x_Cd[0]) - i1_offset); + static_cast(x_Cd[0]) - i1_offset); const auto dx1 = static_cast( x_Cd[0] - static_cast(i1 + i1_offset)); const auto i2 = static_cast( - static_cast(x_Cd[1]) - i2_offset); + static_cast(x_Cd[1]) - i2_offset); const auto dx2 = static_cast( x_Cd[1] - static_cast(i2 + i2_offset)); const auto i3 = static_cast( - static_cast(x_Cd[2]) - i3_offset); + static_cast(x_Cd[2]) - i3_offset); const auto dx3 = static_cast( x_Cd[2] - static_cast(i3 + i3_offset)); @@ -440,9 +439,9 @@ namespace kernel { array_t weights_2; array_t tags_2; - array_t idx { "idx" }; + array_t idx { "idx" }; - std::size_t offset1, offset2; + npart_t offset1, offset2; M metric; const ED energy_dist; const SD spatial_dist; @@ -454,8 +453,8 @@ namespace kernel { spidx_t spidx2, Particles& species1, Particles& species2, - std::size_t offset1, - std::size_t offset2, + npart_t offset1, + npart_t offset2, const M& metric, const ED& energy_dist, const SD& spatial_dist, @@ -496,7 +495,7 @@ namespace kernel { , inv_V0 { inv_V0 } , random_pool { random_pool } {} - auto number_injected() const -> std::size_t { + auto number_injected() const -> npart_t { auto idx_h = Kokkos::create_mirror_view(idx); Kokkos::deep_copy(idx_h, idx); return idx_h(); @@ -508,7 +507,7 @@ namespace kernel { coord_t x_Cd { i1_ + HALF }; coord_t x_Ph { ZERO }; metric.template convert(x_Cd, x_Ph); - const auto ppc = static_cast(ppc0 * spatial_dist(x_Ph)); + const auto ppc = static_cast(ppc0 * spatial_dist(x_Ph)); if (ppc == 0) { return; } @@ -564,7 +563,7 @@ namespace kernel { x_Cd_[2] = ZERO; } metric.template convert(x_Cd, x_Ph); - const auto ppc = static_cast(ppc0 * spatial_dist(x_Ph)); + const auto ppc = static_cast(ppc0 * spatial_dist(x_Ph)); if (ppc == 0) { return; } @@ -631,7 +630,7 @@ namespace kernel { coord_t x_Cd { i1_ + HALF, i2_ + HALF, i3_ + HALF }; coord_t x_Ph { ZERO }; metric.template convert(x_Cd, x_Ph); - const auto ppc = static_cast(ppc0 * spatial_dist(x_Ph)); + const auto ppc = static_cast(ppc0 * spatial_dist(x_Ph)); if (ppc == 0) { return; } diff --git a/src/kernels/particle_moments.hpp b/src/kernels/particle_moments.hpp index 0621646ad..948e46e1e 100644 --- a/src/kernels/particle_moments.hpp +++ b/src/kernels/particle_moments.hpp @@ -86,7 +86,7 @@ namespace kernel { bool use_weights, const M& metric, const boundaries_t& boundaries, - std::size_t ni2, + ncells_t ni2, real_t inv_n0, unsigned short window) : c1 { (components.size() == 2) ? components[0] diff --git a/src/kernels/prtls_to_phys.hpp b/src/kernels/prtls_to_phys.hpp index f12eefc95..4dd7d88b0 100644 --- a/src/kernels/prtls_to_phys.hpp +++ b/src/kernels/prtls_to_phys.hpp @@ -31,7 +31,7 @@ namespace kernel { static constexpr Dimension D = M::Dim; protected: - const std::size_t stride; + const npart_t stride; array_t buff_x1; array_t buff_x2; array_t buff_x3; @@ -47,7 +47,7 @@ namespace kernel { const M metric; public: - PrtlToPhys_kernel(std::size_t stride, + PrtlToPhys_kernel(npart_t stride, array_t& buff_x1, array_t& buff_x2, array_t& buff_x3, diff --git a/src/metrics/kerr_schild.h b/src/metrics/kerr_schild.h index 5a60def53..13294dd7d 100644 --- a/src/metrics/kerr_schild.h +++ b/src/metrics/kerr_schild.h @@ -72,7 +72,7 @@ namespace metric { using MetricBase::nx3; using MetricBase::set_dxMin; - KerrSchild(std::vector res, + KerrSchild(std::vector res, boundaries_t ext, const std::map& params) : MetricBase { res, ext } diff --git a/src/metrics/kerr_schild_0.h b/src/metrics/kerr_schild_0.h index 70689f4f0..fdd2fd847 100644 --- a/src/metrics/kerr_schild_0.h +++ b/src/metrics/kerr_schild_0.h @@ -53,8 +53,8 @@ namespace metric { using MetricBase::nx3; using MetricBase::set_dxMin; - KerrSchild0(std::vector res, - boundaries_t ext, + KerrSchild0(std::vector res, + boundaries_t ext, const std::map& = {}) : MetricBase { res, ext } , dr { (x1_max - x1_min) / nx1 } diff --git a/src/metrics/metric_base.h b/src/metrics/metric_base.h index 321d39bbd..66cc28918 100644 --- a/src/metrics/metric_base.h +++ b/src/metrics/metric_base.h @@ -61,7 +61,7 @@ namespace metric { static constexpr bool is_metric { true }; static constexpr Dimension Dim { D }; - MetricBase(std::vector res, boundaries_t ext) + MetricBase(std::vector res, boundaries_t ext) : nx1 { res.size() > 0 ? (real_t)(res[0]) : ONE } , nx2 { res.size() > 1 ? (real_t)(res[1]) : ONE } , nx3 { res.size() > 2 ? (real_t)(res[2]) : ONE } diff --git a/src/metrics/minkowski.h b/src/metrics/minkowski.h index c22ac1ad9..367689e0f 100644 --- a/src/metrics/minkowski.h +++ b/src/metrics/minkowski.h @@ -47,8 +47,8 @@ namespace metric { using MetricBase::nx3; using MetricBase::set_dxMin; - Minkowski(std::vector res, - boundaries_t ext, + Minkowski(std::vector res, + boundaries_t ext, const std::map& = {}) : MetricBase { res, ext } , dx { (x1_max - x1_min) / nx1 } @@ -240,8 +240,7 @@ namespace metric { * @note tetrad/cart <-> cntrv <-> cov */ template - Inline auto transform(const coord_t& xi, const real_t& v_in) const - -> real_t { + Inline auto transform(const coord_t& xi, const real_t& v_in) const -> real_t { static_assert(i > 0 && i <= 3, "Invalid index i"); static_assert(in != out, "Invalid vector transformation"); if constexpr (i > static_cast(D)) { diff --git a/src/metrics/qkerr_schild.h b/src/metrics/qkerr_schild.h index d531b8b3b..d64fe05da 100644 --- a/src/metrics/qkerr_schild.h +++ b/src/metrics/qkerr_schild.h @@ -72,7 +72,7 @@ namespace metric { using MetricBase::nx3; using MetricBase::set_dxMin; - QKerrSchild(std::vector res, + QKerrSchild(std::vector res, boundaries_t ext, const std::map& params) : MetricBase { res, ext } diff --git a/src/metrics/qspherical.h b/src/metrics/qspherical.h index 8062f7589..4df5db866 100644 --- a/src/metrics/qspherical.h +++ b/src/metrics/qspherical.h @@ -55,7 +55,7 @@ namespace metric { using MetricBase::nx3; using MetricBase::set_dxMin; - QSpherical(std::vector res, + QSpherical(std::vector res, boundaries_t ext, const std::map& params) : MetricBase { res, ext } @@ -284,8 +284,7 @@ namespace metric { * @note tetrad/sph <-> cntrv <-> cov */ template - Inline auto transform(const coord_t& xi, const real_t& v_in) const - -> real_t { + Inline auto transform(const coord_t& xi, const real_t& v_in) const -> real_t { static_assert(i > 0 && i <= 3, "Invalid index i"); static_assert(in != out, "Invalid vector transformation"); if constexpr ((in == Idx::T && out == Idx::Sph) || diff --git a/src/metrics/spherical.h b/src/metrics/spherical.h index f4bbe2eea..54e12367d 100644 --- a/src/metrics/spherical.h +++ b/src/metrics/spherical.h @@ -50,8 +50,8 @@ namespace metric { using MetricBase::nx3; using MetricBase::set_dxMin; - Spherical(std::vector res, - boundaries_t ext, + Spherical(std::vector res, + boundaries_t ext, const std::map& = {}) : MetricBase { res, ext } , dr((x1_max - x1_min) / nx1) @@ -252,8 +252,7 @@ namespace metric { * @note tetrad/sph <-> cntrv <-> cov */ template - Inline auto transform(const coord_t& xi, const real_t& v_in) const - -> real_t { + Inline auto transform(const coord_t& xi, const real_t& v_in) const -> real_t { static_assert(i > 0 && i <= 3, "Invalid index i"); static_assert(in != out, "Invalid vector transformation"); if constexpr ((in == Idx::T && out == Idx::Sph) || diff --git a/src/output/fields.h b/src/output/fields.h index a520a246d..811c5adc2 100644 --- a/src/output/fields.h +++ b/src/output/fields.h @@ -112,7 +112,7 @@ namespace out { } [[nodiscard]] - inline auto name(const std::size_t& ci) const -> std::string { + inline auto name(std::size_t ci) const -> std::string { raise::ErrorIf( comp.size() == 0, "OutputField::name(ci) called but no components were available", diff --git a/src/output/tests/writer-nompi.cpp b/src/output/tests/writer-nompi.cpp index 8fb2ac026..b063539ca 100644 --- a/src/output/tests/writer-nompi.cpp +++ b/src/output/tests/writer-nompi.cpp @@ -103,22 +103,21 @@ auto main(int argc, char* argv[]) -> int { const auto layoutRight = io.InquireAttribute("LayoutRight").Data()[0] == 1; - raise::ErrorIf(io.InquireAttribute("NGhosts").Data()[0] != 0, + raise::ErrorIf(io.InquireAttribute("NGhosts").Data()[0] != 0, "NGhosts is not correct", HERE); raise::ErrorIf(io.InquireAttribute("Dimension").Data()[0] != 3, "Dimension is not correct", HERE); - for (std::size_t step = 0; reader.BeginStep() == adios2::StepStatus::OK; - ++step) { - std::size_t step_read; - long double time_read; + for (auto step = 0u; reader.BeginStep() == adios2::StepStatus::OK; ++step) { + timestep_t step_read; + simtime_t time_read; - reader.Get(io.InquireVariable("Step"), + reader.Get(io.InquireVariable("Step"), &step_read, adios2::Mode::Sync); - reader.Get(io.InquireVariable("Time"), + reader.Get(io.InquireVariable("Time"), &time_read, adios2::Mode::Sync); raise::ErrorIf(step_read != (step + 1) * 10, "Step is not correct", HERE); @@ -136,10 +135,10 @@ auto main(int argc, char* argv[]) -> int { fmt::format("%s is not 3D", name.c_str()), HERE); - auto dims = fieldVar.Shape(); - std::size_t nx1_r = dims[0]; - std::size_t nx2_r = dims[1]; - std::size_t nx3_r = dims[2]; + auto dims = fieldVar.Shape(); + ncells_t nx1_r = dims[0]; + ncells_t nx2_r = dims[1]; + ncells_t nx3_r = dims[2]; if (!layoutRight) { std::swap(nx1_r, nx3_r); } diff --git a/src/output/utils/attr_writer.h b/src/output/utils/attr_writer.h index 47f269d55..c8b21e4c2 100644 --- a/src/output/utils/attr_writer.h +++ b/src/output/utils/attr_writer.h @@ -40,7 +40,10 @@ namespace out { {typeid(int), defineAttribute}, {typeid(short), defineAttribute}, {typeid(unsigned int), defineAttribute}, - {typeid(std::size_t), defineAttribute}, + {typeid(long int), defineAttribute}, + {typeid(unsigned long int), defineAttribute}, + {typeid(long long int), defineAttribute}, + {typeid(unsigned long long int), defineAttribute}, {typeid(unsigned short), defineAttribute}, {typeid(float), defineAttribute}, {typeid(double), defineAttribute}, @@ -49,7 +52,10 @@ namespace out { {typeid(std::vector), defineAttribute>}, {typeid(std::vector), defineAttribute>}, {typeid(std::vector), defineAttribute>}, - {typeid(std::vector), defineAttribute>}, + {typeid(std::vector), defineAttribute>}, + {typeid(std::vector), defineAttribute>}, + {typeid(std::vector), defineAttribute>}, + {typeid(std::vector), defineAttribute>}, {typeid(std::vector), defineAttribute>}, {typeid(std::vector), defineAttribute>}, {typeid(std::vector), defineAttribute>}, diff --git a/src/output/writer.cpp b/src/output/writer.cpp index 95965c864..4350e8442 100644 --- a/src/output/writer.cpp +++ b/src/output/writer.cpp @@ -37,20 +37,20 @@ namespace out { m_io = p_adios->DeclareIO("Entity::Output"); m_io.SetEngine(engine); - m_io.DefineVariable("Step"); - m_io.DefineVariable("Time"); + m_io.DefineVariable("Step"); + m_io.DefineVariable("Time"); m_fname = title; } void Writer::addTracker(const std::string& type, - std::size_t interval, - long double interval_time) { + timestep_t interval, + simtime_t interval_time) { m_trackers.insert({ type, tools::Tracker(type, interval, interval_time) }); } auto Writer::shouldWrite(const std::string& type, - std::size_t step, - long double time) -> bool { + timestep_t step, + simtime_t time) -> bool { if (m_trackers.find(type) != m_trackers.end()) { return m_trackers.at(type).shouldWrite(step, time); } else { @@ -63,9 +63,9 @@ namespace out { m_mode = mode; } - void Writer::defineMeshLayout(const std::vector& glob_shape, - const std::vector& loc_corner, - const std::vector& loc_shape, + void Writer::defineMeshLayout(const std::vector& glob_shape, + const std::vector& loc_corner, + const std::vector& loc_shape, const std::vector& dwn, bool incl_ghosts, Coord coords) { @@ -76,7 +76,7 @@ namespace out { m_flds_l_corner = loc_corner; m_flds_l_shape = loc_shape; - for (std::size_t i { 0 }; i < glob_shape.size(); ++i) { + for (auto i { 0u }; i < glob_shape.size(); ++i) { raise::ErrorIf(dwn[i] != 1 && incl_ghosts, "Downsampling with ghosts not supported", HERE); @@ -86,18 +86,17 @@ namespace out { const double l = loc_corner[i]; const double n = loc_shape[i]; const double f = math::ceil(l / d) * d - l; - m_flds_g_shape_dwn.push_back(static_cast(math::ceil(g / d))); - m_flds_l_corner_dwn.push_back(static_cast(math::ceil(l / d))); - m_flds_l_first.push_back(static_cast(f)); - m_flds_l_shape_dwn.push_back( - static_cast(math::ceil((n - f) / d))); + m_flds_g_shape_dwn.push_back(static_cast(math::ceil(g / d))); + m_flds_l_corner_dwn.push_back(static_cast(math::ceil(l / d))); + m_flds_l_first.push_back(static_cast(f)); + m_flds_l_shape_dwn.push_back(static_cast(math::ceil((n - f) / d))); } m_io.DefineAttribute("NGhosts", incl_ghosts ? N_GHOSTS : 0); m_io.DefineAttribute("Dimension", m_flds_g_shape.size()); m_io.DefineAttribute("Coordinates", std::string(coords.to_string())); - for (std::size_t i { 0 }; i < m_flds_g_shape.size(); ++i) { + for (auto i { 0u }; i < m_flds_g_shape.size(); ++i) { // cell-centers adios2::Dims g_shape = { m_flds_g_shape_dwn[i] }; adios2::Dims l_corner = { m_flds_l_corner_dwn[i] }; @@ -151,7 +150,7 @@ namespace out { adios2::ConstantDims); } else { // vector or tensor - for (std::size_t i { 0 }; i < fld.comp.size(); ++i) { + for (auto i { 0u }; i < fld.comp.size(); ++i) { m_io.DefineVariable(fld.name(i), m_flds_g_shape_dwn, m_flds_l_corner_dwn, @@ -210,7 +209,7 @@ namespace out { const ndfield_t& field, std::size_t comp, std::vector dwn, - std::vector first_cell, + std::vector first_cell, bool ghosts) { // when dwn != 1 in any direction, it is assumed that ghosts == false auto var = io.InquireVariable(varname); @@ -230,7 +229,7 @@ namespace out { const double nx1_full = field.extent(0) - 2 * N_GHOSTS; const auto first_cell1 = first_cell[0]; - const auto nx1_dwn = static_cast( + const auto nx1_dwn = static_cast( math::ceil((nx1_full - first_cell1_d) / dwn1)); output_field = array_t { "output_field", nx1_dwn }; @@ -260,9 +259,9 @@ namespace out { const auto first_cell1 = first_cell[0]; const auto first_cell2 = first_cell[1]; - const auto nx1_dwn = static_cast( + const auto nx1_dwn = static_cast( math::ceil((nx1_full - first_cell1_d) / dwn1)); - const auto nx2_dwn = static_cast( + const auto nx2_dwn = static_cast( math::ceil((nx2_full - first_cell2_d) / dwn2)); output_field = array_t { "output_field", nx1_dwn, nx2_dwn }; Kokkos::parallel_for( @@ -299,11 +298,11 @@ namespace out { const auto first_cell2 = first_cell[1]; const auto first_cell3 = first_cell[2]; - const auto nx1_dwn = static_cast( + const auto nx1_dwn = static_cast( math::ceil((nx1_full - first_cell1_d) / dwn1)); - const auto nx2_dwn = static_cast( + const auto nx2_dwn = static_cast( math::ceil((nx2_full - first_cell2_d) / dwn2)); - const auto nx3_dwn = static_cast( + const auto nx3_dwn = static_cast( math::ceil((nx3_full - first_cell3_d) / dwn3)); output_field = array_t { "output_field", nx1_dwn, nx2_dwn, nx3_dwn }; @@ -333,7 +332,7 @@ namespace out { raise::ErrorIf(names.size() != addresses.size(), "# of names != # of addresses ", HERE); - for (std::size_t i { 0 }; i < addresses.size(); ++i) { + for (auto i { 0u }; i < addresses.size(); ++i) { WriteField(m_io, m_writer, names[i], @@ -346,8 +345,8 @@ namespace out { } void Writer::writeParticleQuantity(const array_t& array, - std::size_t glob_total, - std::size_t loc_offset, + npart_t glob_total, + npart_t loc_offset, const std::string& varname) { auto var = m_io.InquireVariable(varname); var.SetShape({ glob_total }); @@ -416,8 +415,8 @@ namespace out { } void Writer::beginWriting(WriteModeTags write_mode, - std::size_t tstep, - long double time) { + timestep_t tstep, + simtime_t time) { raise::ErrorIf(write_mode == WriteMode::None, "None is not a valid mode", HERE); raise::ErrorIf(p_adios == nullptr, "ADIOS pointer is null", HERE); if (m_active_mode != WriteMode::None) { @@ -468,8 +467,8 @@ namespace out { raise::Fatal(e.what(), HERE); } m_writer.BeginStep(); - m_writer.Put(m_io.InquireVariable("Step"), &tstep); - m_writer.Put(m_io.InquireVariable("Time"), &time); + m_writer.Put(m_io.InquireVariable("Step"), &tstep); + m_writer.Put(m_io.InquireVariable("Time"), &time); } void Writer::endWriting(WriteModeTags write_mode) { @@ -511,7 +510,7 @@ namespace out { const ndfield_t&, std::size_t, std::vector, - std::vector, + std::vector, bool); template void WriteField(adios2::IO&, adios2::Engine&, @@ -519,7 +518,7 @@ namespace out { const ndfield_t&, std::size_t, std::vector, - std::vector, + std::vector, bool); template void WriteField(adios2::IO&, adios2::Engine&, @@ -527,7 +526,7 @@ namespace out { const ndfield_t&, std::size_t, std::vector, - std::vector, + std::vector, bool); template void WriteField(adios2::IO&, adios2::Engine&, @@ -535,7 +534,7 @@ namespace out { const ndfield_t&, std::size_t, std::vector, - std::vector, + std::vector, bool); template void WriteField(adios2::IO&, adios2::Engine&, @@ -543,7 +542,7 @@ namespace out { const ndfield_t&, std::size_t, std::vector, - std::vector, + std::vector, bool); template void WriteField(adios2::IO&, adios2::Engine&, @@ -551,7 +550,7 @@ namespace out { const ndfield_t&, std::size_t, std::vector, - std::vector, + std::vector, bool); } // namespace out diff --git a/src/output/writer.h b/src/output/writer.h index a8abf4b12..5484aa6d7 100644 --- a/src/output/writer.h +++ b/src/output/writer.h @@ -39,16 +39,16 @@ namespace out { bool m_separate_files; // global shape of the fields array to output - std::vector m_flds_g_shape; + std::vector m_flds_g_shape; // local corner of the fields array to output - std::vector m_flds_l_corner; + std::vector m_flds_l_corner; // local shape of the fields array to output - std::vector m_flds_l_shape; + std::vector m_flds_l_shape; // downsampling factors for each dimension std::vector m_dwn; // starting cell in each dimension (not including ghosts) - std::vector m_flds_l_first; + std::vector m_flds_l_first; // same but downsampled adios2::Dims m_flds_g_shape_dwn; @@ -78,14 +78,14 @@ namespace out { void setMode(adios2::Mode); - void addTracker(const std::string&, std::size_t, long double); - auto shouldWrite(const std::string&, std::size_t, long double) -> bool; + void addTracker(const std::string&, timestep_t, simtime_t); + auto shouldWrite(const std::string&, timestep_t, simtime_t) -> bool; void writeAttrs(const prm::Parameters&); - void defineMeshLayout(const std::vector&, - const std::vector&, - const std::vector&, + void defineMeshLayout(const std::vector&, + const std::vector&, + const std::vector&, const std::vector&, bool, Coord); @@ -102,13 +102,13 @@ namespace out { const std::vector&); void writeParticleQuantity(const array_t&, - std::size_t, - std::size_t, + npart_t, + npart_t, const std::string&); void writeSpectrum(const array_t&, const std::string&); void writeSpectrumBins(const array_t&, const std::string&); - void beginWriting(WriteModeTags, std::size_t, long double); + void beginWriting(WriteModeTags, timestep_t, simtime_t); void endWriting(WriteModeTags); /* getters -------------------------------------------------------------- */ From 85811c9bdd670dd44d8c50123240881dc2407293 Mon Sep 17 00:00:00 2001 From: jmahlmann Date: Thu, 13 Mar 2025 10:09:36 -0400 Subject: [PATCH 2/4] Minor fixes of npart_t --- src/checkpoint/writer.cpp | 4 ++-- src/framework/domain/metadomain.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/checkpoint/writer.cpp b/src/checkpoint/writer.cpp index c5f7e5181..a70d8de09 100644 --- a/src/checkpoint/writer.cpp +++ b/src/checkpoint/writer.cpp @@ -273,10 +273,10 @@ namespace checkpoint { std::size_t, std::size_t, double); - template void Writer::savePerDomainVariable(const std::string&, + template void Writer::savePerDomainVariable(const std::string&, std::size_t, std::size_t, - std::size_t); + npart_t); template void Writer::saveField(const std::string&, const ndfield_t&); diff --git a/src/framework/domain/metadomain.h b/src/framework/domain/metadomain.h index e7e1340e2..80f546664 100644 --- a/src/framework/domain/metadomain.h +++ b/src/framework/domain/metadomain.h @@ -177,8 +177,8 @@ namespace ntt { } [[nodiscard]] - auto l_npart_perspec() const -> std::vector { - std::vector npart(g_species_params.size(), 0); + auto l_npart_perspec() const -> std::vector { + std::vector npart(g_species_params.size(), 0); for (const auto& ldidx : l_subdomain_indices()) { for (std::size_t i = 0; i < g_species_params.size(); ++i) { npart[i] += g_subdomains[ldidx].species[i].npart(); @@ -188,8 +188,8 @@ namespace ntt { } [[nodiscard]] - auto l_maxnpart_perspec() const -> std::vector { - std::vector maxnpart(g_species_params.size(), 0); + auto l_maxnpart_perspec() const -> std::vector { + std::vector maxnpart(g_species_params.size(), 0); for (const auto& ldidx : l_subdomain_indices()) { for (std::size_t i = 0; i < g_species_params.size(); ++i) { maxnpart[i] += g_subdomains[ldidx].species[i].maxnpart(); From 66cb136a4f3fa46cca535befce004d1102b4a17d Mon Sep 17 00:00:00 2001 From: jmahlmann Date: Thu, 13 Mar 2025 15:35:15 -0400 Subject: [PATCH 3/4] Minor fixes of npart_t --- src/kernels/comm.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/kernels/comm.hpp b/src/kernels/comm.hpp index 7873870b1..6a47e56b4 100644 --- a/src/kernels/comm.hpp +++ b/src/kernels/comm.hpp @@ -113,14 +113,14 @@ namespace kernel::comm { array_t send_buff_pld; const unsigned short NINTS, NREALS, NPRTLDX, NPLDS; - const std::size_t idx_offset; + const npart_t idx_offset; const array_t i1, i1_prev, i2, i2_prev, i3, i3_prev; const array_t dx1, dx1_prev, dx2, dx2_prev, dx3, dx3_prev; const array_t ux1, ux2, ux3, weight, phi; const array_t pld; array_t tag; - const array_t outgoing_indices; + const array_t outgoing_indices; public: PopulatePrtlSendBuffer_kernel(array_t& send_buff_int, @@ -131,7 +131,7 @@ namespace kernel::comm { unsigned short NREALS, unsigned short NPRTLDX, unsigned short NPLDS, - std::size_t idx_offset, + npart_t idx_offset, const array_t& i1, const array_t& i1_prev, const array_t& dx1, @@ -151,7 +151,7 @@ namespace kernel::comm { const array_t& phi, const array_t& pld, array_t& tag, - const array_t& outgoing_indices) + const array_t& outgoing_indices) : send_buff_int { send_buff_int } , send_buff_real { send_buff_real } , send_buff_prtldx { send_buff_prtldx } From 76867488994438bf98d4b41a2b9209d4764d9de9 Mon Sep 17 00:00:00 2001 From: hayk Date: Tue, 1 Apr 2025 17:31:28 -0400 Subject: [PATCH 4/4] Lf -> f in fmt --- src/engines/engine_printer.cpp | 8 ++++---- src/global/utils/diag.cpp | 7 +++---- src/global/utils/timer.cpp | 34 ++++++++++++++++------------------ 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/engines/engine_printer.cpp b/src/engines/engine_printer.cpp index c1a36a323..f94715d09 100644 --- a/src/engines/engine_printer.cpp +++ b/src/engines/engine_printer.cpp @@ -105,8 +105,8 @@ namespace ntt { color::RESET); } - auto bytes_to_human_readable( - std::size_t bytes) -> std::pair { + auto bytes_to_human_readable(std::size_t bytes) + -> std::pair { const std::vector units { "B", "KB", "MB", "GB", "TB" }; idx_t unit_idx = 0; auto size = static_cast(bytes); @@ -391,7 +391,7 @@ namespace ntt { add_subcategory(report, 6, "Memory footprint"); auto flds_footprint = domain.fields.memory_footprint(); auto [flds_size, flds_unit] = bytes_to_human_readable(flds_footprint); - add_param(report, 8, "Fields", "%.2Lf %s", flds_size, flds_unit.c_str()); + add_param(report, 8, "Fields", "%.2f %s", flds_size, flds_unit.c_str()); if (domain.species.size() > 0) { add_subcategory(report, 8, "Particles"); } @@ -400,7 +400,7 @@ namespace ntt { species.index(), species.label().c_str()); auto [size, unit] = bytes_to_human_readable(species.memory_footprint()); - add_param(report, 10, str.c_str(), "%.2Lf %s", size, unit.c_str()); + add_param(report, 10, str.c_str(), "%.2f %s", size, unit.c_str()); } report.pop_back(); if (idx == m_metadomain.ndomains() - 1) { diff --git a/src/global/utils/diag.cpp b/src/global/utils/diag.cpp index fbd0c4215..9a35e30c9 100644 --- a/src/global/utils/diag.cpp +++ b/src/global/utils/diag.cpp @@ -21,9 +21,8 @@ #include namespace diag { - auto npart_stats( - npart_t npart, - npart_t maxnpart) -> std::vector> { + auto npart_stats(npart_t npart, npart_t maxnpart) + -> std::vector> { auto stats = std::vector>(); #if !defined(MPI_ENABLED) stats.push_back( @@ -127,7 +126,7 @@ namespace diag { c_reset); ss << fmt::alignedTable( - { "Time:", fmt::format("%.4Lf", time), fmt::format("[Δt = %.4Lf]", dt) }, + { "Time:", fmt::format("%.4f", time), fmt::format("[Δt = %.4f]", dt) }, { c_reset, c_bgreen, c_bblack }, { 0, -6, -15 }, { ' ', ' ', ' ' }, diff --git a/src/global/utils/timer.cpp b/src/global/utils/timer.cpp index d3c14d05e..bc133b4b7 100644 --- a/src/global/utils/timer.cpp +++ b/src/global/utils/timer.cpp @@ -130,9 +130,8 @@ namespace timer { return timer_stats; } - auto Timers::printAll(TimerFlags flags, - npart_t npart, - ncells_t ncells) const -> std::string { + auto Timers::printAll(TimerFlags flags, npart_t npart, ncells_t ncells) const + -> std::string { const std::vector extras { "PrtlClear", "Output", "Checkpoint" }; const auto stats = gather(extras, npart, ncells); if (stats.empty()) { @@ -192,11 +191,11 @@ namespace timer { if (multi_rank) { ss << fmt::alignedTable( { name, - fmt::format("%.2Lf", time) + " " + units, + fmt::format("%.2f", time) + " " + units, std::to_string(tot_pct) + "%", std::to_string(var_pct) + "%", - fmt::format("%.2Lf", per_npart) + " " + units_npart, - fmt::format("%.2Lf", per_ncells) + " " + units_ncells }, + fmt::format("%.2f", per_npart) + " " + units_npart, + fmt::format("%.2f", per_ncells) + " " + units_ncells }, { c_reset, c_yellow, ((tot_pct > 60) ? c_red : ((tot_pct > 40) ? c_yellow : c_green)), @@ -210,10 +209,10 @@ namespace timer { } else { ss << fmt::alignedTable( { name, - fmt::format("%.2Lf", time) + " " + units, + fmt::format("%.2f", time) + " " + units, std::to_string(tot_pct) + "%", - fmt::format("%.2Lf", per_npart) + " " + units_npart, - fmt::format("%.2Lf", per_ncells) + " " + units_ncells }, + fmt::format("%.2f", per_npart) + " " + units_npart, + fmt::format("%.2f", per_ncells) + " " + units_ncells }, { c_reset, c_yellow, ((tot_pct > 60) ? c_red : ((tot_pct > 40) ? c_yellow : c_green)), @@ -237,7 +236,7 @@ namespace timer { if (multi_rank) { ss << fmt::alignedTable( { "Total", - fmt::format("%.2Lf", time) + " " + units, + fmt::format("%.2f", time) + " " + units, std::to_string(var_pct) + "%" }, { c_reset, c_blue, @@ -247,13 +246,12 @@ namespace timer { c_bblack, c_reset); } else { - ss << fmt::alignedTable( - { "Total", fmt::format("%.2Lf", time) + " " + units }, - { c_reset, c_blue }, - { 0, 37 }, - { ' ', ' ' }, - c_bblack, - c_reset); + ss << fmt::alignedTable({ "Total", fmt::format("%.2f", time) + " " + units }, + { c_reset, c_blue }, + { 0, 37 }, + { ' ', ' ' }, + c_bblack, + c_reset); } } @@ -271,7 +269,7 @@ namespace timer { convertTime(time, units); } ss << fmt::alignedTable({ name, - fmt::format("%.2Lf", time) + " " + units, + fmt::format("%.2f", time) + " " + units, std::to_string(tot_pct) + "%" }, { (active ? c_reset : c_bblack), (active ? c_byellow : c_bblack),