Skip to content

Commit 7e735f5

Browse files
committed
ajout de la fonction MPI_Ibcast pour l'interposition Fortran
1 parent 2698f56 commit 7e735f5

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/interpolf.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,4 +679,63 @@ _EXTERN_C_ void mpi_wait_(MPI_Fint *request, MPI_Fint *status, MPI_Fint *ierr) {
679679

680680
_EXTERN_C_ void mpi_wait__(MPI_Fint *request, MPI_Fint *status, MPI_Fint *ierr) {
681681
MPI_Wait_fortran_wrapper(request, status, ierr);
682+
}
683+
684+
685+
static void MPI_Ibcast_fortran_wrapper(MPI_Fint *buffer, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
686+
int _wrap_py_return_val = 0;
687+
688+
Tsc const tsc = rdtsc();
689+
690+
#if (!defined(MPICH_HAS_C2F) && defined(MPICH_NAME) && (MPICH_NAME == 1)) /* MPICH test */
691+
_wrap_py_return_val = PMPI_Ibcast((void*)buffer, *count, (MPI_Datatype)(*datatype), *root, (MPI_Comm)(*comm), (MPI_Request*)request);
692+
#else /* MPI-2 safe call */
693+
MPI_Request temp_request;
694+
temp_request = MPI_Request_f2c(*request);
695+
_wrap_py_return_val = PMPI_Ibcast((void*)buffer, *count, MPI_Type_f2c(*datatype), *root, MPI_Comm_f2c(*comm), &temp_request);
696+
*request = MPI_Request_c2f(temp_request);
697+
#endif /* MPICH test */
698+
699+
Tsc const duration = rdtsc() - tsc;
700+
701+
int nb_bytes;
702+
PMPI_Type_size(MPI_Type_f2c(*datatype), &nb_bytes);
703+
704+
MpiCall const ibcast = {
705+
.kind = Ibcast,
706+
.time = -1.0,
707+
.tsc = tsc,
708+
.duration = duration,
709+
.current_rank = current_rank,
710+
.partner_rank = *root,
711+
.nb_bytes_s = nb_bytes * (*count),
712+
.nb_bytes_r = 0,
713+
.comm = PMPI_Comm_c2f((MPI_Comm)comm),
714+
.req = *request,
715+
.tag = -1,
716+
.required_thread_lvl = -1,
717+
.provided_thread_lvl = -1,
718+
.op_type = -1,
719+
.finished = false,
720+
};
721+
722+
register_mpi_call(ibcast);
723+
724+
*ierr = _wrap_py_return_val;
725+
}
726+
727+
_EXTERN_C_ void MPI_IBCAST(MPI_Fint *buffer, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
728+
MPI_Ibcast_fortran_wrapper(buffer, count, datatype, root, comm, request, ierr);
729+
}
730+
731+
_EXTERN_C_ void mpi_ibcast(MPI_Fint *buffer, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
732+
MPI_Ibcast_fortran_wrapper(buffer, count, datatype, root, comm, request, ierr);
733+
}
734+
735+
_EXTERN_C_ void mpi_ibcast_(MPI_Fint *buffer, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
736+
MPI_Ibcast_fortran_wrapper(buffer, count, datatype, root, comm, request, ierr);
737+
}
738+
739+
_EXTERN_C_ void mpi_ibcast__(MPI_Fint *buffer, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
740+
MPI_Ibcast_fortran_wrapper(buffer, count, datatype, root, comm, request, ierr);
682741
}

0 commit comments

Comments
 (0)