Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
NodeInstance.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
23#include "shamcomm/mpiInfo.hpp"
25#include <sycl/sycl.hpp>
26#include <vector>
27
28namespace shamsys::instance {
29
33 class ShamsysInstanceException : public std::exception {
34 public:
35 explicit ShamsysInstanceException(const char *message) : msg_(message) {}
36
37 explicit ShamsysInstanceException(const std::string &message) : msg_(message) {}
38
39 ~ShamsysInstanceException() noexcept override = default;
40
41 [[nodiscard]] const char *what() const noexcept override { return msg_.c_str(); }
42
43 protected:
44 std::string msg_;
45 };
46
54 struct SyclInitInfo {
55 u32 alt_queue_id;
56 u32 compute_queue_id;
57 };
58
66 struct MPIInitInfo {
67 int argc;
68 char **argv;
69 std::optional<shamcomm::StateMPI_Aware> forced_state;
70 };
71
77 bool is_initialized();
78
89 void init(int argc, char *argv[]);
90
92 void start_mpi(MPIInitInfo mpi_info);
93
95 void init_sycl_mpi(std::string search_key, MPIInitInfo mpi_info);
96
101 void close();
102
104 void close_mpi();
105
106 [[deprecated("Please use shamrock smi instead")]]
107 void print_device_list();
108
110 void print_queue_map();
111
113 // sycl related routines
115
124 sycl::queue &get_compute_queue(u32 id = 0);
125 u32 get_compute_queue_eu_count(u32 id = 0);
126
127 inline sycl::device get_compute_device() { return get_compute_queue().get_device(); }
128
135 sycl::queue &get_alt_queue(u32 id = 0);
136
137 sham::DeviceScheduler &get_compute_scheduler();
138 sham::DeviceScheduler &get_alt_scheduler();
139
140 std::shared_ptr<sham::DeviceScheduler> get_compute_scheduler_ptr();
141 std::shared_ptr<sham::DeviceScheduler> get_alt_scheduler_ptr();
142
144 // MPI related routines
146
147 // idea to handle multiple GPU with MPI : i32 get_mpi_tag(u32 tag);
148
149 void print_mpi_capabilities();
150
151 void print_mpi_comm_info();
152
153 void check_dgpu_available();
154
155} // namespace shamsys::instance
void start_mpi(MPIInitInfo mpi_info)
Start MPI.
void print_queue_map()
Print SYCL queue map.
sycl::queue & get_compute_queue(u32 id=0)
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
void close_mpi()
Finalize MPI.
std::uint32_t u32
32 bit unsigned integer
Class to manage the scheduling of kernels on a device.
Exception type for the NodeInstance.
Provide information about MPI capabilities.
Struct containing MPI Init informations Usage.
Struct containing Sycl Init informations Usage.
Functions related to the MPI communicator.