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
22#include "shamrock/version.hpp"
25
26Register_pymod(pysyslibinit) {
27
28 m.def(
29 "change_loglevel",
30 [](u32 loglevel) {
31 if (loglevel > i8_max) {
33 "loglevel must be below 128");
34 }
35
36 if (loglevel == i8_max) {
37 logger::raw_ln(
38 "If you've seen spam in your life i can garantee you, this is worst");
39 }
40
41 logger::raw_ln(
42 "-> modified loglevel to", logger::get_loglevel(), "enabled log types : ");
43
44 logger::set_loglevel(loglevel);
45 logger::print_active_level();
46 },
47 R"pbdoc(
48
49 Change the loglevel
50
51 )pbdoc");
52
53 m.def(
54 "get_git_info",
55 []() {
56 return git_info_str;
57 },
58 R"pbdoc(
59 Return git_info_str
60 )pbdoc");
61
62 m.def(
63 "print_git_info",
64 []() {
65 logger::raw_ln(git_info_str);
66 },
67 R"pbdoc(
68 print git_info_str
69 )pbdoc");
70
71 m.def(
72 "get_compile_arg",
73 []() {
74 return compile_arg;
75 },
76 R"pbdoc(
77 Return compile_arg
78 )pbdoc");
79
80 m.def(
81 "get_compiler_id_string",
82 []() {
83 return shamrock_compiler_id_string;
84 },
85 R"pbdoc(
86 Return compiler_id_string
87 )pbdoc");
88
89 m.def(
90 "print_compile_arg",
91 []() {
92 logger::raw_ln(compile_arg);
93 },
94 R"pbdoc(
95 print compile_arg
96 )pbdoc");
97
98 m.def(
99 "version_string",
100 []() {
101 return version_string;
102 },
103 R"pbdoc(
104 Return version_string
105 )pbdoc");
106
107 m.def(
108 "is_git",
109 []() {
110 return is_git;
111 },
112 R"pbdoc(
113 Return is_git
114 )pbdoc");
115
116 m.def(
117 "enable_experimental_features",
118 []() {
120 },
121 R"pbdoc(
122 Enable experimental features
123 )pbdoc");
124
125 m.def(
126 "dump_profiling",
127 [](std::string prefix) {
128#ifdef SHAMROCK_USE_PROFILING
130#endif
131 },
132 R"pbdoc(
133 dump profiling data
134 )pbdoc");
135
136 m.def(
137 "dump_profiling_chrome",
138 [](std::string prefix) {
139#ifdef SHAMROCK_USE_PROFILING
141#endif
142 },
143 R"pbdoc(
144 dump profiling data
145 )pbdoc");
146
147 m.def(
148 "clear_profiling_data",
149 []() {
150#ifdef SHAMROCK_USE_PROFILING
152#endif
153 },
154 R"pbdoc(
155 dump profiling data
156 )pbdoc");
157
158 py::module sys_module = m.def_submodule("sys", "system handling part of shamrock");
159 sys_module.def("signal_handler", &shamsys::details::signal_callback_handler);
160
161 shamsys::instance::register_pymodules(sys_module);
162}
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
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
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 Register_pymod(placeholdername)
Register a python module init function using static initialisation.
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.
void clear_profiling_data()
Clear the profiling data. (should be done in large run to avoid out-of-memory)
typedefs and macros