DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
MPI_bind.hpp
Go to the documentation of this file.
1#pragma once
2/// @file MPI_bind.hpp
3/// @brief pybind11 bindings for the DNDS MPI wrappers (@ref DNDS::MPIInfo "MPIInfo", @ref DNDS::CommStrategy "CommStrategy",
4/// buffer-protocol datatype helpers).
5
6#include "MPI.hpp"
7#include "Defines_bind.hpp"
8namespace py = pybind11;
9
10namespace DNDS
11{
12
13 inline MPI_Datatype py_get_buffer_basic_mpi_datatype(const py::buffer_info &info)
14 {
15 if (py_buffer_contains_T<real>(info))
16 return DNDS_MPI_REAL;
17 else if (py_buffer_contains_T<index>(info))
18 return DNDS_MPI_INDEX;
19 else if (py_buffer_contains_T<int8_t>(info))
20 return MPI_INT8_T;
21 else if (py_buffer_contains_T<uint8_t>(info))
22 return MPI_UINT8_T;
23 else if (py_buffer_contains_T<int32_t>(info))
24 return MPI_INT32_T;
25 else if (py_buffer_contains_T<uint32_t>(info))
26 return MPI_UINT32_T;
27 else if (py_buffer_contains_T<int64_t>(info))
28 return MPI_INT64_T;
29 else if (py_buffer_contains_T<uint64_t>(info))
30 return MPI_UINT64_T;
31 else if (py_buffer_contains_T<float>(info))
32 return MPI_FLOAT;
33 else if (py_buffer_contains_T<int16_t>(info))
34 return MPI_INT16_T;
35 else if (py_buffer_contains_T<uint16_t>(info))
36 return MPI_UINT16_T;
37 else
38 DNDS_assert_info(false, "MPI datatype not found for info.format == " + info.format);
39
40 return MPI_DATATYPE_NULL;
41 }
42
43 inline MPI_Op py_get_simple_mpi_op_by_name(const std::string &op)
44 {
45 MPI_Op mpi_op = MPI_OP_NULL;
46 if (op == "MPI_SUM")
47 mpi_op = MPI_SUM;
48 else if (op == "MPI_MAX")
49 mpi_op = MPI_MAX;
50 else if (op == "MPI_MIN")
51 mpi_op = MPI_MIN;
52 else if (op == "MPI_LXOR")
53 mpi_op = MPI_LXOR;
54 else if (op == "MPI_BXOR")
55 mpi_op = MPI_BXOR;
56 else
57 DNDS_assert_info(false, "MPI simple op not found: " + op);
58 return mpi_op;
59 }
60}
61
62namespace DNDS
63{
64 void pybind11_MPIInfo(py::module_ &m);
65}
66
67namespace DNDS::MPI
68{
69 void pybind11_Init_thread(py::module_ &m);
70
71 void pybind11_MPI_Operations(py::module_ &m);
72}
73
74namespace DNDS::Debug
75{
76 void pybind11_Debug(py::module_ &m);
77}
78
79namespace DNDS
80{
81 void pybind11_bind_MPI_All(py::module_ &m);
82}
Shared pybind11 plumbing used by every *_bind.hpp in DNDS (buffer-protocol type check,...
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
Definition Errors.hpp:113
MPI wrappers: MPIInfo, collective operations, type mapping, CommStrategy.
void pybind11_Debug(py::module_ &m)
Definition MPI_bind.cpp:125
void pybind11_Init_thread(py::module_ &m)
Definition MPI_bind.cpp:27
void pybind11_MPI_Operations(py::module_ &m)
Definition MPI_bind.cpp:91
the host side operators are provided as implemented
MPI_Op py_get_simple_mpi_op_by_name(const std::string &op)
Definition MPI_bind.hpp:43
const MPI_Datatype DNDS_MPI_INDEX
MPI datatype matching index (= MPI_INT64_T).
Definition MPI.hpp:90
void pybind11_MPIInfo(py::module_ &m)
Definition MPI_bind.cpp:10
MPI_Datatype py_get_buffer_basic_mpi_datatype(const py::buffer_info &info)
Definition MPI_bind.hpp:13
void pybind11_bind_MPI_All(py::module_ &m)
Definition MPI_bind.cpp:135
const MPI_Datatype DNDS_MPI_REAL
MPI datatype matching real (= MPI_REAL8).
Definition MPI.hpp:92