Ignore:
Timestamp:
06/04/18 19:25:08 (6 years ago)
Author:
yushan
Message:

save dev. TO DO : test with xios

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_probe.cpp

    r1362 r1520  
    66namespace ep_lib 
    77{ 
     8  int MPI_Iprobe_mpi(int src, int tag, MPI_Comm comm, int *flag, MPI_Status *status) 
     9  { 
     10    status->ep_src = src; 
     11    status->ep_tag = tag; 
     12    return ::MPI_Iprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm->mpi_comm), flag, to_mpi_status_ptr(*status)); 
     13  } 
    814 
    915  int MPI_Iprobe(int src, int tag, MPI_Comm comm, int *flag, MPI_Status *status) 
    1016  { 
    11     *flag = false; 
     17    if(!comm->is_ep) 
     18    { 
     19      Debug("MPI_Iprobe with MPI\n"); 
     20      return MPI_Iprobe_mpi(src, tag, comm, flag, status); 
     21    } 
     22     
     23    else 
     24    { 
     25      Debug("MPI_Iprobe with EP\n"); 
     26       
     27      *flag = false; 
     28     
     29      Message_Check(comm); 
    1230 
    13     if(!comm.is_ep) 
    14     { 
    15       ::MPI_Status *mpi_status = static_cast< ::MPI_Status* >(status->mpi_status); 
    16       ::MPI_Iprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm.mpi_comm), flag, mpi_status); 
     31      #pragma omp flush 
    1732 
    18       status->mpi_status = mpi_status; 
    19       status->ep_src = src; 
    20       status->ep_tag = tag; 
    21       return 0; 
    22     } 
    23  
    24     Debug("calling MPI_Iprobe EP\n"); 
    25  
    26     Message_Check(comm); 
    27  
    28     #pragma omp flush 
    29  
    30     #pragma omp critical (_query) 
    31     if(!comm.ep_comm_ptr->message_queue->empty()) 
    32     { 
    33       for(Message_list::iterator it = comm.ep_comm_ptr->message_queue->begin(); it!= comm.ep_comm_ptr->message_queue->end(); ++it) 
     33      #pragma omp critical (_query) 
     34      for(Message_list::iterator it = comm->ep_comm_ptr->message_queue->begin(); it!= comm->ep_comm_ptr->message_queue->end(); ++it) 
    3435      { 
    35         bool src_matched = src<0? true: it->ep_src == src; 
    36         bool tag_matched = tag<0? true: it->ep_tag == tag; 
     36        bool src_matched = src<0? true: (*it)->ep_src == src; 
     37        bool tag_matched = tag<0? true: (*it)->ep_tag == tag; 
    3738         
    3839        if(src_matched && tag_matched)         
    3940        { 
    4041          Debug("find message\n"); 
     42           
     43 
     44          status->mpi_status = new ::MPI_Status(*static_cast< ::MPI_Status*>((*it)->mpi_status)); 
     45          status->ep_src = (*it)->ep_src; 
     46          status->ep_tag = (*it)->ep_tag; 
     47 
    4148          *flag = true; 
    42  
    43           ::MPI_Status mpi_status = *(static_cast< ::MPI_Status *>(it->mpi_status)); 
    44  
    45           status->mpi_status = new ::MPI_Status(mpi_status); 
    46           status->ep_src = it->ep_src; 
    47           status->ep_tag = it->ep_tag; 
    48  
    4949          break; 
    5050        } 
    51  
    5251      } 
    5352    } 
    54  
    55     return 0; 
    5653  } 
    5754 
     
    6057  int MPI_Improbe(int src, int tag, MPI_Comm comm, int *flag, MPI_Message *message, MPI_Status *status) 
    6158  { 
     59    int ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 
     60    int mpi_rank    = comm->ep_comm_ptr->size_rank_info[2].first; 
    6261    *flag = false; 
    63     if(!comm.is_ep) 
     62    if(!comm->is_ep) 
    6463    { 
    6564      Debug("calling MPI_Improbe MPI\n"); 
     
    7170      #pragma omp critical (_mpi_call) 
    7271      { 
    73         ::MPI_Iprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm.mpi_comm), flag, &mpi_status); 
     72        ::MPI_Iprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm->mpi_comm), flag, &mpi_status); 
    7473        if(*flag) 
    7574        { 
    76           ::MPI_Mprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm.mpi_comm), &mpi_message, &mpi_status); 
     75          ::MPI_Mprobe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm->mpi_comm), &mpi_message, &mpi_status); 
    7776        } 
    7877      } 
    7978      #elif _intelmpi 
    80         ::MPI_Improbe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm.mpi_comm), flag, &mpi_message, &mpi_status); 
     79        ::MPI_Improbe(src<0? MPI_ANY_SOURCE : src, tag<0? MPI_ANY_TAG: tag, to_mpi_comm(comm->mpi_comm), flag, &mpi_message, &mpi_status); 
    8180      #endif 
    8281         
    83       status->mpi_status = new ::MPI_Status(mpi_status); 
     82      status->mpi_status = &mpi_status; 
    8483      status->ep_src = src; 
    8584      status->ep_tag = tag; 
    8685 
    87       message->mpi_message = new ::MPI_Message; 
    88       *(static_cast< ::MPI_Message*>(message->mpi_message)) = mpi_message; 
    89       message->ep_src = src; 
    90       message->ep_tag = tag; 
     86      (*message)->mpi_message = &message; 
     87      (*message)->ep_src = src; 
     88      (*message)->ep_tag = tag; 
     89       
     90       
    9191      return 0; 
    9292    } 
    9393 
    94      
    95     //Message_Check(comm); 
     94    
    9695 
    9796    #pragma omp flush 
    9897 
    9998    #pragma omp critical (_query) 
    100     if(! comm.ep_comm_ptr->message_queue->empty()) 
     99    if(! comm->ep_comm_ptr->message_queue->empty()) 
    101100    { 
    102       for(Message_list::iterator it = comm.ep_comm_ptr->message_queue->begin(); it!= comm.ep_comm_ptr->message_queue->end(); ++it) 
     101      for(Message_list::iterator it = comm->ep_comm_ptr->message_queue->begin(); it!= comm->ep_comm_ptr->message_queue->end(); ++it) 
    103102      { 
    104         bool src_matched = src<0? true: it->ep_src == src; 
    105         bool tag_matched = tag<0? true: it->ep_tag == tag; 
     103                                           
     104        bool src_matched = src<0? true: (*it)->ep_src == src; 
     105        bool tag_matched = tag<0? true: (*it)->ep_tag == tag; 
    106106         
    107107        if(src_matched && tag_matched) 
     
    109109          *flag = true; 
    110110 
    111           ::MPI_Status mpi_status; 
    112           mpi_status = *(static_cast< ::MPI_Status *>(it->mpi_status)); 
     111          status->mpi_status = new ::MPI_Status(*static_cast< ::MPI_Status*>((*it)->mpi_status)); 
     112          memcheck("new "<< status->mpi_status << " : in ep_lib::MPI_Improbe, status->mpi_status = new ::MPI_Status"); 
     113          status->ep_src = (*it)->ep_src; 
     114          status->ep_tag = (*it)->ep_tag; 
    113115 
    114           status->mpi_status = new ::MPI_Status(mpi_status); 
    115           status->ep_src = it->ep_src; 
    116           status->ep_tag = it->ep_tag; 
    117  
    118           message->mpi_message = it->mpi_message; 
    119           message->ep_tag = it->ep_tag; 
    120           message->ep_src = it->ep_src; 
     116          (*message)->mpi_message = new ::MPI_Message(*static_cast< ::MPI_Message*>((*it)->mpi_message)); 
     117          memcheck("new "<< (*message)->mpi_message <<" : in ep_lib::MPI_Improbe, (*message)->mpi_message = new ::MPI_Message"); 
     118          (*message)->ep_src = (*it)->ep_src; 
     119          (*message)->ep_tag = (*it)->ep_tag; 
     120                                       
    121121 
    122122          #pragma omp critical (_query2) 
    123123          {               
    124             delete it->mpi_status; 
    125             comm.ep_comm_ptr->message_queue->erase(it); 
     124            memcheck("delete "<< (*it)->mpi_message <<" : in ep_lib::Message_Check, delete (*it)->mpi_message"); 
     125            memcheck("delete "<< (*it)->mpi_status <<" : in ep_lib::Message_Check, delete (*it)->mpi_status"); 
     126            memcheck("delete "<< (*it) <<" : in ep_lib::Message_Check, delete (*it)"); 
     127             
     128             
     129            delete (*it)->mpi_message;      
     130            delete (*it)->mpi_status;  
     131            delete *it; 
     132             
     133                        
     134            comm->ep_comm_ptr->message_queue->erase(it); 
     135            memcheck("message_queue["<<mpi_rank<<","<<ep_rank_loc<<"]->size = "<<comm->ep_comm_ptr->message_queue->size()); 
    126136            #pragma omp flush 
    127137          } 
    128  
     138           
    129139          break; 
    130140        } 
Note: See TracChangeset for help on using the changeset viewer.