Skip to content

Commit 9ac4524

Browse files
committed
ajout de la fonction MPI_Recv pour l'interposition Fortran
1 parent a78d973 commit 9ac4524

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

src/interpolf.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ _EXTERN_C_ void mpi_init_thread__(MPI_Fint *argc, MPI_Fint ***argv, MPI_Fint *re
165165
MPI_Init_thread_fortran_wrapper(argc, argv, required, provided, ierr);
166166
}
167167

168+
168169
static void MPI_Finalize_fortran_wrapper(MPI_Fint *ierr) {
169170
int _wrap_py_return_val = 0;
170171

@@ -220,6 +221,7 @@ _EXTERN_C_ void mpi_finalize__(MPI_Fint *ierr) {
220221
MPI_Finalize_fortran_wrapper(ierr);
221222
}
222223

224+
223225
static void MPI_Send_fortran_wrapper(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *ierr) {
224226
int _wrap_py_return_val = 0;
225227

@@ -273,4 +275,63 @@ _EXTERN_C_ void mpi_send_(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MP
273275

274276
_EXTERN_C_ void mpi_send__(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *ierr) {
275277
MPI_Send_fortran_wrapper(buf, count, datatype, dest, tag, comm, ierr);
278+
}
279+
280+
281+
static void MPI_Recv_fortran_wrapper(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *status, MPI_Fint *ierr) {
282+
int _wrap_py_return_val = 0;
283+
284+
Tsc const tsc = rdtsc();
285+
286+
#if (!defined(MPICH_HAS_C2F) && defined(MPICH_NAME) && (MPICH_NAME == 1)) /* MPICH test */
287+
_wrap_py_return_val = PMPI_Recv((void*)buf, *count, (MPI_Datatype)(*datatype), *source, *tag, (MPI_Comm)(*comm), (MPI_Status*)status);
288+
#else /* MPI-2 safe call */
289+
//MPI_Status temp_status;
290+
//MPI_Status_f2c(status, &temp_status);
291+
_wrap_py_return_val = PMPI_Recv((void*)buf, *count, MPI_Type_f2c(*datatype), *source, *tag, MPI_Comm_f2c(*comm), (MPI_Status*)status);
292+
//MPI_Status_c2f(&temp_status, status);
293+
#endif /* MPICH test */
294+
295+
Tsc const duration = rdtsc() - tsc;
296+
297+
int nb_bytes;
298+
PMPI_Type_size(MPI_Type_f2c(*datatype), &nb_bytes);
299+
300+
MpiCall const recv = {
301+
.kind = Recv,
302+
.time = -1.0,
303+
.tsc = tsc,
304+
.duration = duration,
305+
.current_rank = current_rank,
306+
.partner_rank = *source,
307+
.nb_bytes_s = 0,
308+
.nb_bytes_r = nb_bytes * (*count),
309+
.comm = PMPI_Comm_c2f((MPI_Comm)comm),
310+
.req = -1,
311+
.tag = *tag,
312+
.required_thread_lvl = -1,
313+
.provided_thread_lvl = -1,
314+
.op_type = -1,
315+
.finished = false,
316+
};
317+
318+
register_mpi_call(recv);
319+
320+
*ierr = _wrap_py_return_val;
321+
}
322+
323+
_EXTERN_C_ void MPI_RECV(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *status, MPI_Fint *ierr) {
324+
MPI_Recv_fortran_wrapper(buf, count, datatype, source, tag, comm, status, ierr);
325+
}
326+
327+
_EXTERN_C_ void mpi_recv(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *status, MPI_Fint *ierr) {
328+
MPI_Recv_fortran_wrapper(buf, count, datatype, source, tag, comm, status, ierr);
329+
}
330+
331+
_EXTERN_C_ void mpi_recv_(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *status, MPI_Fint *ierr) {
332+
MPI_Recv_fortran_wrapper(buf, count, datatype, source, tag, comm, status, ierr);
333+
}
334+
335+
_EXTERN_C_ void mpi_recv__(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *status, MPI_Fint *ierr) {
336+
MPI_Recv_fortran_wrapper(buf, count, datatype, source, tag, comm, status, ierr);
276337
}

0 commit comments

Comments
 (0)