freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [pooma-dev] Explicit Instantiation Question


From: Dave Nystrom
Subject: RE: [pooma-dev] Explicit Instantiation Question
Date: Mon, 10 Sep 2001 10:40:11 -0600
User-agent: SEMI/1.13.7 (Awazu) CLIME/1.13.6 (中 ノ庄) MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386-redhat-linux)

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: address@hidden
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:address@hidden
 > > 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: address@hidden
 > > 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>&nbsp; // Deduce appropriate version of implementation to 
 > dispatch to.</FONT>
 > <BR><FONT SIZE=2>&nbsp; </FONT>
 > <BR><FONT SIZE=2>&nbsp; static const bool sv = 
 > DomainTraits&lt;SDomain_t&gt;::singleValued;</FONT>
 > <BR><FONT SIZE=2>&nbsp; typedef View1Implementation&lt;Subject_t, SDomain_t, 
 > sv&gt; Dispatch_t;</FONT>
 > </P>
 > 
 > <P><FONT SIZE=2>&nbsp; // The optimized domain combiner.</FONT>
 > <BR><FONT SIZE=2>&nbsp; </FONT>
 > <BR><FONT SIZE=2>&nbsp; typedef CombineDomainOpt&lt;NewDomain_t, sv&gt; 
 > Combine_t;</FONT>
 > </P>
 > <BR>
 > 
 > <P><FONT SIZE=2>This can be changed to the more unwieldly</FONT>
 > </P>
 > 
 > <P><FONT SIZE=2>&nbsp; // Deduce appropriate version of implementation to 
 > dispatch to.</FONT>
 > <BR><FONT SIZE=2>&nbsp; </FONT>
 > <BR><FONT SIZE=2>&nbsp; typedef View1Implementation&lt;Subject_t, SDomain_t, 
 > DomainTraits&lt;SDomain_t&gt;::singleValued&gt; Dispatch_t;</FONT>
 > </P>
 > 
 > <P><FONT SIZE=2>&nbsp; // The optimized domain combiner.</FONT>
 > <BR><FONT SIZE=2>&nbsp; </FONT>
 > <BR><FONT SIZE=2>&nbsp; typedef CombineDomainOpt&lt;NewDomain_t, 
 > DomainTraits&lt;SDomain_t&gt;::singleValued&gt; Combine_t;&nbsp; </FONT>
 > </P>
 > 
 > <P><FONT SIZE=2>Then &quot;sv&quot; 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&lt;blah&gt;::sv. </FONT></P>
 > 
 > <P><FONT SIZE=2>&nbsp; Jim</FONT>
 > </P>
 > <BR>
 > 
 > <P><FONT SIZE=2>&gt; -----Original Message-----</FONT>
 > <BR><FONT SIZE=2>&gt; From: Dave Nystrom [<A 
 > HREF="mailto:address@hidden";>mailto:address@hidden</A>]</FONT>
 > <BR><FONT SIZE=2>&gt; Sent: Thursday, September 06, 2001 2:08 PM</FONT>
 > <BR><FONT SIZE=2>&gt; To: pooma-dev</FONT>
 > <BR><FONT SIZE=2>&gt; Subject: [pooma-dev] Explicit Instantiation 
 > Question</FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > <BR><FONT SIZE=2>&gt; Here is another try at sending my email.&nbsp; I am 
 > trying again </FONT>
 > <BR><FONT SIZE=2>&gt; to speed up our</FONT>
 > <BR><FONT SIZE=2>&gt; compiles because it has been taking way too long on 
 > b18, the </FONT>
 > <BR><FONT SIZE=2>&gt; SGI machine we</FONT>
 > <BR><FONT SIZE=2>&gt; are doing our classified development on.&nbsp; John 
 > and I have </FONT>
 > <BR><FONT SIZE=2>&gt; made some good</FONT>
 > <BR><FONT SIZE=2>&gt; progress on that by getting shared libraries working 
 > on b18 </FONT>
 > <BR><FONT SIZE=2>&gt; and explicitly</FONT>
 > <BR><FONT SIZE=2>&gt; instantiating all the Pooma2 assign functions in a 
 > special </FONT>
 > <BR><FONT SIZE=2>&gt; library package</FONT>
 > <BR><FONT SIZE=2>&gt; that only needs to be rebuilt when we change Pooma 
 > 2.</FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > <BR><FONT SIZE=2>&gt; In the process of doing that, I have revisited the 
 > idea of trying to</FONT>
 > <BR><FONT SIZE=2>&gt; explicitly instantiate the Pooma 2 View1 and AltView1 
 > templates.&nbsp; When</FONT>
 > <BR><FONT SIZE=2>&gt; Jeffrey was looking at the original problem there with 
 > View1 </FONT>
 > <BR><FONT SIZE=2>&gt; which had a</FONT>
 > <BR><FONT SIZE=2>&gt; circular dependency which was causing a </FONT>
 > <BR><FONT SIZE=2>&gt; point-of-instantiation problem, he</FONT>
 > <BR><FONT SIZE=2>&gt; discovered that he could explicitly instantiate the 
 > View1 </FONT>
 > <BR><FONT SIZE=2>&gt; template with</FONT>
 > <BR><FONT SIZE=2>&gt; fairly simple template arguments by first explicitly 
 > </FONT>
 > <BR><FONT SIZE=2>&gt; instantiating the Field</FONT>
 > <BR><FONT SIZE=2>&gt; class with those same template arguments.&nbsp; Then 
 > he figured out how to</FONT>
 > <BR><FONT SIZE=2>&gt; explicitly instantiate the View1 class by adding the 
 > AltView1 class.</FONT>
 > <BR><FONT SIZE=2>&gt; However, that does not help me because now I have 
 > 2000-3000 AltView1</FONT>
 > <BR><FONT SIZE=2>&gt; templates that I need to instantiate.</FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > <BR><FONT SIZE=2>&gt; So, I tried using Jeffreys original solution which I 
 > modified </FONT>
 > <BR><FONT SIZE=2>&gt; to use with the</FONT>
 > <BR><FONT SIZE=2>&gt; AltView1 template - see the cpp macro </FONT>
 > <BR><FONT SIZE=2>&gt; INSTANTIATE_VIEW1_AND_FRIENDS below.</FONT>
 > <BR><FONT SIZE=2>&gt; But, the simple View1.cc file below fails to compile 
 > when </FONT>
 > <BR><FONT SIZE=2>&gt; using KCC 4.0f on</FONT>
 > <BR><FONT SIZE=2>&gt; Red Hat 7.1 Linux.&nbsp; So, I'm wondering if I am 
 > doing the right </FONT>
 > <BR><FONT SIZE=2>&gt; thing in my cpp</FONT>
 > <BR><FONT SIZE=2>&gt; macro - KCC seems to think not.&nbsp; Also, I'm 
 > wondering if I </FONT>
 > <BR><FONT SIZE=2>&gt; need to explicitly</FONT>
 > <BR><FONT SIZE=2>&gt; instantiate the whole Field class or just 1 or 2 
 > methods of </FONT>
 > <BR><FONT SIZE=2>&gt; the Field class.</FONT>
 > <BR><FONT SIZE=2>&gt; I think that Jeffrey might be the best person to 
 > answer this question</FONT>
 > <BR><FONT SIZE=2>&gt; although others who are intimately familiar with Pooma 
 > 2 </FONT>
 > <BR><FONT SIZE=2>&gt; might be able to</FONT>
 > <BR><FONT SIZE=2>&gt; also.</FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > <BR><FONT SIZE=2>&gt; Bottom line is that I am trying to figure out some way 
 > to explicitly</FONT>
 > <BR><FONT SIZE=2>&gt; instantiate the View1 and AltView1 templates without 
 > having </FONT>
 > <BR><FONT SIZE=2>&gt; to remove the</FONT>
 > <BR><FONT SIZE=2>&gt; circular dependency which is causing the </FONT>
 > <BR><FONT SIZE=2>&gt; point-of-instantiation problem.</FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > <BR><FONT SIZE=2>&gt; Thanks for any help,</FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > <BR><FONT SIZE=2>&gt; Dave Nystrom&nbsp; 
 > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
 > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; email: address@hidden</FONT>
 > <BR><FONT SIZE=2>&gt; LANL X-3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
 > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
 > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; phone: 
 > 505-667-7913&nbsp;&nbsp;&nbsp;&nbsp; fax: </FONT>
 > <BR><FONT SIZE=2>&gt; 505-665-3046</FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > <BR><FONT SIZE=2>&gt; ---------------------------------------Simple View1.cc 
 > </FONT>
 > <BR><FONT SIZE=2>&gt; File-------------------------------------</FONT>
 > <BR><FONT SIZE=2>&gt; #include &quot;Pooma/NewFields.h&quot;</FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > <BR><FONT SIZE=2>&gt; #define 
 > INSTANTIATE_VIEW1_AND_FRIENDS(T1_CPP,T2_CPP,T3_CPP) \</FONT>
 > <BR><FONT SIZE=2>&gt; template 
 > class&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
 > Field&lt;T1_CPP,T2_CPP,T3_CPP&gt;; \</FONT>
 > <BR><FONT SIZE=2>&gt; template&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
 > <BR><FONT SIZE=2>&gt; 
 > AltView1&lt;Field&lt;T1_CPP,T2_CPP,T3_CPP&gt;,Interval&lt;1&gt; &gt;::sv; 
 > \</FONT>
 > <BR><FONT SIZE=2>&gt; template&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
 > <BR><FONT SIZE=2>&gt; 
 > AltView1&lt;Field&lt;T1_CPP,T2_CPP,T3_CPP&gt;,Interval&lt;2&gt; &gt;::sv; 
 > \</FONT>
 > <BR><FONT SIZE=2>&gt; template&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
 > AltView1&lt;Field&lt;T1_CPP,T2_CPP,T3_CPP&gt;,Interval&lt;3&gt; 
 > &gt;::sv;</FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > <BR><FONT SIZE=2>&gt; #define T1 UniformRectilinear&lt;(int)2, double, 
 > Cartesian&lt;(int)2&gt; &gt;</FONT>
 > <BR><FONT SIZE=2>&gt; #define T2 Vector&lt;(int)2, double, Full&gt;</FONT>
 > <BR><FONT SIZE=2>&gt; #define T3 ExpressionTag&lt;BinaryNode&lt;OpAdd, 
 > </FONT>
 > <BR><FONT SIZE=2>&gt; BinaryNode&lt;OpSubtract, BinaryNode&lt;OpMultiply, 
 > Scalar&lt;double&gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; BinaryNode&lt;OpSubtract, BinaryNode&lt;OpAdd, </FONT>
 > <BR><FONT SIZE=2>&gt; Reference&lt;Field&lt;UniformRectilinear&lt;(int)2, 
 > double, </FONT>
 > <BR><FONT SIZE=2>&gt; Cartesian&lt;(int)2&gt; &gt;, Vector&lt;(int)2, 
 > double, Full&gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; CompressibleBrickView&gt; &gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; Reference&lt;Field&lt;UniformRectilinear&lt;(int)2, 
 > double, </FONT>
 > <BR><FONT SIZE=2>&gt; Cartesian&lt;(int)2&gt; &gt;, Vector&lt;(int)2, 
 > double, Full&gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; CompressibleBrickView&gt; &gt; &gt;, 
 > BinaryNode&lt;OpMultiply, </FONT>
 > <BR><FONT SIZE=2>&gt; Scalar&lt;int&gt;, 
 > Reference&lt;Field&lt;UniformRectilinear&lt;(int)2, </FONT>
 > <BR><FONT SIZE=2>&gt; double, Cartesian&lt;(int)2&gt; &gt;, 
 > Vector&lt;(int)2, double, Full&gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; CompressibleBrickView&gt; &gt; &gt; &gt; &gt;, 
 > BinaryNode&lt;OpMultiply, </FONT>
 > <BR><FONT SIZE=2>&gt; BinaryNode&lt;OpMultiply, Scalar&lt;double&gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; Reference&lt;Field&lt;UniformRectilinear&lt;(int)2, 
 > double, </FONT>
 > <BR><FONT SIZE=2>&gt; Cartesian&lt;(int)2&gt; &gt;, Vector&lt;(int)2, 
 > double, Full&gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; CompressibleBrickView&gt; &gt; &gt;, 
 > BinaryNode&lt;OpSubtract, </FONT>
 > <BR><FONT SIZE=2>&gt; Reference&lt;Field&lt;UniformRectilinear&lt;(int)2, 
 > double, </FONT>
 > <BR><FONT SIZE=2>&gt; Cartesian&lt;(int)2&gt; &gt;, Vector&lt;(int)2, 
 > double, Full&gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; CompressibleBrickView&gt; &gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; Reference&lt;Field&lt;UniformRectilinear&lt;(int)2, 
 > double, </FONT>
 > <BR><FONT SIZE=2>&gt; Cartesian&lt;(int)2&gt; &gt;, !</FONT>
 > <BR><FONT SIZE=2>&gt; Vector&lt;(int)2, double, Full&gt;, 
 > CompressibleBrickView&gt; &gt; &gt; &gt; &gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; Reference&lt;Field&lt;UniformRectilinear&lt;(int)2, 
 > double, </FONT>
 > <BR><FONT SIZE=2>&gt; Cartesian&lt;(int)2&gt; &gt;, Vector&lt;(int)2, 
 > double, Full&gt;, </FONT>
 > <BR><FONT SIZE=2>&gt; CompressibleBrickView&gt; &gt; &gt; &gt;</FONT>
 > <BR><FONT SIZE=2>&gt; INSTANTIATE_VIEW1_AND_FRIENDS(T1,T2,T3)</FONT>
 > <BR><FONT SIZE=2>&gt; #undef T1</FONT>
 > <BR><FONT SIZE=2>&gt; #undef T2</FONT>
 > <BR><FONT SIZE=2>&gt; #undef T3</FONT>
 > <BR><FONT SIZE=2>&gt; </FONT>
 > </P>
 > 
 > </BODY>
 > </HTML>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]