mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-24 20:00:33 +05:00
mpi-dummies
This commit is contained in:
parent
eead94dfc1
commit
75504c3a6d
@ -286,25 +286,25 @@ namespace ngcore
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** --- non-blocking P2P --- **/
|
/** --- non-blocking P2P --- **/
|
||||||
|
|
||||||
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
||||||
NG_MPI_Request ISend (T & val, int dest, int tag) const
|
[[nodiscard]] NG_MPI_Request ISend (T & val, int dest, int tag) const
|
||||||
{
|
{
|
||||||
NG_MPI_Request request;
|
NG_MPI_Request request;
|
||||||
NG_MPI_Isend (&val, 1, GetMPIType<T>(), dest, tag, comm, &request);
|
NG_MPI_Isend (&val, 1, GetMPIType<T>(), dest, tag, comm, &request);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
||||||
NG_MPI_Request ISend (FlatArray<T> s, int dest, int tag) const
|
[[nodiscard]] NG_MPI_Request ISend (FlatArray<T> s, int dest, int tag) const
|
||||||
{
|
{
|
||||||
NG_MPI_Request request;
|
NG_MPI_Request request;
|
||||||
NG_MPI_Isend (s.Data(), s.Size(), GetMPIType<T>(), dest, tag, comm, &request);
|
NG_MPI_Isend (s.Data(), s.Size(), GetMPIType<T>(), dest, tag, comm, &request);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
||||||
NG_MPI_Request IRecv (T & val, int dest, int tag) const
|
[[nodiscard]] NG_MPI_Request IRecv (T & val, int dest, int tag) const
|
||||||
{
|
{
|
||||||
NG_MPI_Request request;
|
NG_MPI_Request request;
|
||||||
NG_MPI_Irecv (&val, 1, GetMPIType<T>(), dest, tag, comm, &request);
|
NG_MPI_Irecv (&val, 1, GetMPIType<T>(), dest, tag, comm, &request);
|
||||||
@ -312,7 +312,7 @@ namespace ngcore
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
||||||
NG_MPI_Request IRecv (FlatArray<T> s, int src, int tag) const
|
[[nodiscard]] NG_MPI_Request IRecv (FlatArray<T> s, int src, int tag) const
|
||||||
{
|
{
|
||||||
NG_MPI_Request request;
|
NG_MPI_Request request;
|
||||||
NG_MPI_Irecv (s.Data(), s.Size(), GetMPIType<T>(), src, tag, comm, &request);
|
NG_MPI_Irecv (s.Data(), s.Size(), GetMPIType<T>(), src, tag, comm, &request);
|
||||||
@ -393,8 +393,9 @@ namespace ngcore
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class T, size_t S>
|
template <class T, size_t S>
|
||||||
NgMPI_Request IBcast (std::array<T,S> & d, int root = 0) const
|
[[nodiscard]] NgMPI_Request IBcast (std::array<T,S> & d, int root = 0) const
|
||||||
{
|
{
|
||||||
NG_MPI_Request request;
|
NG_MPI_Request request;
|
||||||
NG_MPI_Ibcast (&d[0], S, GetMPIType<T>(), root, comm, &request);
|
NG_MPI_Ibcast (&d[0], S, GetMPIType<T>(), root, comm, &request);
|
||||||
@ -535,7 +536,12 @@ namespace ngcore
|
|||||||
template <class T, class T2=void>
|
template <class T, class T2=void>
|
||||||
inline NG_MPI_Datatype GetMPIType () { return -1; }
|
inline NG_MPI_Datatype GetMPIType () { return -1; }
|
||||||
|
|
||||||
class NgMPI_Request { };
|
class NgMPI_Request {
|
||||||
|
public:
|
||||||
|
NgMPI_Request() = default;
|
||||||
|
NgMPI_Request(NgMPI_Request &&) { ; }
|
||||||
|
NgMPI_Request(NG_MPI_Request &&) { ; }
|
||||||
|
};
|
||||||
class NgMPI_Requests
|
class NgMPI_Requests
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1220,7 +1220,8 @@ namespace netgen
|
|||||||
recvrequests[0] = comm.IBcast (nnames);
|
recvrequests[0] = comm.IBcast (nnames);
|
||||||
MyMPI_WaitAll (recvrequests);
|
MyMPI_WaitAll (recvrequests);
|
||||||
*/
|
*/
|
||||||
comm.IBcast (nnames);
|
NgMPI_Requests requ;
|
||||||
|
requ += comm.IBcast (nnames);
|
||||||
|
|
||||||
// cout << "nnames = " << FlatArray(nnames) << endl;
|
// cout << "nnames = " << FlatArray(nnames) << endl;
|
||||||
materials.SetSize(nnames[0]);
|
materials.SetSize(nnames[0]);
|
||||||
@ -1235,7 +1236,7 @@ namespace netgen
|
|||||||
recvrequests[0] = comm.IBcast (name_sizes);
|
recvrequests[0] = comm.IBcast (name_sizes);
|
||||||
MyMPI_WaitAll (recvrequests);
|
MyMPI_WaitAll (recvrequests);
|
||||||
*/
|
*/
|
||||||
comm.IBcast (name_sizes);
|
requ += comm.IBcast (name_sizes);
|
||||||
|
|
||||||
int tot_size = 0;
|
int tot_size = 0;
|
||||||
for (int k = 0; k < tot_nn; k++) tot_size += name_sizes[k];
|
for (int k = 0; k < tot_nn; k++) tot_size += name_sizes[k];
|
||||||
@ -1245,7 +1246,8 @@ namespace netgen
|
|||||||
Array<char> compiled_names(tot_size);
|
Array<char> compiled_names(tot_size);
|
||||||
// recvrequests[0] = comm.IBcast (compiled_names);
|
// recvrequests[0] = comm.IBcast (compiled_names);
|
||||||
// MyMPI_WaitAll (recvrequests);
|
// MyMPI_WaitAll (recvrequests);
|
||||||
comm.IBcast (compiled_names);
|
requ += comm.IBcast (compiled_names);
|
||||||
|
requ.WaitAll();
|
||||||
|
|
||||||
tot_nn = tot_size = 0;
|
tot_nn = tot_size = 0;
|
||||||
auto write_names = [&] (auto & array) {
|
auto write_names = [&] (auto & array) {
|
||||||
|
Loading…
Reference in New Issue
Block a user