DistDir
backend_mpi.h
Go to the documentation of this file.
1 /*
2  * @file backend_mpi.h
3  *
4  * @copyright Copyright (C) 2024 Enrico Degregori <enrico.degregori@gmail.com>
5  *
6  * @author Enrico Degregori <enrico.degregori@gmail.com>
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10 
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13 
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17 
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef BACKEND_MPI_H
35 #define BACKEND_MPI_H
36 
37 #include "mpi.h"
38 
39 typedef void (*kernel_backend_func_wait) (int, MPI_Request *, MPI_Status *);
40 
41 typedef void (*kernel_func_isendirecv) ( void *, int , MPI_Datatype, int, int,
42  MPI_Comm, MPI_Request *, int ) ;
43 
44 typedef void (*kernel_func_recv) ( void *, int, MPI_Datatype, int, int,
45  MPI_Comm, MPI_Status * , int) ;
46 
54  MPI_Datatype type;
56  MPI_Aint type_size;
58  MPI_Request *req;
60  MPI_Status *stat;
62  int nreq_send;
64  int nreq_recv;
73 };
74 typedef struct t_mpi_exchange t_mpi_exchange;
75 
86 t_mpi_exchange * new_mpi_exchanger(MPI_Datatype type, int size);
87 
96 
111 void mpi_wrapper_isend_int(int *buffer, int count, MPI_Datatype datatype, int dest, int tag,
112  MPI_Comm comm, MPI_Request *request, int offset);
113 
128 void mpi_wrapper_isend_float(float *buffer, int count, MPI_Datatype datatype, int dest, int tag,
129  MPI_Comm comm, MPI_Request *request, int offset);
130 
145 void mpi_wrapper_isend_double(double *buffer, int count, MPI_Datatype datatype, int dest, int tag,
146  MPI_Comm comm, MPI_Request *request, int offset);
147 
162 void mpi_wrapper_irecv_int(int *buffer, int count, MPI_Datatype datatype, int source, int tag,
163  MPI_Comm comm, MPI_Request *request, int offset);
164 
179 void mpi_wrapper_irecv_float(float *buffer, int count, MPI_Datatype datatype, int source, int tag,
180  MPI_Comm comm, MPI_Request *request, int offset);
181 
196 void mpi_wrapper_irecv_double(double *buffer, int count, MPI_Datatype datatype, int source, int tag,
197  MPI_Comm comm, MPI_Request *request, int offset);
198 
213 void mpi_wrapper_recv_int(int *buffer, int count, MPI_Datatype datatype, int source, int tag,
214  MPI_Comm comm, MPI_Status *status, int offset);
215 
230 void mpi_wrapper_recv_float(float *buffer, int count, MPI_Datatype datatype, int source, int tag,
231  MPI_Comm comm, MPI_Status *status, int offset);
232 
247 void mpi_wrapper_recv_double(double *buffer, int count, MPI_Datatype datatype, int source, int tag,
248  MPI_Comm comm, MPI_Status *status, int offset);
249 
259 void mpi_wrapper_waitall(int count, MPI_Request *requests, MPI_Status *statuses);
260 
261 #endif
void(* kernel_backend_func_wait)(int, MPI_Request *, MPI_Status *)
Definition: backend_mpi.h:39
void(* kernel_func_recv)(void *, int, MPI_Datatype, int, int, MPI_Comm, MPI_Status *, int)
Definition: backend_mpi.h:44
void(* kernel_func_isendirecv)(void *, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request *, int)
Definition: backend_mpi.h:41
void mpi_wrapper_irecv_int(int *buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request, int offset)
Lightweight wrapper around MPI_Irecv for integer buffers.
void mpi_wrapper_recv_double(double *buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status, int offset)
Lightweight wrapper around MPI_Recv for double buffers.
void mpi_wrapper_irecv_float(float *buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request, int offset)
Lightweight wrapper around MPI_Irecv for float buffers.
void delete_mpi_exchanger(t_mpi_exchange *mpi_exchange)
Free memory of t_mpi_exchange object.
void mpi_wrapper_irecv_double(double *buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request, int offset)
Lightweight wrapper around MPI_Irecv for double buffers.
void mpi_wrapper_isend_float(float *buffer, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request, int offset)
Lightweight wrapper around MPI_Isend for float buffers.
void mpi_wrapper_recv_float(float *buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status, int offset)
Lightweight wrapper around MPI_Recv for float buffers.
t_mpi_exchange * new_mpi_exchanger(MPI_Datatype type, int size)
Create t_mpi_exchange object.
void mpi_wrapper_waitall(int count, MPI_Request *requests, MPI_Status *statuses)
Lightweight wrapper around MPI_Waitall.
void mpi_wrapper_recv_int(int *buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status, int offset)
Lightweight wrapper around MPI_Recv for integer buffers.
void mpi_wrapper_isend_int(int *buffer, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request, int offset)
Lightweight wrapper around MPI_Isend for integer buffers.
void mpi_wrapper_isend_double(double *buffer, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request, int offset)
Lightweight wrapper around MPI_Isend for double buffers.
The structure contains information about MPI backend.
Definition: backend_mpi.h:52
int nreq_recv
number of recv message requests
Definition: backend_mpi.h:64
kernel_func_recv recv
communication library recv function
Definition: backend_mpi.h:72
MPI_Aint type_size
Size of the MPI datatype used for the exchange.
Definition: backend_mpi.h:56
MPI_Status * stat
array of message status
Definition: backend_mpi.h:60
kernel_backend_func_wait wait
communication library wait function
Definition: backend_mpi.h:66
MPI_Request * req
array of message requests
Definition: backend_mpi.h:58
kernel_func_isendirecv irecv
communication library non blocking recv function
Definition: backend_mpi.h:70
int nreq_send
number of send message requests
Definition: backend_mpi.h:62
kernel_func_isendirecv isend
communication library non blocking send function
Definition: backend_mpi.h:68
MPI_Datatype type
MPI datatype used for the exchange.
Definition: backend_mpi.h:54