c++ - What is the purpose of boost mpi request's m_handler -
i trying test mpi request if done or not. however, there problem not figure out. if use test_all method below, see request not done.
string msg; boost::mpi::request req = world->irecv(some_rank, 0, msg); vector<boost::mpi::request> waitingrequests; waitingrequests.push_back(req); if(boost::mpi::test_all(waitingrequests.begin(), waitingrequests.end())) cout << "test_all done" << endl;
when try code, see request done:
string msg; boost::mpi::request req = world->irecv(some_rank, 0, msg); if(req.test()) cout << "test done" << endl;
so, looked @ code in test_all function , realized returns false because of condition "first->m_handler" (line 5 in below code).
template<typename forwarditerator> bool test_all(forwarditerator first, forwarditerator last) { std::vector<mpi_request> requests; (; first != last; ++first) { // if have non-trivial request, no requests can completed. if (first->m_handler || first->m_requests[1] != mpi_request_null) return false; requests.push_back(first->m_requests[0]); } int flag = 0; int n = requests.size(); boost_mpi_check_result(mpi_testall, (n, &requests[0], &flag, mpi_statuses_ignore)); return flag != 0; }
now, wonder m_handler for.
mpi not support intrinsicly complex c++ objects such std::string
. that's why boost.mpi serialises , correspondingly deserialises such objects when passing them around in form of mpi messages. semantic point of view, non-blocking operation started irecv()
should complete once data has been received , std::string
object has been filled in appropriately. additional step of processing received message , deserialising performed special handler method, pointer stored in m_handler
variable:
... if (m_handler) { // request receive serialized type. use // handler test completion. return m_handler(this, ra_test); } else ...
no such handling needed simple datatypes.
the same applies isend()
when operates on c++ objects. in case handler not attached, class data sent in form of 2 separate messages , special care taken both sends complete. that's second boolean expression (m_requests[1] != mpi_request_null
) for.
Comments
Post a Comment