[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Freepooma-devel] [RFC] Change domain object default constructorbeha
From: |
Richard Guenther |
Subject: |
Re: [Freepooma-devel] [RFC] Change domain object default constructorbehavior |
Date: |
Wed, 06 Apr 2005 20:14:59 +0200 |
User-agent: |
Debian Thunderbird 1.0.2 (X11/20050401) |
ron hylton wrote:
> Richard, I'm not quite sure what the real goal is (I've never looked at
> UninitializedVector) so this may not work or might be considered lying
> to the compiler, but perhaps it will at least generate some other ideas.
>
> template <class X>
> struct XNoInit : public X
> {
> XNoInit() : X(NoInit()) {}
> };
>
> template <class Bar, int Dim>
> struct FooNoInit
> {
> XNoInit<Bar> x[Dim];
> };
>
> If the choice of initialization strategy needs to be controlled at
> compile time you could use a Loki-type Select to choose an appropriate
> type for x.
Indeed - it looks hackish, but it does work :) With the simple attached
patch, performance of ScalarCode using code that uses Loc for indexing
improves by 13%! I'll try to extend this to all domain objects.
Thanks for the suggestion,
Richard.
? DomainIterator.h.optimized
? LINUXgcc
? Loc.h.opt
? tests/LINUXgcc
? tests/loc.cpp
? tests/loc.cpp.t70.optimized
? tests/loc.s
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 6 Apr 2005 18:10:41 -0000
@@ -81,7 +81,7 @@
* The specialization of DomainTraits for Loc, for dimensions greater than
* one.
*/
-
+struct Loc1NoInit;
template<int Dim>
struct DomainTraits< Loc<Dim> >
: public DomainTraitsDomain<Loc<Dim>, int, Dim>
@@ -101,7 +101,8 @@
typedef Loc<Dim> MultResult_t;
// type for storage of this domain's data
- typedef UninitializedVector<OneDomain_t,Dim,Element_t> Storage_t;
+ //typedef UninitializedVector<OneDomain_t,Dim,Element_t> Storage_t;
+ typedef Loc1NoInit Storage_t[Dim];
// necessary static data
enum { domain = Base_t::domain };
@@ -135,7 +136,10 @@
}
// Domains get the chance to do special initialization.
- static void initializeStorage(Storage_t &dom) { dom.initialize(); }
+ //static void initializeStorage(Storage_t &dom) { dom.initialize(); }
+ static void initializeStorage(Storage_t &dom) {
+ InitializeUninitializedVector<OneDomain_t, Dim-1>::initialize(&dom[0]);
+ }
// addAccum means dom += newdom
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 6 Apr 2005 18:10:41 -0000
@@ -657,6 +657,10 @@
o << "]";
}
+struct Loc1NoInit : public Loc<1>
+{
+ Loc1NoInit() : Loc<1>(Pooma::NoInit()) {}
+};
/// print a Loc to a stream, in the format
/// "[" first, first, ... first "]"