Changeset 1063


Ignore:
Timestamp:
02/27/17 14:19:19 (7 years ago)
Author:
yushan
Message:

server mode OK for both multiple and one file mode. Tested with test_client

Location:
XIOS/dev/branch_yushan
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan/extern/src_ep_dev/ep_barrier.cpp

    r1037 r1063  
    11#include "ep_lib.hpp" 
    22#include <mpi.h> 
    3 //#include "ep_declaration.hpp" 
     3#include "ep_declaration.hpp" 
    44 
    55namespace ep_lib 
    66{ 
    77 
    8  
    9  
    108  int MPI_Barrier(MPI_Comm comm) 
    119  { 
     10    if(comm.is_intercomm) return MPI_Barrier_intercomm(comm); 
    1211 
    1312    if(comm.is_ep) 
     
    2019      { 
    2120        ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.mpi_comm); 
     21 
    2222        ::MPI_Barrier(mpi_comm); 
    2323      } 
     
    2727      return 0; 
    2828    } 
    29     else if(comm.mpi_comm !=0 ) 
     29    else if(comm.mpi_comm != MPI_COMM_NULL_STD ) 
    3030    { 
    3131      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm> (comm.mpi_comm); 
     
    3737  } 
    3838 
     39 
     40  int MPI_Barrier_intercomm(MPI_Comm comm) 
     41  { 
     42 
     43    int ep_rank_loc = comm.ep_comm_ptr->size_rank_info[1].first; 
     44 
     45    MPI_Barrier_local(comm); 
     46 
     47    if(ep_rank_loc == 0) 
     48    { 
     49      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.ep_comm_ptr->intercomm->mpi_inter_comm); 
     50      ::MPI_Barrier(mpi_comm); 
     51    } 
     52 
     53    MPI_Barrier_local(comm); 
     54 
     55    return 0; 
     56 
     57  } 
     58 
     59 
    3960  int MPI_Barrier_local(MPI_Comm comm) 
    4061  { 
    41     //Message_Check(comm); 
     62    Message_Check(comm); 
    4263    comm.ep_barrier->wait(); 
    4364  } 
  • XIOS/dev/branch_yushan/extern/src_ep_dev/ep_dup.cpp

    r1037 r1063  
    7575    } 
    7676 
    77     if(!comm.mpi_comm) return 0; 
     77    if(comm.is_intercomm) return MPI_Comm_dup_intercomm(comm, newcomm); 
     78 
     79    // for intracomm 
     80    if(comm.mpi_comm == MPI_COMM_NULL_STD) return 0; 
    7881 
    7982 
     
    103106  } 
    104107 
     108  int MPI_Comm_dup_intercomm(MPI_Comm comm, MPI_Comm *newcomm) 
     109  { 
     110     
     111    if(comm.mpi_comm == MPI_COMM_NULL_STD) return 0; 
     112 
     113    int my_rank = comm.ep_comm_ptr->size_rank_info[1].first; 
     114    int num_ep  = comm.ep_comm_ptr->size_rank_info[1].second; 
     115 
     116 
     117    if(0 == my_rank) 
     118    { 
     119      MPI_Info info; 
     120      MPI_Comm *out_comm; 
     121      ::MPI_Comm mpi_dup; 
     122 
     123      ::MPI_Comm in_comm = static_cast< ::MPI_Comm>(comm.mpi_comm); 
     124 
     125      ::MPI_Comm_dup(in_comm, &mpi_dup); 
     126 
     127      MPI_Comm_create_endpoints(mpi_dup, num_ep, info, out_comm); 
     128 
     129      ::MPI_Comm mpi_inter; 
     130 
     131      ::MPI_Comm_dup(static_cast< ::MPI_Comm>(comm.ep_comm_ptr->intercomm->mpi_inter_comm), &mpi_inter); 
     132       
     133      for(int i=0; i<num_ep; i++) 
     134      { 
     135        out_comm[i].ep_comm_ptr->comm_label = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->comm_label; 
     136        out_comm[i].ep_comm_ptr->intercomm = new ep_intercomm; 
     137 
     138        out_comm[i].ep_comm_ptr->intercomm->mpi_inter_comm = mpi_inter; 
     139        out_comm[i].is_intercomm = true; 
     140 
     141        out_comm[i].ep_comm_ptr->intercomm->intercomm_rank_map = new RANK_MAP; 
     142        out_comm[i].ep_comm_ptr->intercomm->local_rank_map = new RANK_MAP; 
     143        out_comm[i].ep_comm_ptr->intercomm->remote_rank_map = new RANK_MAP; 
     144 
     145        out_comm[i].ep_comm_ptr->intercomm->intercomm_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_rank_map; 
     146        out_comm[i].ep_comm_ptr->intercomm->local_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_rank_map; 
     147        out_comm[i].ep_comm_ptr->intercomm->remote_rank_map = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->remote_rank_map; 
     148 
     149        out_comm[i].ep_comm_ptr->intercomm->local_comm = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_comm;         
     150        out_comm[i].ep_comm_ptr->intercomm->intercomm_tag = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_tag; 
     151 
     152        for(int j =0; j<3; j++) 
     153        { 
     154          out_comm[i].ep_comm_ptr->intercomm->size_rank_info[j] = comm.ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->size_rank_info[j]; 
     155        } 
     156 
     157      } 
     158 
     159      comm.ep_comm_ptr->comm_list->mem_bridge = out_comm; 
     160    } 
     161 
     162    MPI_Barrier(comm); 
     163 
     164    *newcomm = comm.ep_comm_ptr->comm_list->mem_bridge[my_rank]; 
     165     
     166 
     167    return MPI_SUCCESS; 
     168  } 
    105169 
    106170 
  • XIOS/dev/branch_yushan/extern/src_ep_dev/ep_free.cpp

    r1053 r1063  
    1010  int MPI_Comm_free(MPI_Comm *comm) 
    1111  { 
    12     //if(comm == NULL) return 0; 
    13  
    14     MPI_Barrier(*comm); 
    15  
    1612 
    1713    if(! comm->is_ep) 
     
    2723    } 
    2824 
     25    else if(comm->is_intercomm) 
     26    { 
     27      return MPI_Comm_free_intercomm(comm); 
     28    } 
     29 
    2930    else 
    3031    { 
    31       if(comm->mpi_comm == MPI_COMM_NULL_STD ) return 0; 
     32      int ep_rank_loc, num_ep; 
    3233 
    33       int ep_rank, ep_rank_loc, mpi_rank; 
    34       int ep_size, num_ep, mpi_size; 
    35  
    36       ep_rank = comm->ep_comm_ptr->size_rank_info[0].first; 
    3734      ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 
    38       mpi_rank = comm->ep_comm_ptr->size_rank_info[2].first; 
    39       ep_size = comm->ep_comm_ptr->size_rank_info[0].second; 
    4035      num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 
    41       mpi_size = comm->ep_comm_ptr->size_rank_info[2].second; 
    4236 
    4337      MPI_Barrier(*comm); 
    44  
    45  
    46       #pragma omp critical (memory_free) 
    47       if(comm->is_intercomm && comm->ep_comm_ptr->intercomm != NULL) 
    48       { 
    49         if(comm->ep_comm_ptr->intercomm->local_rank_map) comm->ep_comm_ptr->intercomm->local_rank_map->clear(); 
    50         if(comm->ep_comm_ptr->intercomm->remote_rank_map) comm->ep_comm_ptr->intercomm->remote_rank_map->clear(); 
    51         if(comm->ep_comm_ptr->intercomm->intercomm_rank_map) comm->ep_comm_ptr->intercomm->intercomm_rank_map->clear(); 
    52         Debug("intercomm local/remote/intercomm_rank_map emptied\n"); 
    53       } 
    54  
    5538 
    5639      if(ep_rank_loc == 0) 
     
    5841        Debug("comm is EP, mpi_comm_ptr != NULL\n"); 
    5942 
    60  
    61 /* 
    6243        if(comm->my_buffer != NULL) 
    6344        { 
     
    6950          if(comm->my_buffer->buf_char != NULL) delete[] comm->my_buffer->buf_char; Debug("buf_char freed\n"); 
    7051        } 
    71 */ 
     52 
    7253        if(comm->ep_barrier != NULL) 
    7354        { 
     
    7758 
    7859 
    79         if(comm->rank_map != NULL) 
     60        if( ! comm->rank_map->empty() ) 
    8061        { 
    8162          comm->rank_map->clear(); 
     
    8364        } 
    8465 
    85  
    86         if(comm->is_intercomm && comm->ep_comm_ptr->intercomm->mpi_inter_comm != MPI_COMM_NULL_STD) 
    87         { 
    88           ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->ep_comm_ptr->intercomm->mpi_inter_comm); 
    89  
    90           ::MPI_Comm_free(&mpi_comm); 
    91           //comm->ep_comm_ptr->intercomm->mpi_inter_comm = NULL; 
    92           Debug("mpi_intercomm freed\n"); 
    93         } 
    94  
    95  
    96  
    9766        for(int i=0; i<num_ep; i++) 
    9867        { 
    99           if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue != NULL) 
    100           { 
    101             comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 
    102             Debug("message queue freed\n"); 
    103           } 
     68          comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 
     69          Debug("message queue freed\n"); 
     70           
    10471 
    10572          if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr != NULL) 
     
    11481          ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->mpi_comm); 
    11582          ::MPI_Comm_free(&mpi_comm); 
    116           //comm->mpi_comm = NULL; 
    117 //          printf("label = %d, mpi_comm freed\n", comm->ep_comm_ptr->comm_label); 
     83          Debug("mpi_comm freed\n"); 
    11884        } 
    11985 
     
    12894  } 
    12995 
     96  int MPI_Comm_free_intercomm(MPI_Comm *comm) 
     97  { 
     98    int ep_rank_loc, num_ep; 
     99 
     100    ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 
     101    num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 
     102 
     103    //MPI_Barrier(*comm); 
     104 
     105    if(ep_rank_loc == 0) 
     106    { 
     107      Debug("comm is EP, mpi_comm_ptr != NULL\n"); 
     108 
     109      if(comm->my_buffer != NULL) 
     110      { 
     111        if(comm->my_buffer->buf_int != NULL) delete[] comm->my_buffer->buf_int; Debug("buf_int freed\n"); 
     112        if(comm->my_buffer->buf_float != NULL) delete[] comm->my_buffer->buf_float; Debug("buf_float freed\n"); 
     113        if(comm->my_buffer->buf_double != NULL) delete[] comm->my_buffer->buf_double; Debug("buf_double freed\n"); 
     114        if(comm->my_buffer->buf_long != NULL) delete[] comm->my_buffer->buf_long; Debug("buf_long freed\n"); 
     115        if(comm->my_buffer->buf_ulong != NULL) delete[] comm->my_buffer->buf_ulong; Debug("buf_ulong freed\n"); 
     116        if(comm->my_buffer->buf_char != NULL) delete[] comm->my_buffer->buf_char; Debug("buf_char freed\n"); 
     117      } 
     118 
     119      if(comm->ep_barrier != NULL) 
     120      { 
     121        comm->ep_barrier->~OMPbarrier(); 
     122        Debug("ep_barrier freed\n"); 
     123      } 
     124 
     125 
     126      if( ! comm->rank_map->empty() ) 
     127      { 
     128        comm->rank_map->clear(); 
     129        Debug("rank_map emptied\n"); 
     130      } 
     131 
     132      for(int i=0; i<num_ep; i++) 
     133      { 
     134        comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 
     135        Debug("message queue freed\n"); 
     136 
     137        #pragma omp critical (memory_free) 
     138        if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm != NULL) 
     139        { 
     140          comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_rank_map->clear(); 
     141          comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->remote_rank_map->clear(); 
     142          comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_rank_map->clear(); 
     143          Debug("intercomm local/remote/intercomm_rank_map emptied\n"); 
     144        }   
     145 
     146        if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr != NULL) 
     147        { 
     148          delete comm->ep_comm_ptr->comm_list[i].ep_comm_ptr; 
     149          Debug("ep_comm_ptr freed\n"); 
     150        } 
     151      } 
     152 
     153      if(comm->mpi_comm != MPI_COMM_NULL_STD) 
     154      { 
     155        ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->mpi_comm); 
     156        ::MPI_Comm_free(&mpi_comm); 
     157        Debug("mpi_comm freed\n"); 
     158      } 
     159 
     160      // if(comm->ep_comm_ptr->intercomm->mpi_inter_comm != MPI_COMM_NULL_STD) 
     161      // { 
     162         // ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->ep_comm_ptr->comm_list->ep_comm_ptr->intercomm->mpi_inter_comm); 
     163         // ::MPI_Comm_free(&mpi_comm); 
     164      //   Debug("mpi_intercomm freed\n"); 
     165      // } 
     166 
     167     if(comm != NULL) {delete[] comm->ep_comm_ptr->comm_list; Debug("comm freed\n");} 
     168 
     169    } 
     170     
     171    return 0; 
     172  } 
    130173 
    131174 
  • XIOS/dev/branch_yushan/extern/src_ep_dev/ep_lib_intercomm.hpp

    r1037 r1063  
    1111  typedef void* MPI_Op; 
    1212  #endif 
     13   
     14  int MPI_Comm_dup_intercomm(MPI_Comm comm, MPI_Comm *newcomm); 
     15 
     16  int MPI_Comm_free_intercomm(MPI_Comm* comm); 
     17 
     18  int MPI_Barrier_intercomm(MPI_Comm comm); 
    1319 
    1420  int Message_Check_intercomm(MPI_Comm comm); 
  • XIOS/dev/branch_yushan/inputs/iodef.xml

    r1060 r1063  
    1212 
    1313 
    14    <file_definition type="multiple_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 
     14   <file_definition type="one_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 
    1515     <file id="output" name="output"> 
    1616        <field field_ref="field_A_zoom" name="field_A" /> 
  • XIOS/dev/branch_yushan/src/client.cpp

    r1060 r1063  
    247247      } 
    248248 
    249       for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++) 
     249      for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); ++it) 
    250250        MPI_Comm_free(&(*it)); 
    251251       
  • XIOS/dev/branch_yushan/src/context_server.cpp

    r1060 r1063  
    123123    //printf("enter checkPendingRequest\n"); 
    124124    if(!pendingRequest.empty()) 
    125     for(it=pendingRequest.begin();it!=pendingRequest.end();it++) 
     125    for(it=pendingRequest.begin();it!=pendingRequest.end();++it) 
    126126    { 
    127127      rank=it->first; 
     
    136136      } 
    137137    } 
    138  
     138     
     139    if(!recvRequest.empty()) 
    139140    for(itRecv=recvRequest.begin();itRecv!=recvRequest.end();itRecv++) 
    140141    { 
  • XIOS/dev/branch_yushan/src/io/onetcdf4.cpp

    r1056 r1063  
    518518                                 const std::vector<StdSize>& scount, const int* data) 
    519519      { 
    520           CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
     520         CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
    521521      } 
    522522 
     
    528528                                 const std::vector<StdSize>& scount, const float* data) 
    529529      { 
    530           CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
     530         CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
    531531      } 
    532532 
  • XIOS/dev/branch_yushan/src/node/context.cpp

    r1060 r1063  
    260260       MPI_Comm_dup(interComm, &interCommServer); 
    261261       comms.push_back(interCommServer); 
     262        
     263       printf("comm_dup OK\n"); 
    262264     } 
    263265     server = new CContextServer(this,intraCommServer,interCommServer); 
  • XIOS/dev/branch_yushan/src/server.cpp

    r1060 r1063  
    101101             MPI_Intercomm_create(intraComm,0,CXios::globalComm,clientLeader,0,&newComm) ; 
    102102             interComm.push_back(newComm) ; 
    103              //printf("after inter create, interComm.size = %lu\n", interComm.size()); 
     103             printf("after inter create, interComm.size = %lu\n", interComm.size()); 
    104104           } 
    105105         } 
     
    166166      { 
    167167        if (CXios::usingOasis) oasis_finalize(); 
    168         else  {MPI_Finalize() ; printf("CServer::finalize called MPI_finalize\n");} 
     168        //else  {MPI_Finalize() ; printf("CServer::finalize called MPI_finalize\n");} 
    169169      } 
    170170 
     
    213213         
    214214 
    215         for(it=interComm.begin();it!=interComm.end();it++) 
     215        for(it=interComm.begin();it!=interComm.end();++it) 
    216216        { 
    217217           MPI_Status status ; 
     
    441441       bool finished ; 
    442442       map<string,CContext*>::iterator it ; 
    443        for(it=contextList.begin();it!=contextList.end();it++) 
     443       for(it=contextList.begin();it!=contextList.end();++it) 
    444444       { 
    445445         finished=it->second->checkBuffersAndListen(); 
  • XIOS/dev/branch_yushan/src/xios_server.f90

    r1060 r1063  
    99    CALL init_wait 
    1010    CALL xios_init_server 
     11     
     12    CALL MPI_FINALIZE(ierr) 
    1113 
    1214  END PROGRAM server_main 
Note: See TracChangeset for help on using the changeset viewer.