75 if ( pattern->
first == NULL ) {
96 for (elem = pattern->
first; elem != NULL; elem=tmp ) {
102 pattern->
first = NULL;
103 pattern->
last = NULL;
110 for (elem = pattern.
first; elem != NULL; elem = elem->
next) {
119 MPI_Request allRequest[ pattern.
numComm * 2 ];
128 for (elem = pattern.
first; elem != NULL; elem=elem->
next ) {
141 for (elem = pattern.
first; elem != NULL; elem=elem->
next ) {
165 hit_errInternal(
"patternDoUnordered",
"Unknown type of communication object",
"", __FILE__, __LINE__);
172 printf(
"CTRL %d - Waiting sends and recvs\n",
hit_Rank);
174 int ok = MPI_Waitall( cont*2, allRequest, MPI_STATUSES_IGNORE );
177 printf(
"CTRL %d - End waiting sends and recvs\n",
hit_Rank);
191 for (elem = pattern.
first; elem != NULL; elem=elem->
next ) {
202 MPI_Request allRequest[ pattern.
numComm * 2 ];
207 for (elem = pattern.
first; elem != NULL; elem=elem->
next ) {
216 for (elem = pattern.
first; elem != NULL; elem=elem->
next ) {
240 hit_errInternal(
"patternDoUnordered",
"Unknown type of communication object",
"", __FILE__, __LINE__);
247 printf(
"CTRL %d - Waiting sends and recvs\n",
hit_Rank);
249 int ok = MPI_Waitall( cont*2, allRequest, MPI_STATUSES_IGNORE );
267 #define HIT_PAT_REDISTRIBUTE2_TAG 15005
299 MPI_Comm_group( lay1.
topo.
pTopology->global->comm, &gGlobal );
317 printf(
"Ranks: Lay1: %d, Lay2: %d, Global: %d\n", myRank1, myRank2, myRankGlobal );
325 printf(
"Ranks: Lay1: %d, Lay2: %d, Global: %d ACTIVO en Lay1\n", myRank1, myRank2, myRankGlobal );
334 for ( i=0; i<numProcs2; i++ ) {
340 int foreignId = ( myRank1 + i ) % numProcs2;
342 MPI_Group_translate_ranks( gLay2, 1, &foreignId, gGlobal, &foreignIdGlobal );
349 printf(
"[%d] Topology: NumDims: %d, Cards:(%d,%d)\n",
hit_Rank,
352 printf(
"[%d] Send Comprobando foreig: %d (%d) Ranks1:(%d,%d), Ranks2(%d,%d)\n",
hit_Rank, foreignId, foreignIdGlobal,
353 foreignProc1.
rank[0],
354 foreignProc1.
rank[1],
355 foreignProc2.
rank[0],
366 printf(
"[%d] Send shapes: f1 [%d:%d][%d:%d], f2:[%d:%d][%d:%d], over2:[%d:%d][%d:%d], alreadyThere:[%d:%d][%d:%d]\n",
hit_Rank,
391 && ( myRankGlobal == foreignIdGlobal
395 fprintf(stderr,
"%s Adding send from %d to %d with shape %d [%d:%d:%d][%d:%d:%d]\n", __FUNCTION__, myRank1, foreignId,
405 printf(
"Ranks: Lay1: %d, Lay2: %d, Global: %d COM to RLay2: %d, RGlobal: %d\n", myRank1, myRank2, myRankGlobal, foreignId, foreignIdGlobal );
410 foreignProcGlobal.
rank[0] = foreignIdGlobal;
437 printf(
"Ranks: Lay1: %d, Lay2: %d, Global: %d ACTIVO en Lay2\n", myRank1, myRank2, myRankGlobal );
446 for ( i=0; i<numProcs1; i++ ) {
447 int foreignId = ( myRank2 + i ) % numProcs1;
449 MPI_Group_translate_ranks( gLay1, 1, &foreignId, gGlobal, &foreignIdGlobal );
451 printf(
"[%d] Recv Comprobando foreig: %d (%d)\n",
hit_Rank, foreignId, foreignIdGlobal );
456 printf(
"[%d] Foreign Ranks: %d,%d,%d,%d\n",
hit_Rank,
471 printf(
"[%d] After shapes: %d (%d)\n",
hit_Rank, foreignId, foreignIdGlobal );
476 && ( myRankGlobal == foreignIdGlobal
480 fprintf(stderr,
"%s Adding recv from %d to %d with shape %d [%d:%d:%d][%d:%d:%d]\n", __FUNCTION__, foreignId, myRank2,
492 foreignProcGlobal.
rank[0] = foreignIdGlobal;
495 printf(
"Ranks: Lay1: %d, Lay2: %d, Global: %d COM to RLay2: %d, RGlobal: %d\n", myRank1, myRank2, myRankGlobal, foreignId, foreignIdGlobal );
514 printf(
"[%d] Fail condition: %d (%d)\n",
hit_Rank, foreignId, foreignIdGlobal );
532 #define HIT_PAT_REDISTRIBUTE_TAG 15001
563 for ( i=0; i<numProcs; i++ ) {
564 int foreignId = ( myRank + i ) % numProcs;
579 fprintf(stderr,
"%s Adding send from %d to %d with shape %d [%d:%d:%d][%d:%d:%d]\n", __FUNCTION__, myRank, foreignId,
608 for ( i=0; i<numProcs; i++ ) {
609 int foreignId = ( myRank + i ) % numProcs;
623 fprintf(stderr,
"%s Adding recv from %d to %d with shape %d [%d:%d:%d][%d:%d:%d]\n", __FUNCTION__, foreignId, myRank,
652 #define HIT_PAT_REDISTRIBUTE_TAG2 15002
666 int numProcs = lay.
pTopology[0]->numProcs;
670 HitShape tileShapesOrig[2] = {HIT_SHAPE_NULL_STATIC,HIT_SHAPE_NULL_STATIC};
680 tileSigShapes[ myRank ][0] = hit_sShapeAccess(
hit_tileShape( tile1 ) );
681 tileSigShapes[ myRank ][1] = hit_sShapeAccess(
hit_tileShape( tile2 ) );
687 printf(
"[%d](%d) CTRL Redistribute: Before Allgather Local Send[%d:%d:%d][%d:%d:%d] Recv[%d:%d:%d][%d:%d:%d]\n",
689 tileSigShapes[ myRank ][ 0 ].sig[ 0 ].begin,
690 tileSigShapes[ myRank ][ 0 ].sig[ 0 ].end,
691 tileSigShapes[ myRank ][ 0 ].sig[ 0 ].stride,
692 tileSigShapes[ myRank ][ 0 ].sig[ 1 ].begin,
693 tileSigShapes[ myRank ][ 0 ].sig[ 1 ].end,
694 tileSigShapes[ myRank ][ 0 ].sig[ 1 ].stride,
695 tileSigShapes[ myRank ][ 1 ].sig[ 0 ].begin,
696 tileSigShapes[ myRank ][ 1 ].sig[ 0 ].end,
697 tileSigShapes[ myRank ][ 1 ].sig[ 0 ].stride,
698 tileSigShapes[ myRank ][ 1 ].sig[ 1 ].begin,
699 tileSigShapes[ myRank ][ 1 ].sig[ 1 ].end,
700 tileSigShapes[ myRank ][ 1 ].sig[ 1 ].stride
704 int ok = MPI_Allgather( MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, tileSigShapes, 2,
HIT_SHAPE_SIG,
719 for( i=0; i<numProcs; i++ ) {
721 tileShapes[i][0] = hit_shapeFromSigShape( tileSigShapes[i][0] );
722 tileShapes[i][1] = hit_shapeFromSigShape( tileSigShapes[i][1] );
725 printf(
"[%d] CTRL 2 After Allgather(A) %d Send[%d:%d:%d][%d:%d:%d] Recv[%d:%d:%d][%d:%d:%d]\n",
728 tileSigShapes[ i ][ 0 ].sig[ 0 ].begin,
729 tileSigShapes[ i ][ 0 ].sig[ 0 ].end,
730 tileSigShapes[ i ][ 0 ].sig[ 0 ].stride,
731 tileSigShapes[ i ][ 0 ].sig[ 1 ].begin,
732 tileSigShapes[ i ][ 0 ].sig[ 1 ].end,
733 tileSigShapes[ i ][ 0 ].sig[ 1 ].stride,
734 tileSigShapes[ i ][ 1 ].sig[ 0 ].begin,
735 tileSigShapes[ i ][ 1 ].sig[ 0 ].end,
736 tileSigShapes[ i ][ 1 ].sig[ 0 ].stride,
737 tileSigShapes[ i ][ 1 ].sig[ 1 ].begin,
738 tileSigShapes[ i ][ 1 ].sig[ 1 ].end,
739 tileSigShapes[ i ][ 1 ].sig[ 1 ].stride
746 if ( i == myRank ) prefixSums[0][j] = acumCard[j][0];
748 int card0 =
hit_sigCard( tileSigShapes[i][0].sig[j] );
749 tileSigShapes[i][0].sig[j].
begin = acumCard[j][0];
750 tileSigShapes[i][0].sig[j].
end = acumCard[j][0] + card0 - 1;
751 tileSigShapes[i][0].sig[j].
stride = 1;
752 acumCard[j][0] = acumCard[j][0] + card0;
756 if ( i == myRank ) prefixSums[1][j] = acumCard[j][1];
758 int card1 =
hit_sigCard( tileSigShapes[i][1].sig[j] );
759 tileSigShapes[i][1].sig[j].
begin = acumCard[j][1];
760 tileSigShapes[i][1].sig[j].
end = acumCard[j][1] + card1 - 1;
761 tileSigShapes[i][1].sig[j].
stride = 1;
762 acumCard[j][1] = acumCard[j][1] + card1;
768 tileShapesOrig[0] = tileShapes[i][0];
769 tileShapesOrig[1] = tileShapes[i][1];
772 tileShapes[i][0] = hit_shapeFromSigShape( tileSigShapes[i][0] );
773 tileShapes[i][1] = hit_shapeFromSigShape( tileSigShapes[i][1] );
776 printf(
"[%d] CTRL 2 After Allgather(C) %d Send[%d:%d:%d][%d:%d:%d] Recv[%d:%d:%d][%d:%d:%d]\n",
793 tileSigShapes[ i ][ 0 ].sig[ 0 ].begin,
794 tileSigShapes[ i ][ 0 ].sig[ 0 ].end,
795 tileSigShapes[ i ][ 0 ].sig[ 0 ].stride,
796 tileSigShapes[ i ][ 0 ].sig[ 1 ].begin,
797 tileSigShapes[ i ][ 0 ].sig[ 1 ].end,
798 tileSigShapes[ i ][ 0 ].sig[ 1 ].stride,
799 tileSigShapes[ i ][ 1 ].sig[ 0 ].begin,
800 tileSigShapes[ i ][ 1 ].sig[ 0 ].end,
801 tileSigShapes[ i ][ 1 ].sig[ 0 ].stride,
802 tileSigShapes[ i ][ 1 ].sig[ 1 ].begin,
803 tileSigShapes[ i ][ 1 ].sig[ 1 ].end,
804 tileSigShapes[ i ][ 1 ].sig[ 1 ].stride
813 HitShape localShp = tileShapes[ myRank ][0];
818 for ( i=0; i<numProcs; i++ ) {
819 int foreignId = ( myRank + i ) % numProcs;
823 HitShape foreignShp1 = tileShapes[ foreignId ][0];
824 HitShape foreignShp2 = tileShapes[ foreignId ][1];
837 fprintf(stderr,
"[%d] Init translation send from %d to %d with shape %d [%d:%d:%d][%d:%d:%d]\n",
863 (
hit_shapeSig( overlapShp2, j ).begin - prefixSums[0][j] )
882 (
hit_shapeSig( overlapShp2, j ).end - prefixSums[0][j] )
893 fprintf(stderr,
"%s Adding send from %d to %d with shape %d [%d:%d:%d][%d:%d:%d]\n", __FUNCTION__, myRank, foreignId,
917 HitShape localShp1 = tileShapes[ myRank ][0];
918 HitShape localShp2 = tileShapes[ myRank ][1];
924 for ( i=0; i<numProcs; i++ ) {
925 int foreignId = ( myRank + i ) % numProcs;
929 HitShape foreignShp1 = tileShapes[ foreignId ][0];
942 fprintf(stderr,
"[%d] Init translation recv from %d to %d with shape %d [%d:%d:%d][%d:%d:%d]\n",
959 (
hit_shapeSig( overlapShp, j ).begin - prefixSums[1][j] )
965 (
hit_shapeSig( overlapShp, j ).end - prefixSums[1][j] )
975 fprintf(stderr,
"%s Adding recv from %d to %d with shape %d [%d:%d:%d][%d:%d:%d]\n", __FUNCTION__, foreignId, myRank,
1039 for(i=0; i<nrecv; i++){
1046 for(i=0; i<numProcs-1; i++){
1047 rdispls[i+1] = rdispls[i] + recvcnts[i];
1061 MPI_Alltoall(recvcnts, 1, MPI_INT,sendcnts, 1, MPI_INT, MPI_COMM_WORLD);
1064 for(i=0; i<numProcs-1; i++){
1065 sdispls[i+1] = sdispls[i] + sendcnts[i];
1069 int nsend = sdispls[numProcs-1] + sendcnts[numProcs-1];
1078 sendlist, sendcnts, sdispls, MPI_INT, MPI_COMM_WORLD);
1084 for(i=0; i<nsend; i++){
1095 for(i=0; i<numProcs; i++){
1122 ok = MPI_Type_create_indexed_block(sendcnts[i],1,&(sendlist[sdispls[i]]),baseType,&tsend);
1124 ok = MPI_Type_commit(&tsend);
1141 ok = MPI_Type_contiguous(recvcnts[i],baseType,&trecv);
1143 ok = MPI_Type_commit(&trecv);
1151 crecv.
dataRecv = (
char*) tileRecv->data + (
size_t) rdispls[i] * tileRecv->baseExtent;
1164 if(sendcnts[i] != 0 )
1166 if(recvcnts[i] != 0 )
1220 for(i=0; i<nrecv; i++){
1230 for(i=0; i<numProcs-1; i++){
1231 rdispls[i+1] = rdispls[i] + recvcnts[i];
1265 MPI_Alltoall(recvcnts, 1, MPI_INT,sendcnts, 1, MPI_INT, MPI_COMM_WORLD);
1269 for(i=0; i<numProcs-1; i++){
1270 sdispls[i+1] = sdispls[i] + sendcnts[i];
1274 int nsend = sdispls[numProcs-1] + sendcnts[numProcs-1];
1283 sendlist, sendcnts, sdispls, MPI_INT, MPI_COMM_WORLD);
1305 for(i=0; i<nsend; i++){
1315 for(i=0; i<numProcs; i++){
1346 ok = MPI_Type_create_indexed_block(sendcnts[i],1,&(sendlist[sdispls[i]]),baseType,&tsend);
1348 ok = MPI_Type_commit(&tsend);
1365 ok = MPI_Type_contiguous(recvcnts[i],baseType,&trecv);
1367 ok = MPI_Type_commit(&trecv);
1375 crecv.
dataRecv = (
char*) tileRecv->data + (
size_t) rdispls[i] * tileRecv->baseExtent;
1388 if(sendcnts[i] != 0 )
1390 if(recvcnts[i] != 0 )
void hit_patternEndAsync(HitPattern pattern)
void hit_comDoReduce(HitCom *issue)
HitLayout HIT_LAYOUT_NULL
#define hit_layShape(lay)
HitShape hit_shapeIntersect(HitShape sh1, HitShape sh2)
void hit_comDoSendRecvReplace(HitCom *issue)
void hit_patternDoOrdered(HitPattern pattern)
#define hit_bShapeCard(shape, dim)
void hit_comFree(HitCom issue)
HitPattern hit_patternLayRedistribute(HitLayout lay1, HitLayout lay2, void *tileP1, void *tileP2, HitType baseType)
void hit_comDo(HitCom *issue)
#define hit_bShapeNameList(shape, dim)
int hit_shapeCmp(HitShape sh1, HitShape sh2)
void hit_comStartRecv(HitCom *issue)
#define hit_calloc(ptr, type, nmemb)
HitPattern HIT_PATTERN_NULL
#define hit_layShapeOther(lay, ranks)
#define hit_cShapeCard(shape, dim)
HitPTopology * pTopology[HIT_MAXDIMS+1]
void hit_patMatMultInternal(HitPattern *pattern, HitLayout lay, HitShape origin_matrix, HitShape matrix, const void *tilePSend, const void *tilePRecv, HitType baseType, const char *file, int line)
#define HIT_COM_ARRAYCOORDS
HitPattern hit_patternLayRedistribute2(HitLayout lay1, HitLayout lay2, void *tileP1, void *tileP2, HitType baseType)
#define HIT_PAT_REDISTRIBUTE2_TAG
#define HIT_PAT_UNORDERED
void hit_patternAdd(HitPattern *pattern, HitCom comm)
void hit_comDoAlltoallv(HitCom *issue)
void hit_comDoAlltoall(HitCom *issue)
#define hit_shapeDims(shape)
HitRanks hit_topRanksInternal(HitTopology topo, int linealRank)
#define hit_mpiTestError(ok, cad)
#define HIT_PAT_REDISTRIBUTE_TAG
#define hit_cShapeNameList(shape, dim)
#define hit_malloc(ptr, type, nmemb)
void hit_patternFree(HitPattern *pattern)
#define HIT_PAT_REDISTRIBUTE_TAG2
HitPattern hit_patternRedistribute(HitLayout lay, void *tileP1, void *tileP2, HitType baseType, int flagCompact)
#define hit_layImActive(lay)
void hit_comDoBroadcast(HitCom *issue)
void hit_patMatMultBitmapInternal(HitPattern *pattern, HitLayout lay, HitShape origin_matrix, HitShape matrix, const void *tilePSend, const void *tilePRecv, HitType baseType, const char *file, int line)
int hit_topCard(HitTopology topo)
void hit_patternDoUnordered(HitPattern pattern)
#define hit_lgr_elementGroup(lay, element)
void hit_patternCompose(HitPattern *pattern, HitPattern *pattern2)
#define HIT_PATTERN_NULL_STATIC
#define HIT_SENDRECV_REPLACE
void hit_patternStartAsync(HitPattern pattern)
#define hit_topSelfRankInternal(topo)
int numActives[HIT_MAXDIMS]
#define hit_shapeSig(shape, dim)
#define hit_layToTopoRanks(lay, ranks)
#define hit_comSendSelectTag(lay, sendTo, tileP, selection, modeSelect, baseType, tag)
#define hit_ranks(numDims,...)
#define hit_errInternal(routine, text, extraParam, file, numLine)
#define hit_sigCmp(s1, s2)
#define hit_tileShape(var)
#define hit_comRecvSelectTag(lay, receiveFrom, tileP, selection, modeSelect, baseType, tag)
void hit_comStartSend(HitCom *issue)