Skip to content

Commit fe8d356

Browse files
authored
Mpi info added to few more MPI APIs (#175)
* Added uniDiff.py * Fixed a minor bug * Added buffer info to few more APIs * Addresed review comment
1 parent 32d6931 commit fe8d356

File tree

1 file changed

+69
-6
lines changed
  • tools/unitrace/src/mpi

1 file changed

+69
-6
lines changed

tools/unitrace/src/mpi/mpi.c

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,19 @@ int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void
445445
ITT_BEGIN(MPI_TASK_GATHERV);
446446
result = PMPI_Gatherv(sendbuf, sendcount, sendtype, recvbuf,
447447
recvcounts, displs, recvtype, root, comm);
448-
ITT_END(MPI_TASK_GATHERV);
448+
int curr_rank;
449+
PMPI_Comm_rank(comm, &curr_rank);
450+
if(curr_rank == root) {
451+
int no_of_element = 0;
452+
int size = 0;
453+
PMPI_Comm_size(comm, &size);
454+
for (int i=0; i<size; ++i) {
455+
no_of_element += recvcounts[i];
456+
}
457+
ITT_END_MPI_EX_INFO(MPI_TASK_GATHER, sendcount*sizeof(sendtype), -1, -1, no_of_element*sizeof(recvtype), root, -1);
458+
} else {
459+
ITT_END_MPI_EX_INFO(MPI_TASK_GATHER, sendcount*sizeof(sendtype), root, -1, 0, -1, -1);
460+
}
449461
return result;
450462
}
451463

@@ -475,7 +487,20 @@ int MPI_Scatterv(const void *sendbuf, const int *sendcounts, const int *displs,
475487
ITT_BEGIN(MPI_TASK_SCATTERV);
476488
result = PMPI_Scatterv(sendbuf, sendcounts, displs,
477489
sendtype, recvbuf, recvcount, recvtype, root, comm);
478-
ITT_END(MPI_TASK_SCATTERV);
490+
491+
int curr_rank;
492+
PMPI_Comm_rank(comm, &curr_rank);
493+
if (curr_rank != root){
494+
ITT_END_MPI_EX_INFO(MPI_TASK_SCATTERV, 0, -1, -1, recvcount*sizeof(recvtype), root, -1);
495+
}else {
496+
int no_of_element = 0;
497+
int size = 0;
498+
PMPI_Comm_size(comm, &size);
499+
for (int i=0; i<size; ++i) {
500+
no_of_element += sendcounts[i];
501+
}
502+
ITT_END_MPI_EX_INFO(MPI_TASK_SCATTERV, no_of_element*sizeof(sendtype), curr_rank, -1, recvcount*sizeof(recvtype), curr_rank, -1);
503+
}
479504
return result;
480505
}
481506

@@ -496,7 +521,16 @@ int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, vo
496521
ITT_BEGIN(MPI_TASK_ALLGATHERV);
497522
result = PMPI_Allgatherv(sendbuf, sendcount, sendtype, recvbuf,
498523
recvcounts, displs, recvtype, comm);
499-
ITT_END(MPI_TASK_ALLGATHERV);
524+
525+
int no_of_element = 0;
526+
int size = 0;
527+
PMPI_Comm_size(comm, &size);
528+
for (int i=0; i<size; ++i) {
529+
no_of_element += recvcounts[i];
530+
}
531+
int curr_rank;
532+
PMPI_Comm_rank(comm, &curr_rank);
533+
ITT_END_MPI_EX_INFO(MPI_TASK_ALLGATHERV, sendcount*sizeof(sendtype), curr_rank, -1, no_of_element*sizeof(recvtype), curr_rank, -1);
500534
return result;
501535
}
502536

@@ -518,7 +552,17 @@ int MPI_Alltoallv(const void *sendbuf, const int *sendcounts,
518552
ITT_BEGIN(MPI_TASK_ALLTOALLV);
519553
result = PMPI_Alltoallv(sendbuf, sendcounts, sdispls, sendtype, recvbuf,
520554
recvcounts, rdispls, recvtype, comm);
521-
ITT_END(MPI_TASK_ALLTOALLV);
555+
int no_of_recv_element = 0;
556+
int no_of_send_element = 0;
557+
int size = 0;
558+
PMPI_Comm_size(comm, &size);
559+
for (int i=0; i<size; ++i) {
560+
no_of_recv_element += recvcounts[i];
561+
no_of_send_element += sendcounts[i];
562+
}
563+
int curr_rank;
564+
PMPI_Comm_rank(comm, &curr_rank);
565+
ITT_END_MPI_EX_INFO(MPI_TASK_ALLTOALLV, no_of_send_element*sizeof(sendtype), curr_rank, -1, no_of_recv_element*sizeof(recvtype), curr_rank, -1);
522566
return result;
523567
}
524568

@@ -584,7 +628,15 @@ int MPI_Iallgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, v
584628
ITT_BEGIN(MPI_TASK_IALLGATHERV);
585629
result = PMPI_Iallgatherv(sendbuf, sendcount, sendtype, recvbuf,
586630
recvcounts, displs, recvtype, comm, request);
587-
ITT_END(MPI_TASK_IALLGATHERV);
631+
int no_of_recv_element = 0;
632+
int size = 0;
633+
PMPI_Comm_size(comm, &size);
634+
for (int i=0; i<size; ++i) {
635+
no_of_recv_element += recvcounts[i];
636+
}
637+
int curr_rank;
638+
PMPI_Comm_rank(comm, &curr_rank);
639+
ITT_END_MPI_EX_INFO(MPI_TASK_IALLGATHERV, sendcount*sizeof(sendtype), curr_rank, -1, no_of_recv_element*sizeof(recvtype), curr_rank, -1);
588640
return result;
589641
}
590642

@@ -616,7 +668,18 @@ int MPI_Ialltoallv(const void *sendbuf, const int sendcounts[], const int sdispl
616668
ITT_BEGIN(MPI_TASK_IALLTOALLV);
617669
result = PMPI_Ialltoallv(sendbuf, sendcounts, sdispls, sendtype, recvbuf,
618670
recvcounts, rdispls, recvtype, comm, request);
619-
ITT_END(MPI_TASK_IALLTOALLV);
671+
672+
int no_of_recv_element = 0;
673+
int no_of_send_element = 0;
674+
int size = 0;
675+
PMPI_Comm_size(comm, &size);
676+
for (int i=0; i<size; ++i) {
677+
no_of_recv_element += recvcounts[i];
678+
no_of_send_element += sendcounts[i];
679+
}
680+
int curr_rank;
681+
PMPI_Comm_rank(comm, &curr_rank);
682+
ITT_END_MPI_EX_INFO(MPI_TASK_IALLTOALLV, no_of_send_element*sizeof(sendtype), curr_rank, -1, no_of_recv_element*sizeof(recvtype), curr_rank, -1);
620683
return result;
621684
}
622685

0 commit comments

Comments
 (0)