[pooma-dev] Explicit Instantiation Question

Dave Nystrom wdn at lanl.gov
Mon Sep 10 16:40:11 UTC 2001


Hi Jim and Scott,

Jim's idea works great.  I made the changes in NewField/Field.h and it
eliminated 3000+ templates that the Blanca source code was instantiating.
The changes only take about 5 minutes to make.  Could someone make them to
the repository version of Pooma 2 that Blanca is using?

Thanks to Jim for taking the time to look at the code and figure this out.

Thanks,

Dave Nystrom			email: wdn at lanl.gov
LANL X-3			phone: 505-667-7913	fax: 505-665-3046

James Crotinger writes:
 > I've mentioned before that sv is probably not used anywhere and that it was
 > pretty clearly just added for clarity in the class definition. Is there any
 > reason not to remove it completely? That is, we currently have something
 > like (this is a bit old, but I don't think this stuff has changed):
 > 
 >   // Deduce appropriate version of implementation to dispatch to.
 >   
 >   static const bool sv = DomainTraits<SDomain_t>::singleValued;
 >   typedef View1Implementation<Subject_t, SDomain_t, sv> Dispatch_t;
 > 
 >   // The optimized domain combiner.
 >   
 >   typedef CombineDomainOpt<NewDomain_t, sv> Combine_t;
 > 
 > 
 > This can be changed to the more unwieldly
 > 
 >   // Deduce appropriate version of implementation to dispatch to.
 >   
 >   typedef View1Implementation<Subject_t, SDomain_t,
 > DomainTraits<SDomain_t>::singleValued> Dispatch_t;
 > 
 >   // The optimized domain combiner.
 >   
 >   typedef CombineDomainOpt<NewDomain_t,
 > DomainTraits<SDomain_t>::singleValued> Combine_t;  
 > 
 > Then "sv" won't have to be instantiated at all since it won't exist anymore.
 > sv is public, but I think that was an oversight - I don't think anyone ever
 > uses View1<blah>::sv. 
 > 
 >   Jim
 > 
 > 
 > > -----Original Message-----
 > > From: Dave Nystrom [mailto:wdn at lanl.gov]
 > > Sent: Thursday, September 06, 2001 2:08 PM
 > > To: pooma-dev
 > > Subject: [pooma-dev] Explicit Instantiation Question
 > > 
 > > 
 > > Here is another try at sending my email.  I am trying again 
 > > to speed up our
 > > compiles because it has been taking way too long on b18, the 
 > > SGI machine we
 > > are doing our classified development on.  John and I have 
 > > made some good
 > > progress on that by getting shared libraries working on b18 
 > > and explicitly
 > > instantiating all the Pooma2 assign functions in a special 
 > > library package
 > > that only needs to be rebuilt when we change Pooma 2.
 > > 
 > > In the process of doing that, I have revisited the idea of trying to
 > > explicitly instantiate the Pooma 2 View1 and AltView1 templates.  When
 > > Jeffrey was looking at the original problem there with View1 
 > > which had a
 > > circular dependency which was causing a 
 > > point-of-instantiation problem, he
 > > discovered that he could explicitly instantiate the View1 
 > > template with
 > > fairly simple template arguments by first explicitly 
 > > instantiating the Field
 > > class with those same template arguments.  Then he figured out how to
 > > explicitly instantiate the View1 class by adding the AltView1 class.
 > > However, that does not help me because now I have 2000-3000 AltView1
 > > templates that I need to instantiate.
 > > 
 > > So, I tried using Jeffreys original solution which I modified 
 > > to use with the
 > > AltView1 template - see the cpp macro 
 > > INSTANTIATE_VIEW1_AND_FRIENDS below.
 > > But, the simple View1.cc file below fails to compile when 
 > > using KCC 4.0f on
 > > Red Hat 7.1 Linux.  So, I'm wondering if I am doing the right 
 > > thing in my cpp
 > > macro - KCC seems to think not.  Also, I'm wondering if I 
 > > need to explicitly
 > > instantiate the whole Field class or just 1 or 2 methods of 
 > > the Field class.
 > > I think that Jeffrey might be the best person to answer this question
 > > although others who are intimately familiar with Pooma 2 
 > > might be able to
 > > also.
 > > 
 > > Bottom line is that I am trying to figure out some way to explicitly
 > > instantiate the View1 and AltView1 templates without having 
 > > to remove the
 > > circular dependency which is causing the 
 > > point-of-instantiation problem.
 > > 
 > > Thanks for any help,
 > > 
 > > Dave Nystrom			email: wdn at lanl.gov
 > > LANL X-3			phone: 505-667-7913	fax: 
 > > 505-665-3046
 > > 
 > > ---------------------------------------Simple View1.cc 
 > > File-------------------------------------
 > > #include "Pooma/NewFields.h"
 > > 
 > > #define INSTANTIATE_VIEW1_AND_FRIENDS(T1_CPP,T2_CPP,T3_CPP) \
 > > template class          Field<T1_CPP,T2_CPP,T3_CPP>; \
 > > template       
 > > AltView1<Field<T1_CPP,T2_CPP,T3_CPP>,Interval<1> >::sv; \
 > > template       
 > > AltView1<Field<T1_CPP,T2_CPP,T3_CPP>,Interval<2> >::sv; \
 > > template       AltView1<Field<T1_CPP,T2_CPP,T3_CPP>,Interval<3> >::sv;
 > > 
 > > #define T1 UniformRectilinear<(int)2, double, Cartesian<(int)2> >
 > > #define T2 Vector<(int)2, double, Full>
 > > #define T3 ExpressionTag<BinaryNode<OpAdd, 
 > > BinaryNode<OpSubtract, BinaryNode<OpMultiply, Scalar<double>, 
 > > BinaryNode<OpSubtract, BinaryNode<OpAdd, 
 > > Reference<Field<UniformRectilinear<(int)2, double, 
 > > Cartesian<(int)2> >, Vector<(int)2, double, Full>, 
 > > CompressibleBrickView> >, 
 > > Reference<Field<UniformRectilinear<(int)2, double, 
 > > Cartesian<(int)2> >, Vector<(int)2, double, Full>, 
 > > CompressibleBrickView> > >, BinaryNode<OpMultiply, 
 > > Scalar<int>, Reference<Field<UniformRectilinear<(int)2, 
 > > double, Cartesian<(int)2> >, Vector<(int)2, double, Full>, 
 > > CompressibleBrickView> > > > >, BinaryNode<OpMultiply, 
 > > BinaryNode<OpMultiply, Scalar<double>, 
 > > Reference<Field<UniformRectilinear<(int)2, double, 
 > > Cartesian<(int)2> >, Vector<(int)2, double, Full>, 
 > > CompressibleBrickView> > >, BinaryNode<OpSubtract, 
 > > Reference<Field<UniformRectilinear<(int)2, double, 
 > > Cartesian<(int)2> >, Vector<(int)2, double, Full>, 
 > > CompressibleBrickView> >, 
 > > Reference<Field<UniformRectilinear<(int)2, double, 
 > > Cartesian<(int)2> >, !
 > > Vector<(int)2, double, Full>, CompressibleBrickView> > > > >, 
 > > Reference<Field<UniformRectilinear<(int)2, double, 
 > > Cartesian<(int)2> >, Vector<(int)2, double, Full>, 
 > > CompressibleBrickView> > > >
 > > INSTANTIATE_VIEW1_AND_FRIENDS(T1,T2,T3)
 > > #undef T1
 > > #undef T2
 > > #undef T3
 > > 
 > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
 > <HTML>
 > <HEAD>
 > <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
 > <META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2650.12">
 > <TITLE>RE: [pooma-dev] Explicit Instantiation Question</TITLE>
 > </HEAD>
 > <BODY>
 > 
 > <P><FONT SIZE=2>I've mentioned before that sv is probably not used anywhere and that it was pretty clearly just added for clarity in the class definition. Is there any reason not to remove it completely? That is, we currently have something like (this is a bit old, but I don't think this stuff has changed):</FONT></P>
 > 
 > <P><FONT SIZE=2>  // Deduce appropriate version of implementation to dispatch to.</FONT>
 > <BR><FONT SIZE=2>  </FONT>
 > <BR><FONT SIZE=2>  static const bool sv = DomainTraits<SDomain_t>::singleValued;</FONT>
 > <BR><FONT SIZE=2>  typedef View1Implementation<Subject_t, SDomain_t, sv> Dispatch_t;</FONT>
 > </P>
 > 
 > <P><FONT SIZE=2>  // The optimized domain combiner.</FONT>
 > <BR><FONT SIZE=2>  </FONT>
 > <BR><FONT SIZE=2>  typedef CombineDomainOpt<NewDomain_t, sv> Combine_t;</FONT>
 > </P>
 > <BR>
 > 
 > <P><FONT SIZE=2>This can be changed to the more unwieldly</FONT>
 > </P>
 > 
 > <P><FONT SIZE=2>  // Deduce appropriate version of implementation to dispatch to.</FONT>
 > <BR><FONT SIZE=2>  </FONT>
 > <BR><FONT SIZE=2>  typedef View1Implementation<Subject_t, SDomain_t, DomainTraits<SDomain_t>::singleValued> Dispatch_t;</FONT>
 > </P>
 > 
 > <P><FONT SIZE=2>  // The optimized domain combiner.</FONT>
 > <BR><FONT SIZE=2>  </FONT>
 > <BR><FONT SIZE=2>  typedef CombineDomainOpt<NewDomain_t, DomainTraits<SDomain_t>::singleValued> Combine_t;  </FONT>
 > </P>
 > 
 > <P><FONT SIZE=2>Then "sv" won't have to be instantiated at all since it won't exist anymore. sv is public, but I think that was an oversight - I don't think anyone ever uses View1<blah>::sv. </FONT></P>
 > 
 > <P><FONT SIZE=2>  Jim</FONT>
 > </P>
 > <BR>
 > 
 > <P><FONT SIZE=2>> -----Original Message-----</FONT>
 > <BR><FONT SIZE=2>> From: Dave Nystrom [<A HREF="mailto:wdn at lanl.gov">mailto:wdn at lanl.gov</A>]</FONT>
 > <BR><FONT SIZE=2>> Sent: Thursday, September 06, 2001 2:08 PM</FONT>
 > <BR><FONT SIZE=2>> To: pooma-dev</FONT>
 > <BR><FONT SIZE=2>> Subject: [pooma-dev] Explicit Instantiation Question</FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > <BR><FONT SIZE=2>> Here is another try at sending my email.  I am trying again </FONT>
 > <BR><FONT SIZE=2>> to speed up our</FONT>
 > <BR><FONT SIZE=2>> compiles because it has been taking way too long on b18, the </FONT>
 > <BR><FONT SIZE=2>> SGI machine we</FONT>
 > <BR><FONT SIZE=2>> are doing our classified development on.  John and I have </FONT>
 > <BR><FONT SIZE=2>> made some good</FONT>
 > <BR><FONT SIZE=2>> progress on that by getting shared libraries working on b18 </FONT>
 > <BR><FONT SIZE=2>> and explicitly</FONT>
 > <BR><FONT SIZE=2>> instantiating all the Pooma2 assign functions in a special </FONT>
 > <BR><FONT SIZE=2>> library package</FONT>
 > <BR><FONT SIZE=2>> that only needs to be rebuilt when we change Pooma 2.</FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > <BR><FONT SIZE=2>> In the process of doing that, I have revisited the idea of trying to</FONT>
 > <BR><FONT SIZE=2>> explicitly instantiate the Pooma 2 View1 and AltView1 templates.  When</FONT>
 > <BR><FONT SIZE=2>> Jeffrey was looking at the original problem there with View1 </FONT>
 > <BR><FONT SIZE=2>> which had a</FONT>
 > <BR><FONT SIZE=2>> circular dependency which was causing a </FONT>
 > <BR><FONT SIZE=2>> point-of-instantiation problem, he</FONT>
 > <BR><FONT SIZE=2>> discovered that he could explicitly instantiate the View1 </FONT>
 > <BR><FONT SIZE=2>> template with</FONT>
 > <BR><FONT SIZE=2>> fairly simple template arguments by first explicitly </FONT>
 > <BR><FONT SIZE=2>> instantiating the Field</FONT>
 > <BR><FONT SIZE=2>> class with those same template arguments.  Then he figured out how to</FONT>
 > <BR><FONT SIZE=2>> explicitly instantiate the View1 class by adding the AltView1 class.</FONT>
 > <BR><FONT SIZE=2>> However, that does not help me because now I have 2000-3000 AltView1</FONT>
 > <BR><FONT SIZE=2>> templates that I need to instantiate.</FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > <BR><FONT SIZE=2>> So, I tried using Jeffreys original solution which I modified </FONT>
 > <BR><FONT SIZE=2>> to use with the</FONT>
 > <BR><FONT SIZE=2>> AltView1 template - see the cpp macro </FONT>
 > <BR><FONT SIZE=2>> INSTANTIATE_VIEW1_AND_FRIENDS below.</FONT>
 > <BR><FONT SIZE=2>> But, the simple View1.cc file below fails to compile when </FONT>
 > <BR><FONT SIZE=2>> using KCC 4.0f on</FONT>
 > <BR><FONT SIZE=2>> Red Hat 7.1 Linux.  So, I'm wondering if I am doing the right </FONT>
 > <BR><FONT SIZE=2>> thing in my cpp</FONT>
 > <BR><FONT SIZE=2>> macro - KCC seems to think not.  Also, I'm wondering if I </FONT>
 > <BR><FONT SIZE=2>> need to explicitly</FONT>
 > <BR><FONT SIZE=2>> instantiate the whole Field class or just 1 or 2 methods of </FONT>
 > <BR><FONT SIZE=2>> the Field class.</FONT>
 > <BR><FONT SIZE=2>> I think that Jeffrey might be the best person to answer this question</FONT>
 > <BR><FONT SIZE=2>> although others who are intimately familiar with Pooma 2 </FONT>
 > <BR><FONT SIZE=2>> might be able to</FONT>
 > <BR><FONT SIZE=2>> also.</FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > <BR><FONT SIZE=2>> Bottom line is that I am trying to figure out some way to explicitly</FONT>
 > <BR><FONT SIZE=2>> instantiate the View1 and AltView1 templates without having </FONT>
 > <BR><FONT SIZE=2>> to remove the</FONT>
 > <BR><FONT SIZE=2>> circular dependency which is causing the </FONT>
 > <BR><FONT SIZE=2>> point-of-instantiation problem.</FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > <BR><FONT SIZE=2>> Thanks for any help,</FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > <BR><FONT SIZE=2>> Dave Nystrom                  email: wdn at lanl.gov</FONT>
 > <BR><FONT SIZE=2>> LANL X-3                      phone: 505-667-7913     fax: </FONT>
 > <BR><FONT SIZE=2>> 505-665-3046</FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > <BR><FONT SIZE=2>> ---------------------------------------Simple View1.cc </FONT>
 > <BR><FONT SIZE=2>> File-------------------------------------</FONT>
 > <BR><FONT SIZE=2>> #include "Pooma/NewFields.h"</FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > <BR><FONT SIZE=2>> #define INSTANTIATE_VIEW1_AND_FRIENDS(T1_CPP,T2_CPP,T3_CPP) \</FONT>
 > <BR><FONT SIZE=2>> template class          Field<T1_CPP,T2_CPP,T3_CPP>; \</FONT>
 > <BR><FONT SIZE=2>> template       </FONT>
 > <BR><FONT SIZE=2>> AltView1<Field<T1_CPP,T2_CPP,T3_CPP>,Interval<1> >::sv; \</FONT>
 > <BR><FONT SIZE=2>> template       </FONT>
 > <BR><FONT SIZE=2>> AltView1<Field<T1_CPP,T2_CPP,T3_CPP>,Interval<2> >::sv; \</FONT>
 > <BR><FONT SIZE=2>> template       AltView1<Field<T1_CPP,T2_CPP,T3_CPP>,Interval<3> >::sv;</FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > <BR><FONT SIZE=2>> #define T1 UniformRectilinear<(int)2, double, Cartesian<(int)2> ></FONT>
 > <BR><FONT SIZE=2>> #define T2 Vector<(int)2, double, Full></FONT>
 > <BR><FONT SIZE=2>> #define T3 ExpressionTag<BinaryNode<OpAdd, </FONT>
 > <BR><FONT SIZE=2>> BinaryNode<OpSubtract, BinaryNode<OpMultiply, Scalar<double>, </FONT>
 > <BR><FONT SIZE=2>> BinaryNode<OpSubtract, BinaryNode<OpAdd, </FONT>
 > <BR><FONT SIZE=2>> Reference<Field<UniformRectilinear<(int)2, double, </FONT>
 > <BR><FONT SIZE=2>> Cartesian<(int)2> >, Vector<(int)2, double, Full>, </FONT>
 > <BR><FONT SIZE=2>> CompressibleBrickView> >, </FONT>
 > <BR><FONT SIZE=2>> Reference<Field<UniformRectilinear<(int)2, double, </FONT>
 > <BR><FONT SIZE=2>> Cartesian<(int)2> >, Vector<(int)2, double, Full>, </FONT>
 > <BR><FONT SIZE=2>> CompressibleBrickView> > >, BinaryNode<OpMultiply, </FONT>
 > <BR><FONT SIZE=2>> Scalar<int>, Reference<Field<UniformRectilinear<(int)2, </FONT>
 > <BR><FONT SIZE=2>> double, Cartesian<(int)2> >, Vector<(int)2, double, Full>, </FONT>
 > <BR><FONT SIZE=2>> CompressibleBrickView> > > > >, BinaryNode<OpMultiply, </FONT>
 > <BR><FONT SIZE=2>> BinaryNode<OpMultiply, Scalar<double>, </FONT>
 > <BR><FONT SIZE=2>> Reference<Field<UniformRectilinear<(int)2, double, </FONT>
 > <BR><FONT SIZE=2>> Cartesian<(int)2> >, Vector<(int)2, double, Full>, </FONT>
 > <BR><FONT SIZE=2>> CompressibleBrickView> > >, BinaryNode<OpSubtract, </FONT>
 > <BR><FONT SIZE=2>> Reference<Field<UniformRectilinear<(int)2, double, </FONT>
 > <BR><FONT SIZE=2>> Cartesian<(int)2> >, Vector<(int)2, double, Full>, </FONT>
 > <BR><FONT SIZE=2>> CompressibleBrickView> >, </FONT>
 > <BR><FONT SIZE=2>> Reference<Field<UniformRectilinear<(int)2, double, </FONT>
 > <BR><FONT SIZE=2>> Cartesian<(int)2> >, !</FONT>
 > <BR><FONT SIZE=2>> Vector<(int)2, double, Full>, CompressibleBrickView> > > > >, </FONT>
 > <BR><FONT SIZE=2>> Reference<Field<UniformRectilinear<(int)2, double, </FONT>
 > <BR><FONT SIZE=2>> Cartesian<(int)2> >, Vector<(int)2, double, Full>, </FONT>
 > <BR><FONT SIZE=2>> CompressibleBrickView> > > ></FONT>
 > <BR><FONT SIZE=2>> INSTANTIATE_VIEW1_AND_FRIENDS(T1,T2,T3)</FONT>
 > <BR><FONT SIZE=2>> #undef T1</FONT>
 > <BR><FONT SIZE=2>> #undef T2</FONT>
 > <BR><FONT SIZE=2>> #undef T3</FONT>
 > <BR><FONT SIZE=2>> </FONT>
 > </P>
 > 
 > </BODY>
 > </HTML>



More information about the pooma-dev mailing list