Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pyShamcomm.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
21#include "shamcomm/logs.hpp"
22#include "shamcomm/wrapper.hpp"
23#include <pybind11/pytypes.h>
24#include <unordered_map>
25#include <utility>
26#include <vector>
27
28Register_pymod(shamcommlibinit) {
29
30 py::module shamcomm_module = m.def_submodule("comm", "comm library");
31
32 shamcomm_module.def("get_timer", [](std::string name) {
33 return shamcomm::mpi::get_timer(std::move(name));
34 });
35
36 shamcomm_module.def("get_timers", []() {
38 });
39
40 shamcomm_module.def(
41 "mpi_timers_delta",
42 [](std::unordered_map<std::string, f64> start, std::unordered_map<std::string, f64> end) {
43 std::unordered_map<std::string, f64> deltas{};
44
45 for (auto &k : shamcomm::mpi::get_possible_keys()) {
46 deltas[k] = shamalgs::collective::allreduce_max(end[k] - start[k]);
47 }
48
49 return deltas;
50 });
51}
MPI string gather / allgather helpers (declarations; implementations in shamalgs/src/collective/gathe...
namespace for communication related stuff
Pybind11 include and definitions.
#define Register_pymod(placeholdername)
Register a python module init function using static initialisation.
const std::vector< std::string > & get_possible_keys()
return all possible keys for the internal timers
Definition wrapper.cpp:60
f64 get_timer(std::string timername)
get a timer value
Definition wrapper.cpp:44
const std::unordered_map< std::string, f64 > & get_timers()
return all internal timers
Definition wrapper.cpp:46