Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pyShamsys.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
15
23#include "shamrock/version.hpp"
26
28 auto &m = root_module;
29
30 m.def(
31 "change_loglevel",
32 [](u32 loglevel) {
33 if (loglevel > i8_max) {
35 "loglevel must be below 128");
36 }
37
38 if (loglevel == i8_max) {
40 "If you've seen spam in your life i can garantee you, this is worst");
41 }
42
44 "-> modified loglevel to", logger::get_loglevel(), "enabled log types : ");
45
46 logger::set_loglevel(loglevel);
48 },
49 R"pbdoc(
50
51 Change the loglevel
52
53 )pbdoc");
54
55 m.def(
56 "get_git_info",
57 []() {
58 return git_info_str;
59 },
60 R"pbdoc(
61 Return git_info_str
62 )pbdoc");
63
64 m.def(
65 "print_git_info",
66 []() {
67 logger::raw_ln(git_info_str);
68 },
69 R"pbdoc(
70 print git_info_str
71 )pbdoc");
72
73 m.def(
74 "get_compile_arg",
75 []() {
76 return compile_arg;
77 },
78 R"pbdoc(
79 Return compile_arg
80 )pbdoc");
81
82 m.def(
83 "get_compiler_id_string",
84 []() {
85 return shamrock_compiler_id_string;
86 },
87 R"pbdoc(
88 Return compiler_id_string
89 )pbdoc");
90
91 m.def(
92 "print_compile_arg",
93 []() {
94 logger::raw_ln(compile_arg);
95 },
96 R"pbdoc(
97 print compile_arg
98 )pbdoc");
99
100 m.def(
101 "version_string",
102 []() {
103 return version_string;
104 },
105 R"pbdoc(
106 Return version_string
107 )pbdoc");
108
109 m.def(
110 "is_git",
111 []() {
112 return is_git;
113 },
114 R"pbdoc(
115 Return is_git
116 )pbdoc");
117
118 m.def(
119 "enable_experimental_features",
120 []() {
122 },
123 R"pbdoc(
124 Enable experimental features
125 )pbdoc");
126
127 m.def(
128 "dump_profiling",
129 [](std::string prefix) {
130#ifdef SHAMROCK_USE_PROFILING
132#endif
133 },
134 R"pbdoc(
135 dump profiling data
136 )pbdoc");
137
138 m.def(
139 "dump_profiling_chrome",
140 [](std::string prefix) {
141#ifdef SHAMROCK_USE_PROFILING
143#endif
144 },
145 R"pbdoc(
146 dump profiling data
147 )pbdoc");
148
149 m.def(
150 "clear_profiling_data",
151 []() {
152#ifdef SHAMROCK_USE_PROFILING
154#endif
155 },
156 R"pbdoc(
157 dump profiling data
158 )pbdoc");
159
160 m.def(
161 "get_wtime",
162 []() {
164 },
165 R"pbdoc(
166 Get the wall time.
167 )pbdoc");
168
169 m.def(
170 "get_wtime_sync",
171 []() {
172 return shamalgs::collective::allreduce_max(shambase::details::get_wtime());
173 },
174 R"pbdoc(
175 Get the synchronized wall time across all MPI ranks.
176
177 .. warning::
178 This is an MPI collective operation and MUST be called by all ranks
179 simultaneously to avoid deadlocks.
180 )pbdoc");
181
182 py::module sys_module = m.def_submodule("sys", "system handling part of shamrock");
183 sys_module.def("signal_handler", &shamsys::details::signal_callback_handler);
184
185 shamsys::instance::register_pymodules(sys_module);
186}
void signal_callback_handler(int signum)
The handler that will be called when a signal is catched.
std::uint32_t u32
32 bit unsigned integer
This header file contains utility functions related to exception handling in the code.
void set_loglevel(i8 val)
Set the global log level.
Definition loglevel.hpp:45
i8 get_loglevel()
Get the current global log level.
Definition loglevel.hpp:52
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
i32 world_rank()
Gives the rank of the current process in the MPI communicator.
Definition worldInfo.cpp:40
void enable_experimental_features()
Allow the use of experimental features.
constexpr i8 i8_max
i8 max value
Pybind11 include and definitions.
#define ON_PYTHON_INIT
Register a Python module init function using static initialization.
void print_active_level()
Prints the active log levels.
Definition logs.cpp:33
void raw_ln(Types... var2)
Prints a log message with multiple arguments followed by a newline.
Definition logs.hpp:90
This file contains the definition for the stacktrace related functionality.
void dump_profilings(const std::string &process_prefix, u32 world_rank)
Dump the profiling data in a JSON format to a file.
void dump_profilings_chrome(const std::string &process_prefix, u32 world_rank)
Dump the profiling data in a Chrome Tracing format.
f64 get_wtime()
Returns the current wall clock time in seconds.
void clear_profiling_data()
Clear the profiling data. (should be done in large run to avoid out-of-memory).
typedefs and macros