Changeset 3296
- Timestamp:
- 11/06/09 12:37:19 (2 weeks ago)
- Location:
- MOAB/trunk/parallel
- Files:
-
- 1 added
- 3 modified
-
MBParallelComm.cpp (modified) (29 diffs)
-
Makefile.am (modified) (2 diffs)
-
pcomm_serial.cpp (added)
-
pcomm_unit.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
MOAB/trunk/parallel/MBParallelComm.cpp
r3255 r3296 48 48 49 49 #undef DEBUG_MPE 50 //#define DEBUG_MPE 1 50 51 #ifdef DEBUG_MPE 51 52 #include "mpe.h" … … 54 55 int SHAREDV_START, SHAREDV_END; 55 56 int RESOLVE_START, RESOLVE_END; 57 int ENTITIES_START, ENTITIES_END; 58 int RHANDLES_START, RHANDLES_END; 59 56 60 #endif 57 61 #undef DEBUG_COMM 62 //#define DEBUG_COMM 1 58 63 #undef DEBUG_PACKING 59 64 #undef DEBUG_MSGS … … 489 494 MPI_UNSIGNED_CHAR, to_proc, 490 495 mesg_tag+1, procConfig.proc_comm(), &send_req2); 496 // put this inside so we can stop on completion in the debugger 491 497 if (success != MPI_SUCCESS) return MB_FAILURE; 492 498 } … … 868 874 PACK_INTS(buff_ptr, tmp_procs, num_ents); 869 875 PACK_EH(buff_ptr, tmp_handles, num_ents); 876 877 #ifndef NDEBUG 878 // check for duplicates in proc list 879 unsigned int dp = 0; 880 for (; dp < MAX_SHARING_PROCS && -1 != tmp_procs[dp]; dp++) 881 dumprocs.insert(tmp_procs[dp]); 882 assert(dumprocs.size() == dp); 883 dumprocs.clear(); 884 #endif 870 885 } 871 886 } … … 1016 1031 } 1017 1032 1033 // put -1 after procs and 0 after handles 1034 if (MAX_SHARING_PROCS > num_ents) { 1035 tmp_procs[num_ents] = -1; 1036 tmp_handles[num_ents] = 0; 1037 } 1038 1018 1039 return MB_SUCCESS; 1019 1040 } … … 1312 1333 for (i = 0; i < num_ents; i++) { 1313 1334 UNPACK_INT(buff_ptr, j); 1314 assert(j >= 0 && "Should be non-negative # proc/handles."); 1335 if (j < 0) { 1336 std::cout << "Should be non-negative # proc/handles."; 1337 return MB_FAILURE; 1338 } 1339 1315 1340 buff_ptr += j * (sizeof(int)+sizeof(MBEntityHandle)); 1316 1341 } … … 1355 1380 // pointers to other procs/handles 1356 1381 UNPACK_INT(buff_save, num_ps); 1357 assert("Shouldn't ever be fewer than 1 procs here." && 0 < num_ps); 1382 if (0 >= num_ps) { 1383 std::cout << "Shouldn't ever be fewer than 1 procs here." << std::endl; 1384 return MB_FAILURE; 1385 } 1386 1358 1387 UNPACK_INTS(buff_save, &ps[0], num_ps); 1359 1388 UNPACK_EH(buff_save, &hs[0], num_ps); … … 1441 1470 (created_here ? (PSTATUS_GHOST | PSTATUS_NOT_OWNED) : 0))); 1442 1471 RRA(""); 1443 1472 1444 1473 // need to send this new handle to all sharing procs 1445 1474 if (!is_iface) { … … 1507 1536 } 1508 1537 1509 MBErrorCode MBParallelComm::print_buffer(unsigned char *buff_ptr, int mesg_tag, 1538 MBErrorCode MBParallelComm::print_buffer(unsigned char *buff_ptr, 1539 int mesg_tag, 1510 1540 int from_proc, bool sent) 1511 1541 { … … 1516 1546 << " to/from proc " << from_proc << "; contents:" << std::endl; 1517 1547 1548 int msg_length; 1549 unsigned char *orig_ptr = buff_ptr; 1550 UNPACK_INT(buff_ptr, msg_length); 1551 std::cout << msg_length << " bytes..." << std::endl; 1552 1518 1553 if (MB_MESG_ENTS == mesg_tag) { 1519 int total_size;1520 UNPACK_INT(buff_ptr, total_size);1521 std::cout << total_size << " entities..." << std::endl;1522 1554 1523 1555 // 1. # entities = E … … 1533 1565 for (i = 0; i < num_ents; i++) { 1534 1566 UNPACK_INT(buff_ptr, j); 1567 if (0 > j) return MB_FAILURE; 1535 1568 ps.resize(j); 1536 1569 hs.resize(j); 1537 std::cout << "Entity " << i << " :# procs = " << j << std::endl;1570 std::cout << "Entity " << i << ", # procs = " << j << std::endl; 1538 1571 UNPACK_INTS(buff_ptr, &ps[0], j); 1539 1572 UNPACK_EH(buff_ptr, &hs[0], j); … … 1544 1577 for (k = 0; k < j; k++) std::cout << hs[k] << " "; 1545 1578 std::cout << std::endl; 1546 } 1547 1548 while (true) { 1549 MBEntityType this_type = MBMAXTYPE; 1550 UNPACK_TYPE(buff_ptr, this_type); 1551 assert(this_type != MBENTITYSET); 1579 1580 if (buff_ptr-orig_ptr > msg_length) { 1581 std::cout << "End of buffer..." << std::endl; 1582 return MB_FAILURE; 1583 } 1584 } 1585 1586 while (true) { 1587 MBEntityType this_type = MBMAXTYPE; 1588 UNPACK_TYPE(buff_ptr, this_type); 1589 assert(this_type != MBENTITYSET); 1552 1590 1553 1591 // MBMAXTYPE signifies end of entities data … … 1588 1626 std::cout << std::endl; 1589 1627 } 1628 1629 if (buff_ptr-orig_ptr > msg_length) { 1630 std::cout << "End of buffer..." << std::endl; 1631 return MB_FAILURE; 1632 } 1590 1633 } 1591 1634 } … … 1593 1636 1594 1637 else if (MB_MESG_REMOTE_HANDLES) { 1638 int num_bytes; 1639 UNPACK_INT(buff_ptr, num_bytes); 1640 std::cout << num_bytes << " bytes..." << std::endl; 1595 1641 int num_ents; 1596 1642 UNPACK_INT(buff_ptr, num_ents); … … 1607 1653 << L1p[i] << std::endl; 1608 1654 } 1655 1656 if (buff_ptr-orig_ptr > msg_length) { 1657 std::cout << "End of buffer..." << std::endl; 1658 return MB_FAILURE; 1659 } 1660 1609 1661 } 1610 1662 else if (MB_MESG_TAGS) { … … 1706 1758 RRA(""); 1707 1759 1760 #ifndef NDEBUG 1761 { 1762 // check for duplicates in proc list 1763 std::set<unsigned int> dumprocs; 1764 unsigned int dp = 0; 1765 for (; (int) dp < num_ps && -1 != ps[dp]; dp++) 1766 dumprocs.insert(ps[dp]); 1767 assert(dp == dumprocs.size()); 1768 } 1769 #endif 1770 1708 1771 // add any new sharing data 1709 1772 bool changed = false; … … 1812 1875 RRA("Couldn't set sharedhs tag."); 1813 1876 pstat |= (PSTATUS_MULTISHARED | PSTATUS_SHARED); 1877 1878 #ifndef NDEBUG 1879 { 1880 // check for duplicates in proc list 1881 std::set<unsigned int> dumprocs; 1882 unsigned int dp = 0; 1883 for (; dp < num_exist && -1 != tag_ps[dp]; dp++) 1884 dumprocs.insert(tag_ps[dp]); 1885 assert(dp == dumprocs.size()); 1886 } 1887 #endif 1814 1888 } 1815 1889 else if (num_exist == 2 || num_exist == 1) { 1816 1890 if (tag_ps[0] == (int) procConfig.proc_rank()) { 1817 assert(2 == num_exist );1891 assert(2 == num_exist && tag_ps[1] != (int) procConfig.proc_rank()); 1818 1892 tag_ps[0] = tag_ps[1]; 1819 1893 tag_hs[0] = tag_hs[1]; … … 2931 3005 MPE_Log_get_state_eventIDs( &SHAREDV_START, &SHAREDV_END); 2932 3006 MPE_Log_get_state_eventIDs( &RESOLVE_START, &RESOLVE_END); 3007 MPE_Log_get_state_eventIDs( &ENTITIES_START, &ENTITIES_END); 3008 MPE_Log_get_state_eventIDs( &RHANDLES_START, &RHANDLES_END); 2933 3009 success = MPE_Describe_state(IFACE_START, IFACE_END, "Resolve interface ents", "green"); 2934 3010 success = MPE_Describe_state(GHOST_START, GHOST_END, "Exchange ghost ents", "red"); 2935 3011 success = MPE_Describe_state(SHAREDV_START, SHAREDV_END, "Resolve interface vertices", "blue"); 2936 3012 success = MPE_Describe_state(RESOLVE_START, RESOLVE_END, "Resolve shared ents", "purple"); 3013 success = MPE_Describe_state(ENTITIES_START, ENTITIES_END, "Exchange shared ents", "yellow"); 3014 success = MPE_Describe_state(RHANDLES_START, RHANDLES_END, "Remote handles", "cyan"); 2937 3015 #endif 2938 3016 } … … 3709 3787 // post ghost irecv's for ghost entities from all communicating procs 3710 3788 //=========================================== 3789 #ifdef DEBUG_MPE 3790 MPE_Log_event(ENTITIES_START, procConfig.proc_rank(), "Starting entity exchange."); 3791 #endif 3711 3792 // index reqs the same as buffer/sharing procs indices 3712 3793 std::vector<MPI_Request> recv_reqs(buffProcs.size(), MPI_REQUEST_NULL); … … 3764 3845 sendReqs[ind], sendReqs[ind+buffProcs.size()]); 3765 3846 RRA("Failed to Isend in ghost exchange."); 3847 3848 // if (1 == num_layers) 3849 // print_buffer(&ownerSBuffs[ind][0], MB_MESG_ENTS, *proc_it, true); 3766 3850 } 3767 3851 … … 3795 3879 3796 3880 std::cerr << "Received from " << status[0].MPI_SOURCE 3797 << " :count = " << this_count << ", tag = " << status[0].MPI_TAG;3881 << ", count = " << this_count << ", tag = " << status[0].MPI_TAG; 3798 3882 if (MB_MESG_ENTS+1 == status[0].MPI_TAG) std::cerr << " (second)"; 3799 3883 std::cerr << std::endl; … … 3811 3895 3812 3896 if (done) { 3897 #ifdef DEBUG_MSGS 3898 print_buffer(&ghostRBuffs[ind][0], MB_MESG_ENTS, buffProcs[ind], false); 3899 #endif 3813 3900 unsigned char *buff_ptr = &ghostRBuffs[ind][sizeof(int)]; 3814 #ifdef DEBUG_MSGS3815 print_buffer(buff_ptr-sizeof(int), MB_MESG_ENTS, buffProcs[ind], false);3816 #endif3817 3901 result = unpack_entities(buff_ptr, 3818 3902 store_remote_handles, ind, is_iface, 3819 3903 L1hloc, L1hrem, L1p, L2hloc, L2hrem, L2p, new_ents); 3820 RRA("Failed to unpack entities."); 3904 if (MB_SUCCESS != result) { 3905 std::cout << "Failed to unpack entities. Buffer contents:" << std::endl; 3906 print_buffer(&ghostRBuffs[ind][0], MB_MESG_ENTS, buffProcs[ind], false); 3907 return result; 3908 } 3821 3909 3822 3910 if (recv_reqs.size() != buffProcs.size()) { … … 3835 3923 } 3836 3924 3925 #ifdef DEBUG_MPE 3926 MPE_Log_event(ENTITIES_END, procConfig.proc_rank(), "Ending entity exchange."); 3927 #endif 3928 3837 3929 if (is_iface) { 3838 3930 // need to check over entities I sent and make sure I received … … 3880 3972 // post recvs for remote handles of my sent ents 3881 3973 //=========================================== 3974 #ifdef DEBUG_MPE 3975 MPE_Log_event(RHANDLES_START, procConfig.proc_rank(), "Starting remote handles."); 3976 #endif 3882 3977 for (ind = 0, proc_it = buffProcs.begin(); 3883 3978 proc_it != buffProcs.end(); proc_it++, ind++) { … … 3942 4037 3943 4038 std::cerr << "Received from " << status[0].MPI_SOURCE 3944 << " :count = " << this_count << ", tag = " << status[0].MPI_TAG;4039 << ", count = " << this_count << ", tag = " << status[0].MPI_TAG; 3945 4040 if (MB_MESG_REMOTE_HANDLES_SECOND == status[0].MPI_TAG) 3946 4041 std::cerr << " (second)"; … … 3955 4050 if (done) { 3956 4051 // incoming remote handles 4052 #ifdef DEBUG_MSGS 4053 print_buffer(&ghostRBuffs[ind][0], MB_MESG_REMOTE_HANDLES, buffProcs[ind], false); 4054 #endif 3957 4055 buff_ptr = &ghostRBuffs[ind][sizeof(int)]; 3958 #ifdef DEBUG_MSGS3959 print_buffer(buff_ptr, MB_MESG_REMOTE_HANDLES, buffProcs[ind], false);3960 #endif3961 4056 result = unpack_remote_handles(buffProcs[ind], buff_ptr, 3962 4057 L2hloc, L2hrem, L2p); … … 3969 4064 } 3970 4065 4066 #ifdef DEBUG_MPE 4067 MPE_Log_event(RHANDLES_END, procConfig.proc_rank(), "Ending remote handles."); 4068 #endif 3971 4069 #ifdef DEBUG_MPE 3972 4070 MPE_Log_event(GHOST_END, procConfig.proc_rank(), … … 4418 4516 else hpair[0] = 0; 4419 4517 } 4420 assert(hpair[0] && hpair[1]);4518 if (!(hpair[0] && hpair[1])) return MB_FAILURE; 4421 4519 int this_proc = from_proc; 4422 4520 result = update_remote_data(hpair[0], &this_proc, hpair+1, 1, 0); … … 5710 5808 5711 5809 if (!bad_ents.empty()) { 5712 std::cout << "Found bad entities in check_local_shared:" << std::endl; 5810 std::cout << "Found bad entities in check_local_shared, proc rank " 5811 << procConfig.proc_rank() << "," << std::endl; 5713 5812 std::vector<std::string>::iterator vit; 5714 5813 for (rit = bad_ents.begin(), vit = errors.begin(); rit != bad_ents.end(); rit++, vit++) { -
MOAB/trunk/parallel/Makefile.am
r3256 r3296 47 47 crystal.h errmem.h types.h 48 48 49 MOAB_PARALLEL_TEST += pcomm_unit parallel_unit_tests uber_parallel_test scdtest 49 MOAB_PARALLEL_TEST += pcomm_unit parallel_unit_tests uber_parallel_test scdtest pcomm_serial 50 50 51 51 if PARALLEL_HDF5 … … 89 89 uber_parallel_test_SOURCES = uber_parallel_test.cpp 90 90 uber_parallel_test_LDADD = ../libMOAB.la 91 pcomm_serial_SOURCES = pcomm_serial.cpp 92 pcomm_serial_LDADD = ../libMOAB.la 91 93 92 94 scdtest_SOURCES = scdtest.cpp -
MOAB/trunk/parallel/pcomm_unit.cpp
r3255 r3296 49 49 /** Test pack/unpack of shared entities in 3d*/ 50 50 void test_pack_shared_entities_3d(); 51 /** Test pack/unpack of arbitrary mesh file */52 void test_pack_shared_arbitrary();53 51 /** Test filter_pstatus function*/ 54 52 void test_filter_pstatus(); … … 77 75 num_err += RUN_TEST( test_pack_shared_entities_2d ); 78 76 num_err += RUN_TEST( test_pack_shared_entities_3d ); 79 num_err += RUN_TEST( test_pack_shared_arbitrary );80 77 num_err += RUN_TEST( test_filter_pstatus ); 81 78 … … 1863 1860 1864 1861 for (unsigned int i = 0; i < 4; i++) 1865 delete pc[i];1866 }1867 1868 void test_pack_shared_arbitrary()1869 {1870 #define NP 31871 MBCore moab[NP];1872 MBParallelComm *pc[NP];1873 for (unsigned int i = 0; i < NP; i++) {1874 pc[i] = new MBParallelComm(&moab[i]);1875 pc[i]->set_rank(i);1876 pc[i]->set_size(NP);1877 }1878 1879 std::vector<int> pa_vec;1880 pa_vec.push_back(ReadParallel::PA_READ);1881 pa_vec.push_back(ReadParallel::PA_GET_FILESET_ENTS);1882 pa_vec.push_back(ReadParallel::PA_DELETE_NONLOCAL);1883 MBErrorCode rval;1884 std::vector<int> partition_tag_vals;1885 bool partition_distrib = false;1886 1887 #ifdef SRCDIR1888 const char *fnames[] = {STRINGIFY(SRCDIR) "/ptest.cub"};1889 #else1890 const char *fnames[] = {"./ptest.cub"};1891 #endif1892 1893 std::string ptag_name("GEOM_DIMENSION");1894 partition_tag_vals.push_back(3);1895 partition_distrib = true;1896 1897 //std::string ptag_name("MATERIAL_SET");1898 //partition_distrib = true;1899 1900 FileOptions fopts(NULL);1901 1902 for (unsigned int i = 0; i < NP; i++) {1903 ReadParallel rp(moab+i, pc[i]);1904 MBEntityHandle tmp_set = 0;1905 rval = rp.load_file(fnames, 1, tmp_set, ReadParallel::POPT_READ_DELETE,1906 ptag_name,1907 partition_tag_vals, partition_distrib, false, pa_vec,1908 fopts, NULL, 0, NULL, i, false, -1, -1, -1, -1, 0);1909 CHECK_ERR(rval);1910 }1911 1912 rval = MBParallelComm::resolve_shared_ents(pc, NP, 3);1913 CHECK_ERR(rval);1914 1915 // exchange interface cells1916 rval = MBParallelComm::exchange_ghost_cells(pc, NP, -1, -1, 0, true);1917 CHECK_ERR(rval);1918 1919 // now 1 layer of hex ghosts1920 rval = MBParallelComm::exchange_ghost_cells(pc, NP, 3, 0, 1, true);1921 CHECK_ERR(rval);1922 1923 for (unsigned int i = 0; i < NP; i++)1924 1862 delete pc[i]; 1925 1863 }
![(please configure the [header_logo] section in trac.ini)](/projects/ITAPS/chrome/common/trac_banner.png)