$extrastylesheet
#include <parallel.h>
Public Member Functions | |
| Request () | |
| Request (const request &r) | |
| Request (const Request &other) | |
| void | cleanup () |
| Request & | operator= (const Request &other) |
| Request & | operator= (const request &r) |
| ~Request () | |
| request * | get () |
| const request * | get () const |
| Status | wait () |
| bool | test () |
| bool | test (status &status) |
| void | add_prior_request (const Request &req) |
| void | add_post_wait_work (PostWaitWork *work) |
Private Attributes | |
| request | _request |
| UniquePtr< Request > | _prior_request |
| std::pair< std::vector < PostWaitWork * >, unsigned int > * | post_wait_work |
Encapsulates the MPI_Request
Definition at line 419 of file parallel.h.
| libMesh::Parallel::Request::Request | ( | ) | [inline] |
Definition at line 658 of file parallel_implementation.h.
Referenced by add_prior_request(), operator=(), and Request().
: #ifdef LIBMESH_HAVE_MPI _request(MPI_REQUEST_NULL), #else _request(), #endif post_wait_work(NULL) {}
| libMesh::Parallel::Request::Request | ( | const request & | r | ) | [inline] |
Definition at line 667 of file parallel_implementation.h.
: _request(r), post_wait_work(NULL) {}
| libMesh::Parallel::Request::Request | ( | const Request & | other | ) | [inline] |
Definition at line 672 of file parallel_implementation.h.
References _prior_request, post_wait_work, and Request().
: _request(other._request), post_wait_work(other.post_wait_work) { if (other._prior_request.get()) _prior_request = UniquePtr<Request> (new Request(*other._prior_request.get())); // operator= should behave like a shared pointer if (post_wait_work) post_wait_work->second++; }
| libMesh::Parallel::Request::~Request | ( | ) | [inline] |
Definition at line 733 of file parallel_implementation.h.
References cleanup().
{
this->cleanup();
}
| void libMesh::Parallel::Request::add_post_wait_work | ( | PostWaitWork * | work | ) | [inline] |
Definition at line 817 of file parallel_implementation.h.
References post_wait_work.
Referenced by libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), and libMesh::Parallel::Communicator::send_packed_range().
{
if (!post_wait_work)
post_wait_work = new
std::pair<std::vector <PostWaitWork* >, unsigned int>
(std::vector <PostWaitWork* >(), 1);
post_wait_work->first.push_back(work);
}
| void libMesh::Parallel::Request::add_prior_request | ( | const Request & | req | ) | [inline] |
Definition at line 803 of file parallel_implementation.h.
References _prior_request, libMesh::libmesh_assert(), and Request().
Referenced by libMesh::Parallel::Communicator::send_packed_range().
{
// We're making a chain of prior requests, not a tree
libmesh_assert(!req._prior_request.get());
Request *new_prior_req = new Request(req);
// new_prior_req takes ownership of our existing _prior_request
new_prior_req->_prior_request.reset(this->_prior_request.release());
// Our _prior_request now manages the new resource we just set up
this->_prior_request.reset(new_prior_req);
}
| void libMesh::Parallel::Request::cleanup | ( | ) | [inline] |
Definition at line 685 of file parallel_implementation.h.
References libMesh::libmesh_assert(), and post_wait_work.
Referenced by operator=(), and ~Request().
{
if (post_wait_work)
{
// Decrement the use count
post_wait_work->second--;
if (!post_wait_work->second)
{
#ifdef DEBUG
// If we're done using this request, then we'd better have
// done the work we waited for
for (std::vector<PostWaitWork*>::iterator i =
post_wait_work->first.begin();
i != post_wait_work->first.end(); ++i)
libmesh_assert(!(*i));
#endif
delete post_wait_work;
post_wait_work = NULL;
}
}
}
| request* libMesh::Parallel::Request::get | ( | ) | [inline] |
Definition at line 436 of file parallel.h.
References _request.
Referenced by libMesh::Parallel::Communicator::receive(), and libMesh::Parallel::Communicator::send().
{ return &_request; }
| const request* libMesh::Parallel::Request::get | ( | ) | const [inline] |
Definition at line 708 of file parallel_implementation.h.
References _prior_request, _request, cleanup(), post_wait_work, and Request().
{
this->cleanup();
_request = other._request;
post_wait_work = other.post_wait_work;
if (other._prior_request.get())
_prior_request = UniquePtr<Request>
(new Request(*other._prior_request.get()));
// operator= should behave like a shared pointer
if (post_wait_work)
post_wait_work->second++;
return *this;
}
Definition at line 725 of file parallel_implementation.h.
References _request, cleanup(), and post_wait_work.
{
this->cleanup();
_request = r;
post_wait_work = NULL;
return *this;
}
| bool libMesh::Parallel::Request::test | ( | ) | [inline] |
Definition at line 765 of file parallel_implementation.h.
References _request, and libMesh::libmesh_assert().
{
#ifdef LIBMESH_HAVE_MPI
int val=0;
MPI_Test (&_request,
&val,
MPI_STATUS_IGNORE);
if (val)
{
libmesh_assert (_request == MPI_REQUEST_NULL);
libmesh_assert_equal_to (val, 1);
}
return val;
#else
return true;
#endif
}
| bool libMesh::Parallel::Request::test | ( | status & | status | ) | [inline] |
Definition at line 786 of file parallel_implementation.h.
References _request.
{
int val=0;
MPI_Test (&_request,
&val,
&stat);
return val;
}
| Status libMesh::Parallel::Request::wait | ( | ) | [inline] |
Definition at line 737 of file parallel_implementation.h.
References _prior_request, _request, libMesh::Parallel::Status::get(), libMesh::libmesh_assert(), post_wait_work, and libMesh::START_LOG().
Referenced by libMesh::Parallel::Communicator::send_receive(), libMesh::Parallel::Communicator::send_receive_packed_range(), and libMesh::Parallel::wait().
{
START_LOG("wait()", "Parallel::Request");
if (_prior_request.get())
_prior_request->wait();
Status stat;
#ifdef LIBMESH_HAVE_MPI
MPI_Wait (&_request, stat.get());
#endif
if (post_wait_work)
for (std::vector<PostWaitWork*>::iterator i =
post_wait_work->first.begin();
i != post_wait_work->first.end(); ++i)
{
// The user should never try to give us NULL work or try
// to wait() twice.
libmesh_assert (*i);
(*i)->run();
delete (*i);
*i = NULL;
}
STOP_LOG("wait()", "Parallel::Request");
return stat;
}
UniquePtr<Request> libMesh::Parallel::Request::_prior_request [private] |
Definition at line 455 of file parallel.h.
Referenced by add_prior_request(), operator=(), Request(), and wait().
request libMesh::Parallel::Request::_request [private] |
Definition at line 451 of file parallel.h.
Referenced by get(), operator=(), test(), and wait().
std::pair<std::vector <PostWaitWork* >, unsigned int>* libMesh::Parallel::Request::post_wait_work [private] |
Definition at line 461 of file parallel.h.
Referenced by add_post_wait_work(), cleanup(), operator=(), Request(), and wait().