Skip to content

Commit 21772ed

Browse files
committed
ajout de la fonction MPI_Iscatter pour l'interposition Fortran et légère modification pour éviter une erreur
1 parent aaebdcf commit 21772ed

File tree

1 file changed

+67
-6
lines changed

1 file changed

+67
-6
lines changed

src/interpolf.c

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,10 @@ static void MPI_Recv_fortran_wrapper(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *d
286286
#if (!defined(MPICH_HAS_C2F) && defined(MPICH_NAME) && (MPICH_NAME == 1)) /* MPICH test */
287287
_wrap_py_return_val = PMPI_Recv((void*)buf, *count, (MPI_Datatype)(*datatype), *source, *tag, (MPI_Comm)(*comm), (MPI_Status*)status);
288288
#else /* MPI-2 safe call */
289-
//MPI_Status temp_status;
289+
MPI_Status temp_status;
290290
//MPI_Status_f2c(status, &temp_status);
291291
_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);
292+
MPI_Status_c2f(&temp_status, status);
293293
#endif /* MPICH test */
294294

295295
Tsc const duration = rdtsc() - tsc;
@@ -575,8 +575,8 @@ static void MPI_Test_fortran_wrapper(MPI_Fint *request, MPI_Fint *flag, MPI_Fint
575575
MPI_Request temp_request;
576576
MPI_Status temp_status;
577577
temp_request = MPI_Request_f2c(*request);
578-
MPI_Status_f2c(status, &temp_status);
579-
_wrap_py_return_val = PMPI_Test(&temp_request, (int*)flag, &temp_status);
578+
//MPI_Status_f2c(status, &temp_status);
579+
_wrap_py_return_val = PMPI_Test(&temp_request, (int*)flag, (MPI_Status*)status);
580580
*request = MPI_Request_c2f(temp_request);
581581
MPI_Status_c2f(&temp_status, status);
582582
#endif /* MPICH test */
@@ -626,6 +626,7 @@ _EXTERN_C_ void mpi_test__(MPI_Fint *request, MPI_Fint *flag, MPI_Fint *status,
626626
static void MPI_Wait_fortran_wrapper(MPI_Fint *request, MPI_Fint *status, MPI_Fint *ierr) {
627627
int _wrap_py_return_val = 0;
628628

629+
MpiReq const req = *request;
629630
Tsc const tsc = rdtsc();
630631

631632
#if (!defined(MPICH_HAS_C2F) && defined(MPICH_NAME) && (MPICH_NAME == 1)) /* MPICH test */
@@ -634,7 +635,7 @@ static void MPI_Wait_fortran_wrapper(MPI_Fint *request, MPI_Fint *status, MPI_Fi
634635
MPI_Request temp_request;
635636
MPI_Status temp_status;
636637
temp_request = MPI_Request_f2c(*request);
637-
MPI_Status_f2c(status, &temp_status);
638+
//MPI_Status_f2c(status, &temp_status);
638639
_wrap_py_return_val = PMPI_Wait(&temp_request, &temp_status);
639640
*request = MPI_Request_c2f(temp_request);
640641
MPI_Status_c2f(&temp_status, status);
@@ -652,7 +653,7 @@ static void MPI_Wait_fortran_wrapper(MPI_Fint *request, MPI_Fint *status, MPI_Fi
652653
.nb_bytes_s = 0,
653654
.nb_bytes_r = 0,
654655
.comm = -1,
655-
.req = *request,
656+
.req = req,
656657
.tag = -1,
657658
.required_thread_lvl = -1,
658659
.provided_thread_lvl = -1,
@@ -798,4 +799,64 @@ _EXTERN_C_ void mpi_igather_(MPI_Fint *sendbuf, MPI_Fint *sendcount, MPI_Fint *s
798799

799800
_EXTERN_C_ void mpi_igather__(MPI_Fint *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
800801
MPI_Igather_fortran_wrapper(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, request, ierr);
802+
}
803+
804+
805+
static void MPI_Iscatter_fortran_wrapper(MPI_Fint *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
806+
int _wrap_py_return_val = 0;
807+
808+
Tsc const tsc = rdtsc();
809+
810+
#if (!defined(MPICH_HAS_C2F) && defined(MPICH_NAME) && (MPICH_NAME == 1)) /* MPICH test */
811+
_wrap_py_return_val = MPI_Iscatter((const void*)sendbuf, *sendcount, (MPI_Datatype)(*sendtype), (void*)recvbuf, *recvcount, (MPI_Datatype)(*recvtype), *root, (MPI_Comm)(*comm), (MPI_Request*)request);
812+
#else /* MPI-2 safe call */
813+
MPI_Request temp_request;
814+
temp_request = MPI_Request_f2c(*request);
815+
_wrap_py_return_val = PMPI_Iscatter((const void*)sendbuf, *sendcount, MPI_Type_f2c(*sendtype), (void*)recvbuf, *recvcount, MPI_Type_f2c(*recvtype), *root, MPI_Comm_f2c(*comm), &temp_request);
816+
*request = MPI_Request_c2f(temp_request);
817+
#endif /* MPICH test */
818+
819+
Tsc const duration = rdtsc() - tsc;
820+
821+
int nb_bytes_send, nb_bytes_recv;
822+
PMPI_Type_size(MPI_Type_f2c(*sendtype), &nb_bytes_send);
823+
PMPI_Type_size(MPI_Type_f2c(*recvtype), &nb_bytes_recv);
824+
825+
MpiCall const iscatter = {
826+
.kind = Iscatter,
827+
.time = -1.0,
828+
.tsc = tsc,
829+
.duration = duration,
830+
.current_rank = current_rank,
831+
.partner_rank = *root,
832+
.nb_bytes_s = nb_bytes_send * (*sendcount),
833+
.nb_bytes_r = nb_bytes_recv * (*recvcount),
834+
.comm = PMPI_Comm_c2f((MPI_Comm)comm),
835+
.req = *request,
836+
.tag = -1,
837+
.required_thread_lvl = -1,
838+
.provided_thread_lvl = -1,
839+
.op_type = -1,
840+
.finished = false,
841+
};
842+
843+
register_mpi_call(iscatter);
844+
845+
*ierr = _wrap_py_return_val;
846+
}
847+
848+
_EXTERN_C_ void MPI_ISCATTER(MPI_Fint *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
849+
MPI_Iscatter_fortran_wrapper(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, request, ierr);
850+
}
851+
852+
_EXTERN_C_ void mpi_iscatter(MPI_Fint *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
853+
MPI_Iscatter_fortran_wrapper(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, request, ierr);
854+
}
855+
856+
_EXTERN_C_ void mpi_iscatter_(MPI_Fint *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
857+
MPI_Iscatter_fortran_wrapper(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, request, ierr);
858+
}
859+
860+
_EXTERN_C_ void mpi_iscatter__(MPI_Fint *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
861+
MPI_Iscatter_fortran_wrapper(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, request, ierr);
801862
}

0 commit comments

Comments
 (0)