libMesh::Parallel::Request Class Reference

#include <parallel.h>

List of all members.

Public Member Functions

 Request ()
 Request (const request &r)
 Request (const Request &other)
void cleanup ()
Requestoperator= (const Request &other)
Requestoperator= (const request &r)
 ~Request ()
requestget ()
const requestget () const
Status wait ()
bool test ()
bool test (status &status)
void add_post_wait_work (PostWaitWork *work)

Private Attributes

request _request
std::pair< std::vector
< PostWaitWork * >, unsigned
int > * 
post_wait_work

Detailed Description

Encapsulates the MPI_Request

Definition at line 373 of file parallel.h.


Constructor & Destructor Documentation

libMesh::Parallel::Request::Request (  )  [inline]

Definition at line 605 of file parallel_implementation.h.

00605                          :
00606 #ifdef LIBMESH_HAVE_MPI
00607   _request(MPI_REQUEST_NULL),
00608 #else
00609   _request(),
00610 #endif
00611   post_wait_work(NULL)
00612 {}

libMesh::Parallel::Request::Request ( const request r  )  [inline]

Definition at line 614 of file parallel_implementation.h.

00614                                          :
00615   _request(r),
00616   post_wait_work(NULL)
00617 {}

libMesh::Parallel::Request::Request ( const Request other  )  [inline]

Definition at line 619 of file parallel_implementation.h.

References post_wait_work.

00619                                              :
00620   _request(other._request),
00621   post_wait_work(other.post_wait_work)
00622 {
00623   // operator= should behave like a shared pointer
00624   if (post_wait_work)
00625     post_wait_work->second++;
00626 }

libMesh::Parallel::Request::~Request (  )  [inline]

Definition at line 672 of file parallel_implementation.h.

References cleanup().

00672                           {
00673   this->cleanup();
00674 }


Member Function Documentation

void libMesh::Parallel::Request::add_post_wait_work ( PostWaitWork work  )  [inline]

Definition at line 739 of file parallel_implementation.h.

References post_wait_work.

Referenced by libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::receive_packed_range(), libMesh::Parallel::Communicator::send(), and libMesh::Parallel::Communicator::send_packed_range().

00740 {
00741   if (!post_wait_work)
00742     post_wait_work = new
00743       std::pair<std::vector <PostWaitWork* >, unsigned int>
00744         (std::vector <PostWaitWork* >(), 1);
00745   post_wait_work->first.push_back(work);
00746 }

void libMesh::Parallel::Request::cleanup (  )  [inline]

Definition at line 628 of file parallel_implementation.h.

References post_wait_work.

Referenced by operator=(), and ~Request().

00629 {
00630   if (post_wait_work)
00631     {
00632       // Decrement the use count
00633       post_wait_work->second--;
00634 
00635       if (!post_wait_work->second)
00636         {
00637 #ifdef DEBUG
00638           // If we're done using this request, then we'd better have
00639           // done the work we waited for
00640           for (std::vector<PostWaitWork*>::iterator i =
00641                    post_wait_work->first.begin();
00642                i != post_wait_work->first.end(); ++i)
00643                 libmesh_assert(!(*i));
00644 #endif
00645           delete post_wait_work;
00646           post_wait_work = NULL;
00647         }
00648     }
00649 }

const request* libMesh::Parallel::Request::get (  )  const [inline]

Definition at line 392 of file parallel.h.

References _request.

00392 { return &_request; }

request* libMesh::Parallel::Request::get (  )  [inline]

Definition at line 390 of file parallel.h.

References _request.

Referenced by libMesh::Parallel::Communicator::receive(), and libMesh::Parallel::Communicator::send().

00390 { return &_request; }

Request & libMesh::Parallel::Request::operator= ( const request r  )  [inline]

Definition at line 664 of file parallel_implementation.h.

References _request, cleanup(), and post_wait_work.

00665 {
00666   this->cleanup();
00667   _request = r;
00668   post_wait_work = NULL;
00669   return *this;
00670 }

Request & libMesh::Parallel::Request::operator= ( const Request other  )  [inline]

Definition at line 651 of file parallel_implementation.h.

References _request, cleanup(), and post_wait_work.

00652 {
00653   this->cleanup();
00654   _request = other._request;
00655   post_wait_work = other.post_wait_work;
00656 
00657   // operator= should behave like a shared pointer
00658   if (post_wait_work)
00659     post_wait_work->second++;
00660 
00661   return *this;
00662 }

bool libMesh::Parallel::Request::test ( status status  )  [inline]

Definition at line 722 of file parallel_implementation.h.

References _request.

00723 {
00724   int val=0;
00725 
00726   MPI_Test (&_request,
00727             &val,
00728             &stat);
00729 
00730   return val;
00731 }

bool libMesh::Parallel::Request::test (  )  [inline]

Definition at line 701 of file parallel_implementation.h.

References _request.

00702 {
00703 #ifdef LIBMESH_HAVE_MPI
00704   int val=0;
00705 
00706   MPI_Test (&_request,
00707                 &val,
00708                 MPI_STATUS_IGNORE);
00709   if (val)
00710         {
00711           libmesh_assert          (_request == MPI_REQUEST_NULL);
00712           libmesh_assert_equal_to (val, 1);
00713         }
00714 
00715   return val;
00716 #else
00717   return true;
00718 #endif
00719 }

Status libMesh::Parallel::Request::wait (  )  [inline]

Definition at line 676 of file parallel_implementation.h.

References _request, libMesh::Parallel::Status::get(), and post_wait_work.

Referenced by libMesh::Parallel::Communicator::send_receive(), libMesh::Parallel::Communicator::send_receive_packed_range(), and libMesh::Parallel::wait().

00677 {
00678   START_LOG("wait()", "Parallel::Request");
00679 
00680   Status stat;
00681 #ifdef LIBMESH_HAVE_MPI
00682   MPI_Wait (&_request, stat.get());
00683 #endif
00684   if (post_wait_work)
00685     for (std::vector<PostWaitWork*>::iterator i =
00686              post_wait_work->first.begin();
00687          i != post_wait_work->first.end(); ++i)
00688       {
00689         // The user should never try to give us NULL work or try
00690         // to wait() twice.
00691         libmesh_assert (*i);
00692             (*i)->run();
00693         delete (*i);
00694         *i = NULL;
00695       }
00696 
00697   STOP_LOG("wait()", "Parallel::Request");
00698   return stat;
00699 }


Member Data Documentation

Definition at line 403 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 409 of file parallel.h.

Referenced by add_post_wait_work(), cleanup(), operator=(), Request(), and wait().


The documentation for this class was generated from the following files:

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:44 UTC

Hosted By:
SourceForge.net Logo