aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src
diff options
context:
space:
mode:
authorschnetter <>2004-03-23 11:14:00 +0000
committerschnetter <>2004-03-23 11:14:00 +0000
commitb6ae9419e78279c0d766b3bb95cbc52e1456cdb9 (patch)
treec7fd0e1797e81d9fdc2471a60273fc7d89528d78 /Carpet/CarpetLib/src
parent2a6d3a5b99bf13d97bef1ff7b17facbd88fbb861 (diff)
Move MPI request and tag handling from data to gdata
darcs-hash:20040323111429-07bb3-08a8c6b8d729eb0efc5b757b61401b14712d790c.gz
Diffstat (limited to 'Carpet/CarpetLib/src')
-rw-r--r--Carpet/CarpetLib/src/data.cc39
-rw-r--r--Carpet/CarpetLib/src/data.hh7
-rw-r--r--Carpet/CarpetLib/src/gdata.cc17
-rw-r--r--Carpet/CarpetLib/src/gdata.hh7
4 files changed, 34 insertions, 36 deletions
diff --git a/Carpet/CarpetLib/src/data.cc b/Carpet/CarpetLib/src/data.cc
index b4f4c20c5..4c30b44cf 100644
--- a/Carpet/CarpetLib/src/data.cc
+++ b/Carpet/CarpetLib/src/data.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.cc,v 1.45 2004/03/03 15:30:40 hawke Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.cc,v 1.46 2004/03/23 12:14:29 schnetter Exp $
#include <assert.h>
#include <limits.h>
@@ -26,33 +26,18 @@ using namespace std;
-// Hand out the next MPI tag
-static int nexttag ()
-{
- static int last = 100;
- ++last;
- if (last > 30000) last = 100;
- return last;
-}
-
-
-
// Constructors
template<class T, int D>
data<T,D>::data (const int varindex_, const operator_type transport_operator_)
: gdata<D>(varindex_, transport_operator_),
- _storage(0),
- comm_active(false),
- tag(nexttag())
+ _storage(0)
{ }
template<class T, int D>
data<T,D>::data (const int varindex_, const operator_type transport_operator_,
const ibbox& extent_, const int proc_)
: gdata<D>(varindex_, transport_operator_),
- _storage(0),
- comm_active(false),
- tag(nexttag())
+ _storage(0)
{
allocate(extent_, proc_);
}
@@ -146,8 +131,8 @@ void data<T,D>::change_processor (comm_state<D>& state,
template<class T, int D>
void data<T,D>::change_processor_recv (const int newproc, void* const mem)
{
- assert (!comm_active);
- comm_active = true;
+ assert (!this->comm_active);
+ this->comm_active = true;
if (newproc == this->_proc) {
assert (!mem);
@@ -171,7 +156,7 @@ void data<T,D>::change_processor_recv (const int newproc, void* const mem)
const double wtime1 = MPI_Wtime();
T dummy;
MPI_Irecv (_storage, this->_size, dist::datatype(dummy), this->_proc,
- this->tag, dist::comm, &request);
+ this->tag, dist::comm, &this->request);
const double wtime2 = MPI_Wtime();
this->wtime_irecv += wtime2 - wtime1;
@@ -190,7 +175,7 @@ void data<T,D>::change_processor_recv (const int newproc, void* const mem)
template<class T, int D>
void data<T,D>::change_processor_send (const int newproc, void* const mem)
{
- assert (comm_active);
+ assert (this->comm_active);
if (newproc == this->_proc) {
assert (!mem);
@@ -212,7 +197,7 @@ void data<T,D>::change_processor_send (const int newproc, void* const mem)
const double wtime1 = MPI_Wtime();
T dummy;
MPI_Isend (_storage, this->_size, dist::datatype(dummy), newproc,
- this->tag, dist::comm, &request);
+ this->tag, dist::comm, &this->request);
const double wtime2 = MPI_Wtime();
this->wtime_isend += wtime2 - wtime1;
@@ -228,8 +213,8 @@ void data<T,D>::change_processor_send (const int newproc, void* const mem)
template<class T, int D>
void data<T,D>::change_processor_wait (const int newproc, void* const mem)
{
- assert (comm_active);
- comm_active = false;
+ assert (this->comm_active);
+ this->comm_active = false;
if (newproc == this->_proc) {
assert (!mem);
@@ -244,7 +229,7 @@ void data<T,D>::change_processor_wait (const int newproc, void* const mem)
const double wtime1 = MPI_Wtime();
MPI_Status status;
- MPI_Wait (&request, &status);
+ MPI_Wait (&this->request, &status);
const double wtime2 = MPI_Wtime();
this->wtime_irecvwait += wtime2 - wtime1;
@@ -256,7 +241,7 @@ void data<T,D>::change_processor_wait (const int newproc, void* const mem)
const double wtime1 = MPI_Wtime();
MPI_Status status;
- MPI_Wait (&request, &status);
+ MPI_Wait (&this->request, &status);
const double wtime2 = MPI_Wtime();
this->wtime_isendwait += wtime2 - wtime1;
diff --git a/Carpet/CarpetLib/src/data.hh b/Carpet/CarpetLib/src/data.hh
index 016dfcd1e..a6658e23e 100644
--- a/Carpet/CarpetLib/src/data.hh
+++ b/Carpet/CarpetLib/src/data.hh
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.hh,v 1.16 2004/01/25 14:57:29 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.hh,v 1.17 2004/03/23 12:14:29 schnetter Exp $
#ifndef DATA_HH
#define DATA_HH
@@ -31,11 +31,6 @@ class data: public gdata<D> {
// Fields
T* _storage; // the data (if located on this processor)
- bool comm_active;
- MPI_Request request;
-
- int tag; // MPI tag for this object
-
public:
// Constructors
diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc
index 948047e5d..97f39972c 100644
--- a/Carpet/CarpetLib/src/gdata.cc
+++ b/Carpet/CarpetLib/src/gdata.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.26 2004/01/25 14:57:30 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.27 2004/03/23 12:14:29 schnetter Exp $
#include <assert.h>
#include <stdlib.h>
@@ -52,13 +52,26 @@ comm_state<D>::~comm_state ()
+// Hand out the next MPI tag
+static int nexttag ()
+{
+ static int last = 100;
+ ++last;
+ if (last > 30000) last = 100;
+ return last;
+}
+
+
+
// Constructors
template<int D>
gdata<D>::gdata (const int varindex_, const operator_type transport_operator_)
: varindex(varindex_), transport_operator(transport_operator_),
wtime_isend(0.0), wtime_isendwait(0.0),
wtime_irecv(0.0), wtime_irecvwait(0.0),
- _has_storage(false)
+ _has_storage(false),
+ comm_active(false),
+ tag(nexttag())
{ }
// Destructors
diff --git a/Carpet/CarpetLib/src/gdata.hh b/Carpet/CarpetLib/src/gdata.hh
index 7484d75da..cda8091cc 100644
--- a/Carpet/CarpetLib/src/gdata.hh
+++ b/Carpet/CarpetLib/src/gdata.hh
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.hh,v 1.22 2004/01/25 14:57:30 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.hh,v 1.23 2004/03/23 12:14:29 schnetter Exp $
#ifndef GDATA_HH
#define GDATA_HH
@@ -74,6 +74,11 @@ protected: // should be readonly
ibbox _extent; // bbox for all data
+ bool comm_active;
+ MPI_Request request;
+
+ int tag; // MPI tag for this object
+
public:
// Constructors