23#include <pybind11/complex.h>
26inline void register_DeviceBuffer(py::module &m,
const char *class_name) {
29 py::class_<sham::DeviceBuffer<T>>(m, class_name)
31 return std::make_unique<sham::DeviceBuffer<T>>(
52 self.set_val_at_idx(idx, val);
71 py::module shambackends_module = m.def_submodule(
"backends",
"backend library");
73 register_DeviceBuffer<u8>(shambackends_module,
"DeviceBuffer_u8");
74 register_DeviceBuffer<u32>(shambackends_module,
"DeviceBuffer_u32");
75 register_DeviceBuffer<f32>(shambackends_module,
"DeviceBuffer_f32");
76 register_DeviceBuffer<f64>(shambackends_module,
"DeviceBuffer_f64");
77 register_DeviceBuffer<f64_2>(shambackends_module,
"DeviceBuffer_f64_2");
78 register_DeviceBuffer<f64_3>(shambackends_module,
"DeviceBuffer_f64_3");
80 shambackends_module.def(
"reset_mem_info_max", []() {
84 py::class_<sham::MemPerfInfos>(shambackends_module,
"MemPerfInfos")
91 py::return_value_policy::reference_internal)
95 py::return_value_policy::reference_internal)
99 py::return_value_policy::reference_internal)
103 py::return_value_policy::reference_internal)
107 py::return_value_policy::reference_internal)
111 py::return_value_policy::reference_internal)
113 "allocated_byte_host",
115 py::return_value_policy::reference_internal)
117 "allocated_byte_device",
119 py::return_value_policy::reference_internal)
121 "allocated_byte_shared",
123 py::return_value_policy::reference_internal)
125 "max_allocated_byte_host",
127 py::return_value_policy::reference_internal)
129 "max_allocated_byte_device",
131 py::return_value_policy::reference_internal)
133 "max_allocated_byte_shared",
135 py::return_value_policy::reference_internal)
139 return shambase::format(
141 " time_alloc_host=\"{0:}\",\n"
142 " time_alloc_device=\"{1:}\",\n"
143 " time_alloc_shared=\"{2:}\",\n"
144 " time_free_host=\"{3:}\",\n"
145 " time_free_device=\"{4:}\",\n"
146 " time_free_shared=\"{5:}\",\n"
147 " allocated_byte_host=\"{6:}\",\n"
148 " allocated_byte_device=\"{7:}\",\n"
149 " allocated_byte_shared=\"{8:}\",\n"
150 " max_allocated_byte_host=\"{9:}\",\n"
151 " max_allocated_byte_device=\"{10:}\",\n"
152 " max_allocated_byte_shared=\"{11:}\")",
167 return shambase::format(
169 " time_alloc_host=\"{0:}\",\n"
170 " time_alloc_device=\"{1:}\",\n"
171 " time_alloc_shared=\"{2:}\",\n"
172 " time_free_host=\"{3:}\",\n"
173 " time_free_device=\"{4:}\",\n"
174 " time_free_shared=\"{5:}\",\n"
175 " allocated_byte_host=\"{6:}\",\n"
176 " allocated_byte_device=\"{7:}\",\n"
177 " allocated_byte_shared=\"{8:}\",\n"
178 " max_allocated_byte_host=\"{9:}\",\n"
179 " max_allocated_byte_device=\"{10:}\",\n"
180 " max_allocated_byte_shared=\"{11:}\")",
195 shambackends_module.def(
"get_mem_perf_info", []() {
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
void copy_from_stdvec(const std::vector< T > &vec)
Copy the content of a std::vector into the buffer.
void resize(size_t new_size, bool keep_data=true)
Resizes the buffer to a given size.
void fill(T value, std::array< size_t, 2 > idx_range)
Fill a subpart of the buffer with a given value.
std::vector< T > copy_to_stdvec() const
Copy the content of the buffer to a std::vector.
T get_val_at_idx(size_t idx) const
Get the value at a given index in the buffer.
size_t get_size() const
Gets the number of elements in the buffer.
MemPerfInfos get_mem_perf_info()
Retrieve the memory performance information.
void reset_mem_info_max()
Reset the memory information for the maximum allocated bytes.
Pybind11 include and definitions.
#define Register_pymod(placeholdername)
Register a python module init function using static initialisation.
void debug_ln(std::string module_name, Types... var2)
Prints a log message with multiple arguments followed by a newline.
Structure to store the performance informations about memory allocation and deallocation.
f64 time_alloc_host
Time spent allocating memory on the host.
size_t max_allocated_byte_host
max bytes allocated on the host
size_t allocated_byte_shared
Bytes allocated in shared memory.
f64 time_free_device
Time spent deallocating memory on the device.
f64 time_free_shared
Time spent deallocating memory in shared memory.
size_t max_allocated_byte_device
max bytes allocated on the device
f64 time_alloc_device
Time spent allocating memory on the device.
size_t allocated_byte_device
Bytes allocated on the device.
size_t allocated_byte_host
Bytes allocated on the host.
f64 time_free_host
Time spent deallocating memory on the host.
f64 time_alloc_shared
Time spent allocating memory in shared memory.
size_t max_allocated_byte_shared
max bytes allocated in shared memory