Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pyNodeInstance.hpp
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
10#pragma once
11
19#include "shamcmdopt/cmdopt.hpp"
20#include "shamcomm/mpiInfo.hpp"
21#include "shamcomm/wrapper.hpp"
24#include <pybind11/stl.h>
25
26namespace shamsys::instance {
27 void register_pymodules(py::module &m) {
28
29 using namespace shamsys::instance;
30
31 m.def(
32 "init",
33 [](std::string sycl_cfg) {
35 },
36 R"pbdoc(
37
38 The init function for shamrock node instance
39
40 )pbdoc");
41
42 m.def(
43 "close",
44 []() {
45 close();
46 },
47 R"pbdoc(
48
49 The close function for shamrock node instance
50
51 )pbdoc");
52
53 m.def("get_process_name", &shamcomm::get_process_name, R"pbdoc(
54
55 Get the name of the process
56
57 )pbdoc");
58
59 m.def(
60 "world_rank",
61 []() {
62 return shamcomm::world_rank();
63 },
64 R"pbdoc(
65 Get the world rank
66 )pbdoc");
67
68 m.def(
69 "world_size",
70 []() {
71 return shamcomm::world_size();
72 },
73 R"pbdoc(
74 Get the world size
75 )pbdoc");
76
77 m.def(
78 "is_initialized",
79 []() {
80 return is_initialized();
81 },
82 R"pbdoc(
83 Return true if the node instance is initialized
84 )pbdoc");
85
86 m.def(
87 "mpi_barrier",
88 []() {
89 shamcomm::mpi::Barrier(MPI_COMM_WORLD);
90 },
91 R"pbdoc(
92 Call the MPI barrier
93 )pbdoc");
94
95 m.def(
96 "get_compute_device_properties",
97 []() {
98 auto &sched = shamsys::instance::get_compute_scheduler();
99 auto &dev = shambase::get_check_ref(sched.ctx).device;
100 auto &prop = shambase::get_check_ref(dev).prop;
101
102 py::dict dict;
103 dict["vendor"] = sham::vendor_name(prop.vendor);
104 dict["backend"] = sham::backend_name(prop.backend);
105 dict["type"] = sham::device_type_name(prop.type);
106 dict["name"] = prop.name;
107 dict["platform"] = prop.platform;
108 dict["global_mem_size"] = prop.global_mem_size;
109 dict["global_mem_cache_line_size"] = prop.global_mem_cache_line_size;
110 dict["global_mem_cache_size"] = prop.global_mem_cache_size;
111 dict["local_mem_size"] = prop.local_mem_size;
112 dict["max_compute_units"] = prop.max_compute_units;
113 dict["max_mem_alloc_size_dev"] = prop.max_mem_alloc_size_dev;
114 dict["max_mem_alloc_size_host"] = prop.max_mem_alloc_size_host;
115 dict["mem_base_addr_align"] = prop.mem_base_addr_align;
116 // dict["sub_group_sizes"] = prop.sub_group_sizes;
117 // dict["default_work_group_size"] = prop.default_work_group_size;
118 // dict["pci_address"] = prop.pci_address;
119 // dict["warnings"] = prop.warnings;
120
121 return dict;
122 },
123 R"pbdoc(
124 Get the properties of the compute device
125 )pbdoc");
126
127 m.def(
128 "get_microbench_results",
129 []() {
131 },
132 R"pbdoc(
133 Get the microbench results
134 )pbdoc");
135 }
136} // namespace shamsys::instance
Header file describing a Node Instance.
void init_sycl_mpi(std::string search_key, MPIInitInfo mpi_info)
Start SYCL & MPI.
bool is_initialized()
to check whether the NodeInstance is initialized
void close()
close the NodeInstance Aka : Finalize both MPI & SYCL
Provide information about MPI capabilities.
std::string backend_name(Backend b)
Returns the name of the given backend.
Definition Device.hpp:54
std::string vendor_name(Vendor v)
Returns the name of the given vendor.
Definition Device.hpp:32
std::string device_type_name(DeviceType t)
Returns the name of the given device type.
Definition Device.hpp:70
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...
Definition memory.hpp:110
char ** get_argv()
Get the command line arguments.
Definition cmdopt.cpp:203
int get_argc()
Get the number of command line arguments.
Definition cmdopt.cpp:197
i32 world_rank()
Gives the rank of the current process in the MPI communicator.
Definition worldInfo.cpp:40
i32 world_size()
Gives the size of the MPI communicator.
Definition worldInfo.cpp:38
std::string get_process_name()
Get the process name.
Definition mpiInfo.cpp:147
const std::unordered_map< std::string, double > & get_microbench_results()
Get the microbench results.
Pybind11 include and definitions.
Struct containing MPI Init informations Usage.
void Barrier(MPI_Comm comm)
MPI wrapper for MPI_Barrier.
Definition wrapper.cpp:194