Changeset 2972

Show
Ignore:
Timestamp:
06/26/09 17:22:55 (9 months ago)
Author:
tautges
Message:

Fixing pcomm_unit for more arbitrary cases where you don't know
beforehand how many / which procs you're communicating with.

pcomm_unit: added a test_pack_shared_arbitrary test, to test parallel

read of an arbitrary file (may be commented out eventually)

parallel_unit_tests: replaced ptest.cub with 64bricks_512hex.h5m
ReadParallel?: made some functions public so that they can be called in

tests

MBParallelComm:
- don't initialize size of buffers, leave them to be zero-sized
- move calls to get_buffers into get_interface_procs, controlled by a

boolean flag to the function (normally false, so it isn't done)

- in serial version of exchange_ghost_cells, if buffer is empty, don't

call unpack function; this happens sometimes when a proc receives
entities owned by a third proc, and has to return handles to that
proc; in this case, that third proc didn't send this proc any
entities, even though it's in this proc's communicating procs list;
parallel version doesn't see this 'cuz it never receives a message
with entities from that third proc

- added function to set proc size in addition to proc rank

Location:
MOAB/branches/parallel_ghosting/parallel
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • MOAB/branches/parallel_ghosting/parallel/MBParallelComm.cpp

    r2962 r2972  
    105105          _new_size = _old_size + (addl_space);    \ 
    106106      if (_new_size > buff_vec.size()) {               \ 
    107         buff_vec.resize(1.5*_new_size);             \ 
     107        buff_vec.resize(1.5*_new_size);            \ 
    108108        buff_ptr = &buff_vec[_new_size-(addl_space)];} } 
    109109     
     
    331331    ind = buffProcs.size(); 
    332332    buffProcs.push_back((unsigned int)to_proc); 
    333     ownerSBuffs.push_back(std::vector<unsigned char>(INITIAL_BUFF_SIZE)); 
    334     ghostRBuffs.push_back(std::vector<unsigned char>(INITIAL_BUFF_SIZE)); 
     333    ownerSBuffs.push_back(std::vector<unsigned char>()); 
     334    ghostRBuffs.push_back(std::vector<unsigned char>()); 
    335335      // allocate these other buffs in case we're storing remote handles 
    336     ownerRBuffs.push_back(std::vector<unsigned char>(INITIAL_BUFF_SIZE)); 
    337     ghostSBuffs.push_back(std::vector<unsigned char>(INITIAL_BUFF_SIZE)); 
     336    ownerRBuffs.push_back(std::vector<unsigned char>()); 
     337    ghostSBuffs.push_back(std::vector<unsigned char>()); 
    338338    if (is_new) *is_new = true; 
    339339  } 
     
    14281428{ 
    14291429  if (NULL == ents && 0 == num_ents) { 
    1430     return list_entities(NULL, 0); 
     1430    sharedEnts.print("Shared entities:\n"); 
     1431    return MB_SUCCESS; 
    14311432  } 
    14321433   
     
    26122613    // establish comm procs and buffers for them 
    26132614  std::set<unsigned int> procs; 
    2614   result = get_interface_procs(procs); 
     2615  result = get_interface_procs(procs, true); 
    26152616  RRA("Trouble getting iface procs."); 
    2616   for (std::set<unsigned int>::iterator sit = procs.begin(); sit != procs.end(); sit++) 
    2617     get_buffers(*sit); 
    26182617 
    26192618    // resolve shared entity remote handles; implemented in ghost cell exchange 
     
    27192718      // establish comm procs and buffers for them 
    27202719    psets.clear(); 
    2721     rval = pc[p]->get_interface_procs(psets); 
     2720    rval = pc[p]->get_interface_procs(psets, true); 
    27222721    if (MB_SUCCESS != rval) return rval; 
    2723     for (std::set<unsigned int>::iterator sit = psets.begin(); sit != psets.end(); sit++) 
    2724       pc[p]->get_buffers(*sit); 
    2725  
    27262722  } 
    27272723   
     
    31683164   
    31693165  //! get processors with which this processor communicates; sets are sorted by processor 
    3170 MBErrorCode MBParallelComm::get_interface_procs(std::set<unsigned int> &procs_set) 
     3166MBErrorCode MBParallelComm::get_interface_procs(std::set<unsigned int> &procs_set, 
     3167                                                bool get_buffs) 
    31713168{ 
    31723169    // make sure the sharing procs vector is empty 
     
    32013198    } 
    32023199  } 
     3200 
     3201  if (get_buffs) { 
     3202    for (std::set<unsigned int>::iterator sit = procs_set.begin(); sit != procs_set.end(); sit++) 
     3203      get_buffers(*sit); 
     3204  } 
    32033205   
    32043206  return MB_SUCCESS; 
     
    37403742        // incoming ghost entities; unpack; returns entities received 
    37413743        // both from sending proc and from owning proc (which may be different) 
     3744 
     3745        // buffer could be empty, which means there isn't any message to 
     3746        // unpack (due to this comm proc getting added as a result of indirect 
     3747        // communication); just skip this unpack 
     3748      if (pc->ownerSBuffs[ind].empty()) continue; 
     3749 
    37423750      unsigned int to_p = pc->buffProcs[ind]; 
    37433751      unsigned char *buff_ptr = &pc->ownerSBuffs[ind][0]; 
  • MOAB/branches/parallel_ghosting/parallel/MBParallelComm.hpp

    r2962 r2972  
    327327*/ 
    328328    //! get processors with which this processor shares an interface 
    329   MBErrorCode get_interface_procs(std::set<unsigned int> &iface_procs); 
     329  MBErrorCode get_interface_procs(std::set<unsigned int> &iface_procs, 
     330                                  const bool get_buffs = false); 
    330331 
    331332    //! get processors with which this processor communicates 
     
    495496    //! set rank for this pcomm; USED FOR TESTING ONLY! 
    496497  void set_rank(unsigned int r); 
     498   
     499    //! set rank for this pcomm; USED FOR TESTING ONLY! 
     500  void set_size(unsigned int r); 
    497501   
    498502    //! get (and possibly allocate) buffers for messages to/from to_proc; returns 
     
    10341038} 
    10351039 
     1040inline void MBParallelComm::set_size(unsigned int s)  
     1041{ 
     1042  procConfig.proc_size(s); 
     1043} 
     1044 
    10361045inline MBErrorCode MBParallelComm::get_sharing_data(MBEntityHandle entity, 
    10371046                                                    int *ps,  
  • MOAB/branches/parallel_ghosting/parallel/ReadParallel.hpp

    r2229 r2972  
    3232                        const int num_material_sets ); 
    3333   
    34     //! Constructor 
    35   ReadParallel(MBInterface* impl = NULL, MBParallelComm *pc = NULL); 
    36  
    37    //! Destructor 
    38   virtual ~ReadParallel() {} 
    39  
    40   static const char *parallelOptsNames[]; 
    41    
    42   enum ParallelOpts {POPT_NONE=0, POPT_BCAST, POPT_BCAST_DELETE,  
    43                      POPT_READ_DELETE, POPT_READ_PARALLEL, 
    44                      POPT_FORMAT, POPT_DEFAULT}; 
    45    
    46 protected: 
    47  
    48 private: 
    4934  MBErrorCode load_file(const char **file_names, 
    5035                        const int num_files, 
     
    6550                        const int bridge_dim, 
    6651                        const int num_layers); 
     52    //! Constructor 
     53  ReadParallel(MBInterface* impl = NULL, MBParallelComm *pc = NULL); 
    6754 
     55   //! Destructor 
     56  virtual ~ReadParallel() {} 
     57 
     58  static const char *parallelOptsNames[]; 
     59   
     60  enum ParallelOpts {POPT_NONE=0, POPT_BCAST, POPT_BCAST_DELETE,  
     61                     POPT_READ_DELETE, POPT_READ_PARALLEL, 
     62                     POPT_FORMAT, POPT_DEFAULT}; 
     63 
     64    //! PUBLIC TO ALLOW TESTING 
    6865  MBErrorCode delete_nonlocal_entities(std::string &ptag_name, 
    6966                                       std::vector<int> &ptag_vals, 
     
    7269   
    7370  MBErrorCode delete_nonlocal_entities(MBEntityHandle file_set); 
     71 
     72protected: 
     73 
     74private: 
    7475 
    7576  MBInterface *mbImpl; 
  • MOAB/branches/parallel_ghosting/parallel/parallel_unit_tests.cpp

    r2962 r2972  
    188188  if (!filename) { 
    189189#ifdef SRCDIR 
    190     filename = STRINGIFY(SRCDIR) "/ptest.cub"; 
     190    filename = STRINGIFY(SRCDIR) "/../test/64bricks_512hex.h5m"; 
    191191#else 
    192     filename = "ptest.cub"; 
     192    filename = "../test/64bricks_512hex.h5m"; 
    193193#endif 
    194194  } 
  • MOAB/branches/parallel_ghosting/parallel/pcomm_unit.cpp

    r2961 r2972  
    44#include "MBCore.hpp" 
    55#include "MeshTopoUtil.hpp" 
     6#include "ReadParallel.hpp" 
     7#include "FileOptions.hpp" 
    68#include "TestUtil.hpp" 
    79#include <algorithm> 
     
    4446/** Test pack/unpack of shared entities in 3d*/ 
    4547void test_pack_shared_entities_3d(); 
     48/** Test pack/unpack of arbitrary mesh file */ 
     49void test_pack_shared_arbitrary(); 
    4650/** Test filter_pstatus function*/ 
    4751void test_filter_pstatus(); 
     
    7074  num_err += RUN_TEST( test_pack_shared_entities_2d ); 
    7175  num_err += RUN_TEST( test_pack_shared_entities_3d ); 
     76  num_err += RUN_TEST( test_pack_shared_arbitrary ); 
    7277  num_err += RUN_TEST( test_filter_pstatus ); 
    7378   
     
    18491854    // now 1 layer of hex ghosts 
    18501855  rval = MBParallelComm::exchange_ghost_cells(pc, 4, 3, 0, 1, true); 
     1856  CHECK_ERR(rval); 
     1857} 
     1858 
     1859void test_pack_shared_arbitrary() 
     1860{ 
     1861#define NP 4 
     1862  MBCore moab[NP]; 
     1863  MBParallelComm *pc[NP]; 
     1864  for (unsigned int i = 0; i < NP; i++) { 
     1865    pc[i] = new MBParallelComm(&moab[i]); 
     1866    pc[i]->set_rank(i); 
     1867    pc[i]->set_size(NP); 
     1868  } 
     1869 
     1870  std::string ptag_name("MATERIAL_SET"); 
     1871  std::vector<int> pa_vec; 
     1872  pa_vec.push_back(0); 
     1873  pa_vec.push_back(4); 
     1874  pa_vec.push_back(2); 
     1875  MBErrorCode rval; 
     1876 
     1877  const char *fnames[] = {"/home/tautges/MOABpar2/test/64bricks_512hex.h5m"}; 
     1878   
     1879  std::string partition_name("MATERIAL_SET"); 
     1880  FileOptions fopts(NULL); 
     1881   
     1882  for (unsigned int i = 0; i < NP; i++) { 
     1883    ReadParallel rp(moab+i, pc[i]); 
     1884    MBEntityHandle tmp_set = 0; 
     1885    std::vector<int> partition_tag_vals; 
     1886    rval = rp.load_file(fnames, 1, tmp_set, ReadParallel::POPT_READ_DELETE, 
     1887                        partition_name,  
     1888                        partition_tag_vals, true, pa_vec, NULL, 0, 
     1889                        fopts, i, false, -1, -1, -1, -1, 0); 
     1890    CHECK_ERR(rval); 
     1891  } 
     1892   
     1893  rval = MBParallelComm::resolve_shared_ents(pc, NP, 3); 
     1894  CHECK_ERR(rval); 
     1895 
     1896    // exchange interface cells 
     1897  rval = MBParallelComm::exchange_ghost_cells(pc, NP, -1, -1, 0, true); 
     1898  CHECK_ERR(rval); 
     1899   
     1900    // now 1 layer of hex ghosts 
     1901  rval = MBParallelComm::exchange_ghost_cells(pc, NP, 3, 0, 1, true); 
    18511902  CHECK_ERR(rval); 
    18521903}