aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2007-02-04 17:58:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2007-02-04 17:58:00 +0000
commit8f28ee78d87631b019da15123d77a0513d436008 (patch)
treecdcf06a1b6c260f92a5d31e66cc8d3010c04bcfd
parentd1a89bfd53ceb0ca43721749e5f4da91080078aa (diff)
CarpetLib: Add _storage field to gdata class
Add a field "void * _storage" to the gdata class to speed up its storage() member function. darcs-hash:20070204175843-dae7b-644ade82e1432b82384baf64f55aeb2482032fdf.gz
-rw-r--r--Carpet/CarpetLib/src/data.cc6
-rw-r--r--Carpet/CarpetLib/src/data.hh14
-rw-r--r--Carpet/CarpetLib/src/gdata.cc3
-rw-r--r--Carpet/CarpetLib/src/gdata.hh17
4 files changed, 22 insertions, 18 deletions
diff --git a/Carpet/CarpetLib/src/data.cc b/Carpet/CarpetLib/src/data.cc
index bdcfcd43e..7f4396cd7 100644
--- a/Carpet/CarpetLib/src/data.cc
+++ b/Carpet/CarpetLib/src/data.cc
@@ -218,6 +218,7 @@ void data<T>::allocate (const ibbox& extent_,
assert (_memory);
}
_memory->register_client (vectorindex);
+ _storage = _memory->storage(vectorindex);
} else {
assert (not memptr);
}
@@ -232,6 +233,7 @@ void data<T>::free ()
if (not _memory->has_clients()) delete _memory;
_memory = NULL;
_has_storage = false;
+ _storage = NULL;
}
@@ -264,6 +266,7 @@ void data<T>::change_processor_recv (comm_state& state,
assert (not _memory);
_memory = new mem<T> (1, _size, (T*)memptr);
_memory->register_client (0);
+ _storage = _memory->storage (0);
static Timer timer ("irecv");
timer.start ();
@@ -399,7 +402,8 @@ void data<T>::change_processor_wait (comm_state& state,
_memory->unregister_client (0);
if (not _memory->has_clients()) delete _memory;
- _memory = 0;
+ _memory = NULL;;
+ _storage = NULL;
} else {
assert (not memptr);
diff --git a/Carpet/CarpetLib/src/data.hh b/Carpet/CarpetLib/src/data.hh
index 415345c06..c0f2a68fc 100644
--- a/Carpet/CarpetLib/src/data.hh
+++ b/Carpet/CarpetLib/src/data.hh
@@ -82,20 +82,6 @@ private:
const int newproc,
void* const memptr = NULL);
public:
-
- // Accessors
- virtual const void* storage () const
- {
- assert (_has_storage);
- if (! _memory) return 0;
- return _memory->storage(vectorindex);
- }
-
- virtual void* storage () {
- assert (_has_storage);
- if (! _memory) return 0;
- return _memory->storage(vectorindex);
- }
// Data accessors
const T& operator[] (const ivect& index) const
diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc
index b07422a91..8d3de7dab 100644
--- a/Carpet/CarpetLib/src/gdata.cc
+++ b/Carpet/CarpetLib/src/gdata.cc
@@ -43,7 +43,8 @@ gdata::gdata (const int varindex_,
const centering cent_,
const operator_type transport_operator_,
const int tag_)
- : varindex(varindex_),
+ : _storage(NULL),
+ varindex(varindex_),
cent(cent_),
transport_operator(transport_operator_),
_has_storage(false),
diff --git a/Carpet/CarpetLib/src/gdata.hh b/Carpet/CarpetLib/src/gdata.hh
index b97a3e010..106c6ae45 100644
--- a/Carpet/CarpetLib/src/gdata.hh
+++ b/Carpet/CarpetLib/src/gdata.hh
@@ -28,6 +28,8 @@ class gdata {
protected: // should be readonly
// Fields
+ void * _storage; // A copy of the storage pointer
+
const int varindex; // Cactus variable index, or -1
centering cent;
@@ -99,9 +101,20 @@ public:
return _has_storage;
}
- virtual const void* storage () const = 0;
+ void const *
+ storage ()
+ const
+ {
+ assert (_has_storage);
+ return _storage;
+ }
- virtual void* storage () = 0;
+ void *
+ storage ()
+ {
+ assert (_has_storage);
+ return _storage;
+ }
int size () const {
assert (_has_storage);