2005Apr07 Richard Guenther
* src/Domain/Domain.h (Domain<1>): Do not provide empty
destructor definition.
* src/Domain/DomainBase.h (DomainBase): Likewise. Remove
useless casting from const unwrap(). Provide access to
domain storage.
* src/Domain/Grid.h (Grid): Remove storage accessor; no
longer destroy sub-domains manually.
* src/Domain/DomainTraits.Grid.h: Use OneDomain_t[Dim] as
storage.
* src/Domain/DomainTraits.Interval.h: Likewise.
* src/Domain/DomainTraits.Loc.h: Likewise.
* src/Domain/DomainTraits.Range.h: Likewise.
* src/Domain/DomainTraits.Region.h: Likewise.
* src/Domain/DomainTraits.h (Dom1Initialize): Provide
template metaprogram for initializing multi-dimensional
domains with their one-dimensional counterpart array as storage.
(WrapNoInit): Provide wrapper class to turn default
initialization to initialization with Pooma::NoInit().
* src/Domain/Interval.h (Interval<1>): Do not provide
empty destructor definition.
(Interval<1>::operator[]): Provide shortcut without going
through Domain::operator[] and DomainTraits::unwrap().
* src/Domain/Loc.h: Likewise.
* src/Domain/Range.h: Likewise.
* src/Domain/Region.h: Likewise.
Index: Domain.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/Domain.h,v
retrieving revision 1.36
diff -u -r1.36 Domain.h
--- Domain.h 7 Apr 2005 10:09:16 -0000 1.36
+++ Domain.h 7 Apr 2005 12:56:57 -0000
@@ -444,8 +444,8 @@
// Destructor. Here, nothing to do.
//
- inline
- ~Domain() { }
+ //inline
+ //~Domain() { }
//
// Domain accessors.
Index: DomainBase.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/DomainBase.h,v
retrieving revision 1.36
diff -u -r1.36 DomainBase.h
--- DomainBase.h 7 Apr 2005 10:09:16 -0000 1.36
+++ DomainBase.h 7 Apr 2005 12:56:57 -0000
@@ -169,8 +169,8 @@
// Destructor. Here, nothing to do
//
- inline
- ~DomainBase() { }
+ //inline
+ //~DomainBase() { }
//
// DomainBase accessors.
@@ -182,7 +182,7 @@
// a const version of unwrap
const Domain_t &unwrap() const {
- return *static_cast(const_cast *>(this));
+ return *static_cast(this);
}
// return the first elements of the domain in another domain object
@@ -257,6 +257,12 @@
return retval;
}
+ // return the domain storage object
+ Storage_t& storage() { return domain_m; }
+
+ // return the domain storage object
+ const Storage_t& storage() const { return domain_m; }
+
//
// Negation operator
//
Index: DomainTraits.Grid.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/DomainTraits.Grid.h,v
retrieving revision 1.14
diff -u -r1.14 DomainTraits.Grid.h
--- DomainTraits.Grid.h 1 Nov 2004 18:16:32 -0000 1.14
+++ DomainTraits.Grid.h 7 Apr 2005 12:56:57 -0000
@@ -68,7 +68,6 @@
#include "Domain/DomainTraits.h"
#include "Domain/IndirectionList.h"
-#include "Utilities/UninitializedVector.h"
@@ -110,8 +109,7 @@
typedef Grid MultResult_t;
// type for storage of this domain's data
- typedef void * ElemPtr_t;
- typedef UninitializedVector Storage_t;
+ typedef OneDomain_t Storage_t[Dim];
// necessary static data
enum { domain = Base_t::domain };
@@ -137,8 +135,8 @@
return getDomain(d, n);
}
- // Domains get the chance to do special initialization.
- static void initializeStorage(Storage_t &dom) { dom.initialize(); }
+ // Grid is always initialized to an empty domain.
+ static void initializeStorage(Storage_t &dom) { }
};
Index: DomainTraits.Interval.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/DomainTraits.Interval.h,v
retrieving revision 1.30
diff -u -r1.30 DomainTraits.Interval.h
--- DomainTraits.Interval.h 1 Nov 2004 18:16:32 -0000 1.30
+++ DomainTraits.Interval.h 7 Apr 2005 12:56:57 -0000
@@ -63,7 +63,6 @@
//-----------------------------------------------------------------------------
#include "Domain/DomainTraits.h"
-#include "Utilities/UninitializedVector.h"
#include "Utilities/PAssert.h"
//-----------------------------------------------------------------------------
@@ -103,7 +102,7 @@
typedef Range MultResult_t;
// type for storage of this domain's data
- typedef UninitializedVector Storage_t;
+ typedef WrapNoInit Storage_t[Dim];
// necessary static data
enum { domain = Base_t::domain };
@@ -135,7 +134,9 @@
// Domains get the chance to do special initialization.
inline
- static void initializeStorage(Storage_t &dom) { dom.initialize(); }
+ static void initializeStorage(Storage_t &dom) {
+ Dom1Initialize::template apply > >(dom);
+ }
};
Index: DomainTraits.Loc.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/DomainTraits.Loc.h,v
retrieving revision 1.34
diff -u -r1.34 DomainTraits.Loc.h
--- DomainTraits.Loc.h 1 Nov 2004 18:16:32 -0000 1.34
+++ DomainTraits.Loc.h 7 Apr 2005 12:56:57 -0000
@@ -63,7 +63,6 @@
//-----------------------------------------------------------------------------
#include "Domain/DomainTraits.h"
-#include "Utilities/UninitializedVector.h"
//-----------------------------------------------------------------------------
@@ -101,7 +100,7 @@
typedef Loc MultResult_t;
// type for storage of this domain's data
- typedef UninitializedVector Storage_t;
+ typedef WrapNoInit Storage_t[Dim];
// necessary static data
enum { domain = Base_t::domain };
@@ -135,8 +134,9 @@
}
// Domains get the chance to do special initialization.
- static void initializeStorage(Storage_t &dom) { dom.initialize(); }
-
+ static void initializeStorage(Storage_t &dom) {
+ Dom1Initialize::template apply > >(dom);
+ }
// addAccum means dom += newdom
template
Index: DomainTraits.Range.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/DomainTraits.Range.h,v
retrieving revision 1.27
diff -u -r1.27 DomainTraits.Range.h
--- DomainTraits.Range.h 1 Nov 2004 18:16:32 -0000 1.27
+++ DomainTraits.Range.h 7 Apr 2005 12:56:57 -0000
@@ -62,7 +62,6 @@
//-----------------------------------------------------------------------------
#include "Domain/DomainTraits.h"
-#include "Utilities/UninitializedVector.h"
//-----------------------------------------------------------------------------
@@ -102,7 +101,7 @@
typedef Range MultResult_t;
// type for storage of this domain's data
- typedef UninitializedVector Storage_t;
+ typedef WrapNoInit Storage_t[Dim];
// necessary static data
enum { domain = Base_t::domain };
@@ -129,7 +128,9 @@
}
// Domains get the chance to do special initialization.
- static void initializeStorage(Storage_t &dom) { dom.initialize(); }
+ static void initializeStorage(Storage_t &dom) {
+ Dom1Initialize::template apply > >(dom);
+ }
};
Index: DomainTraits.Region.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/DomainTraits.Region.h,v
retrieving revision 1.17
diff -u -r1.17 DomainTraits.Region.h
--- DomainTraits.Region.h 1 Nov 2004 18:16:32 -0000 1.17
+++ DomainTraits.Region.h 7 Apr 2005 12:56:57 -0000
@@ -65,7 +65,6 @@
//-----------------------------------------------------------------------------
#include "Domain/DomainTraits.h"
-#include "Utilities/UninitializedVector.h"
//-----------------------------------------------------------------------------
@@ -101,7 +100,7 @@
typedef Region MultResult_t;
// type for storage of this domain's data
- typedef UninitializedVector Storage_t;
+ typedef WrapNoInit Storage_t[Dim];
// necessary static data
enum { domain = Base_t::domain };
@@ -128,7 +127,9 @@
}
// Domains get the chance to do special initialization.
- static void initializeStorage(Storage_t &dom) { dom.initialize(); }
+ static void initializeStorage(Storage_t &dom) {
+ Dom1Initialize::template apply > >(dom);
+ }
};
Index: DomainTraits.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/DomainTraits.h,v
retrieving revision 1.25
diff -u -r1.25 DomainTraits.h
--- DomainTraits.h 1 Nov 2004 18:16:32 -0000 1.25
+++ DomainTraits.h 7 Apr 2005 12:56:57 -0000
@@ -229,12 +229,16 @@
//-----------------------------------------------------------------------------
#include "Pooma/Configuration.h"
+#include "Utilities/NoInit.h"
//-----------------------------------------------------------------------------
// Forward Declarations:
//-----------------------------------------------------------------------------
+template class DomainTraits;
+
+
// Helper struct to compute proper type for Size_t typedef in DomainTraits
template
@@ -256,6 +260,45 @@
};
+
+/**
+ * Template metaprogram for initializing the storage arrays
+ * of onedimensional domain objects.
+ */
+
+template
+struct Dom1Initialize {
+ template
+ static inline void apply(typename DT::Storage_t& s)
+ {
+ Dom1Initialize::template apply(s);
+ DomainTraits::initializeStorage(s[I].storage());
+ }
+};
+
+template <>
+struct Dom1Initialize<0> {
+ template
+ static inline void apply(typename DT::Storage_t& s)
+ {
+ DomainTraits::initializeStorage(s[0].storage());
+ }
+};
+
+
+/**
+ * WrapNoInit is a wrapper class around Domain that changes
+ * the default constructor behavior to not init the storage.
+ */
+
+template
+struct WrapNoInit : public Domain
+{
+ WrapNoInit() : Domain(Pooma::NoInit()) {}
+};
+
+
+
/**
* DomainTraitsDomain can act as a base class for the partially-
* specialized versions of DomainTraits for domain-like classes, that is,
Index: Grid.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/Grid.h,v
retrieving revision 1.21
diff -u -r1.21 Grid.h
--- Grid.h 15 Feb 2005 13:25:57 -0000 1.21
+++ Grid.h 7 Apr 2005 12:56:58 -0000
@@ -241,10 +241,7 @@
// Destructor. For this class there is nothing to do.
//
- ~Grid() {
- for (int i=0;ioperator[](i).~OneDomain_t();
- }
+ ~Grid() { }
//
// operator=, templated to allow assignment from other domain objects
@@ -427,13 +424,6 @@
}
//
- // A special function used to initialize one Grid from another. For
- // this, we need non-modifiable access to the storage.
- //
-
- const Storage_t &storage() const { return domain_m; }
-
- //
// I/O/
//
Index: Interval.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/Interval.h,v
retrieving revision 1.24
diff -u -r1.24 Interval.h
--- Interval.h 1 Nov 2004 18:16:32 -0000 1.24
+++ Interval.h 7 Apr 2005 12:56:58 -0000
@@ -374,7 +374,7 @@
// Destructor. For this class there is nothing to do.
//
- ~Interval() { }
+ //~Interval() { }
//
// operator=, templated to allow assignment from other domain objects
@@ -393,6 +393,13 @@
return NewDomain1 >::fill(*this, newdom);
}
+ // Some compilers do not like being confused by unwrapping
+ // OneDomain_t from Domain::operator[], so provide a shortcut
+ // here.
+
+ const OneDomain_t &operator[](int d) const { return *this; }
+ OneDomain_t &operator[](int d) { return *this; }
+
};
// initialize from a set of endpoints: sets interval to [m ..n]. Must
Index: Loc.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/Loc.h,v
retrieving revision 1.34
diff -u -r1.34 Loc.h
--- Loc.h 10 Feb 2005 16:02:06 -0000 1.34
+++ Loc.h 7 Apr 2005 12:56:58 -0000
@@ -620,8 +620,8 @@
// Destructor. For this class there is nothing to do.
//
- inline
- ~Loc() { }
+ //inline
+ //~Loc() { }
//
// operator=, templated to allow assignment from other domain objects
@@ -644,6 +644,13 @@
return *this;
}
+ // Some compilers do not like being confused by unwrapping
+ // OneDomain_t from Domain::operator[], so provide a shortcut
+ // here.
+
+ const OneDomain_t &operator[](int d) const { return *this; }
+ OneDomain_t &operator[](int d) { return *this; }
+
template
void print(Out &o) const;
};
Index: Range.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/Range.h,v
retrieving revision 1.24
diff -u -r1.24 Range.h
--- Range.h 1 Nov 2004 18:16:32 -0000 1.24
+++ Range.h 7 Apr 2005 12:56:58 -0000
@@ -404,7 +404,7 @@
// Destructor. For this class there is nothing to do.
//
- ~Range() { }
+ //~Range() { }
//
// operator=, templated to allow assignment from other domain objects
@@ -423,6 +423,13 @@
return NewDomain1 >::fill(*this, newdom);
}
+ // Some compilers do not like being confused by unwrapping
+ // OneDomain_t from Domain::operator[], so provide a shortcut
+ // here.
+
+ const OneDomain_t &operator[](int d) const { return *this; }
+ OneDomain_t &operator[](int d) { return *this; }
+
};
// initialize from a set of endpoints: sets range to [m ..n].
Index: Region.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/Region.h,v
retrieving revision 1.28
diff -u -r1.28 Region.h
--- Region.h 1 Nov 2004 18:16:32 -0000 1.28
+++ Region.h 7 Apr 2005 12:56:58 -0000
@@ -386,7 +386,7 @@
// Destructor. For this class there is nothing to do.
//
- ~Region() { }
+ //~Region() { }
//
// operator=, templated to allow assignment from other domain objects
@@ -405,6 +405,13 @@
return NewDomain1 >::fill(*this, newdom);
}
+ // Some compilers do not like being confused by unwrapping
+ // OneDomain_t from Domain::operator[], so provide a shortcut
+ // here.
+
+ const OneDomain_t &operator[](int d) const { return *this; }
+ OneDomain_t &operator[](int d) { return *this; }
+
};
@@ -494,7 +501,7 @@
// Destructor. For this class there is nothing to do.
//
- ~Region() { }
+ //~Region() { }
//
// operator=, templated to allow assignment from other domain objects