OpenLB 1.7
Loading...
Searching...
No Matches
mpiRequest.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Adrian Kummerlaender
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the Free
17 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef MPI_REQUEST_H
22#define MPI_REQUEST_H
23#ifdef PARALLEL_MODE_MPI
24
25#include "mpi.h"
26#include "mpiManager.h"
27
28namespace olb {
29
32protected:
33 MPI_Request _request;
34 MPI_Status _status;
35
36public:
38 _request{},
39 _status{} { };
40
41 inline void start() {
42 MPI_Start(&_request);
43 }
44
45 inline void wait() {
46 MPI_Wait(&_request, &_status);
47 }
48
49 bool isDone() {
50 int done;
51 MPI_Test(&_request, &done, MPI_STATUS_IGNORE);
52 return done;
53 }
54};
55
57class MpiSendRequest final : public MpiRequest {
58public:
59 template <typename T>
60 MpiSendRequest(T* buffer, std::size_t size,
61 int rank, int tag, MPI_Comm communicator)
62 {
64 buffer, size,
65 rank,
66 &this->_request,
67 tag,
68 communicator);
69 }
70
72 //MPI_Request_free(&this->_request);
73 }
74};
75
77class MpiRecvRequest final : public MpiRequest {
78public:
79 template <typename T>
80 MpiRecvRequest(T* buffer, std::size_t size,
81 int rank, int tag, MPI_Comm communicator)
82 {
84 buffer, size,
85 rank,
86 &this->_request,
87 tag,
88 communicator);
89 }
90
92 //MPI_Request_free(&this->_request);
93 }
94};
95
96}
97
98#endif
99#endif
Non-blocking MPI receive request.
Definition mpiRequest.h:77
MpiRecvRequest(T *buffer, std::size_t size, int rank, int tag, MPI_Comm communicator)
Definition mpiRequest.h:80
Basic wrapper around a single MPI_Request.
Definition mpiRequest.h:31
MPI_Request _request
Definition mpiRequest.h:33
MPI_Status _status
Definition mpiRequest.h:34
Non-blocking MPI send request.
Definition mpiRequest.h:57
MpiSendRequest(T *buffer, std::size_t size, int rank, int tag, MPI_Comm communicator)
Definition mpiRequest.h:60
void recvInit(T *buf, int count, int dest, MPI_Request *request, int tag=0, MPI_Comm comm=MPI_COMM_WORLD)
Initialize persistent non-blocking receive.
void sendInit(T *buf, int count, int dest, MPI_Request *request, int tag=0, MPI_Comm comm=MPI_COMM_WORLD)
Initialize persistent non-blocking send.
Wrapper functions that simplify the use of MPI.
MpiManager & mpi()
Top level namespace for all of OpenLB.