Changeset 1270
- Timestamp:
- 09/18/17 14:38:55 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/XIOS_DEV_CMIP6/src/server.cpp
r1244 r1270 613 613 MPI_Status status ; 614 614 int flag ; 615 static void* buffer ; 616 static MPI_Request request ; 617 static bool recept=false ; 615 static std::vector<void*> buffers; 616 static std::vector<MPI_Request> requests ; 617 static std::vector<bool> recept; 618 static std::vector<int> counts ; 619 MPI_Request request; 620 621 // void* buffer ; 622 // static MPI_Request request ; 623 // static bool recept=false ; 624 // static int count ; 618 625 int rank ; 619 // int count ;620 static int count ;621 626 const int root=0 ; 622 627 boost::hash<string> hashString; 623 628 size_t hashId = hashString("RegisterContext"); 624 629 625 // (1) Receive context id from the root 626 if (recept==false) 630 // (1) Receive context id from the root, save it into a buffer 631 if (recept.size() == nbContexts) recept.push_back(false); 632 if (recept[nbContexts]==false) 627 633 { 628 634 traceOff() ; … … 631 637 if (flag==true) 632 638 { 633 MPI_Get_count(&status,MPI_CHAR,&count) ; 634 buffer=new char[count] ; 635 MPI_Irecv((void*)buffer,count,MPI_CHAR,root,2,intraComm,&request) ; 636 recept=true ; 637 } 638 } 639 // (2) If context id is received, save it into a buffer and register an event 639 counts.push_back(0); 640 MPI_Get_count(&status,MPI_CHAR,&counts[nbContexts]) ; 641 requests.push_back(request); 642 buffers.push_back(new char[counts[nbContexts]]) ; 643 MPI_Irecv((void*)(buffers.back()),counts.back(),MPI_CHAR,root,2,intraComm,&(requests.back())) ; 644 recept[nbContexts]=true ; 645 } 646 } 647 // (2) If context id is received, register an event 640 648 else 641 649 { 642 MPI_Test(&request ,&flag,&status) ;650 MPI_Test(&requests[nbContexts],&flag,&status) ; 643 651 if (flag==true) 644 652 { 645 MPI_Get_count(&status,MPI_CHAR,&count) ;646 653 eventScheduler->registerEvent(nbContexts,hashId); 647 // registerContext((void*)buffer,count) ; 648 // delete [] buffer ; 649 recept=false ; 654 recept[nbContexts]=false ; 650 655 } 651 656 } … … 653 658 if (eventScheduler->queryEvent(nbContexts,hashId)) 654 659 { 655 registerContext(buffer,count) ; 660 registerContext(buffers[nbContexts],counts[nbContexts]) ; 661 delete [] buffers[nbContexts] ; 656 662 ++nbContexts; 657 delete [] buffer ;658 663 } 659 664 }
Note: See TracChangeset
for help on using the changeset viewer.