aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib
diff options
context:
space:
mode:
Diffstat (limited to 'Carpet/CarpetLib')
-rw-r--r--Carpet/CarpetLib/src/commstate.cc71
-rw-r--r--Carpet/CarpetLib/src/commstate.hh41
-rw-r--r--Carpet/CarpetLib/src/gdata.cc68
-rw-r--r--Carpet/CarpetLib/src/gdata.hh27
-rw-r--r--Carpet/CarpetLib/src/make.code.defn1
5 files changed, 115 insertions, 93 deletions
diff --git a/Carpet/CarpetLib/src/commstate.cc b/Carpet/CarpetLib/src/commstate.cc
new file mode 100644
index 000000000..8b81ce428
--- /dev/null
+++ b/Carpet/CarpetLib/src/commstate.cc
@@ -0,0 +1,71 @@
+#include "cctk.h"
+#include "cctk_Parameters.h"
+
+#include "commstate.hh"
+
+
+
+// Communication state control
+comm_state::comm_state ()
+ : thestate(state_recv)
+{
+}
+
+void comm_state::step ()
+{
+ DECLARE_CCTK_PARAMETERS;
+
+ assert (thestate!=state_done);
+ if (combine_recv_send) {
+ switch (thestate) {
+ case state_recv:
+ assert (tmps1.empty());
+ thestate = state_wait;
+ break;
+ case state_send:
+ assert (0);
+ case state_wait:
+ assert (tmps1.empty());
+ assert (tmps2.empty());
+ thestate = state_done;
+ break;
+ case state_done:
+ assert (0);
+ default:
+ assert (0);
+ }
+ } else {
+ switch (thestate) {
+ case state_recv:
+ assert (tmps2.empty());
+ thestate = state_send;
+ break;
+ case state_send:
+ assert (tmps1.empty());
+ thestate = state_wait;
+ break;
+ case state_wait:
+ assert (tmps1.empty());
+ assert (tmps2.empty());
+ thestate = state_done;
+ break;
+ case state_done:
+ assert (0);
+ default:
+ assert (0);
+ }
+ }
+}
+
+bool comm_state::done ()
+{
+ return thestate==state_done;
+}
+
+comm_state::~comm_state ()
+{
+ assert (thestate==state_recv || thestate==state_done);
+ assert (tmps1.empty());
+ assert (tmps2.empty());
+ assert (requests.empty());
+}
diff --git a/Carpet/CarpetLib/src/commstate.hh b/Carpet/CarpetLib/src/commstate.hh
new file mode 100644
index 000000000..340d09ded
--- /dev/null
+++ b/Carpet/CarpetLib/src/commstate.hh
@@ -0,0 +1,41 @@
+#ifndef COMMSTATE_HH
+#define COMMSTATE_HH
+
+#include <queue>
+#include <vector>
+
+#include <mpi.h>
+
+
+
+using namespace std;
+
+
+
+class gdata;
+
+
+
+// State information for communications
+enum astate { state_recv, state_send, state_wait, state_done };
+
+struct comm_state {
+ astate thestate;
+ comm_state ();
+ void step ();
+ bool done ();
+ ~comm_state ();
+
+private:
+ // Forbid copying and passing by value
+ comm_state (comm_state const &);
+ comm_state& operator= (comm_state const &);
+public:
+
+ queue<gdata*> tmps1, tmps2;
+ vector<MPI_Request> requests; // for use_waitall
+};
+
+
+
+#endif // COMMSTATE_HH
diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc
index 2a921807c..55f1ce197 100644
--- a/Carpet/CarpetLib/src/gdata.cc
+++ b/Carpet/CarpetLib/src/gdata.cc
@@ -9,6 +9,7 @@
#include "util_Table.h"
#include "bbox.hh"
+#include "commstate.hh"
#include "defs.hh"
#include "dist.hh"
#include "vect.hh"
@@ -19,73 +20,6 @@ using namespace std;
-// Communication state control
-comm_state::comm_state ()
- : thestate(state_recv)
-{
-}
-
-void comm_state::step ()
-{
- DECLARE_CCTK_PARAMETERS;
-
- assert (thestate!=state_done);
- if (combine_recv_send) {
- switch (thestate) {
- case state_recv:
- assert (tmps1.empty());
- thestate = state_wait;
- break;
- case state_send:
- assert (0);
- case state_wait:
- assert (tmps1.empty());
- assert (tmps2.empty());
- thestate = state_done;
- break;
- case state_done:
- assert (0);
- default:
- assert (0);
- }
- } else {
- switch (thestate) {
- case state_recv:
- assert (tmps2.empty());
- thestate = state_send;
- break;
- case state_send:
- assert (tmps1.empty());
- thestate = state_wait;
- break;
- case state_wait:
- assert (tmps1.empty());
- assert (tmps2.empty());
- thestate = state_done;
- break;
- case state_done:
- assert (0);
- default:
- assert (0);
- }
- }
-}
-
-bool comm_state::done ()
-{
- return thestate==state_done;
-}
-
-comm_state::~comm_state ()
-{
- assert (thestate==state_recv || thestate==state_done);
- assert (tmps1.empty());
- assert (tmps2.empty());
- assert (requests.empty());
-}
-
-
-
// Hand out the next MPI tag
static int nexttag ()
{
diff --git a/Carpet/CarpetLib/src/gdata.hh b/Carpet/CarpetLib/src/gdata.hh
index 37343b18b..72d136f5e 100644
--- a/Carpet/CarpetLib/src/gdata.hh
+++ b/Carpet/CarpetLib/src/gdata.hh
@@ -10,6 +10,7 @@
#include "cctk.h"
+#include "commstate.hh"
#include "defs.hh"
#include "dist.hh"
#include "bbox.hh"
@@ -21,32 +22,6 @@ using namespace std;
-class gdata;
-
-
-
-// State information for communications
-enum astate { state_recv, state_send, state_wait, state_done };
-
-struct comm_state {
- astate thestate;
- comm_state ();
- void step ();
- bool done ();
- ~comm_state ();
-
-private:
- // Forbid copying and passing by value
- comm_state (comm_state const &);
- comm_state& operator= (comm_state const &);
-public:
-
- queue<gdata*> tmps1, tmps2;
- vector<MPI_Request> requests; // for use_waitall
-};
-
-
-
// A generic data storage without type information
class gdata {
diff --git a/Carpet/CarpetLib/src/make.code.defn b/Carpet/CarpetLib/src/make.code.defn
index cc9ee9a22..6cb56e810 100644
--- a/Carpet/CarpetLib/src/make.code.defn
+++ b/Carpet/CarpetLib/src/make.code.defn
@@ -3,6 +3,7 @@
# Source files in this directory
SRCS = bbox.cc \
bboxset.cc \
+ commstate.cc \
data.cc \
defs.cc \
dh.cc \