Re: [proto] Who's using proto ?
On 06/06/2012 09:24 PM, Joel Falcou wrote: Hi, i'm in the process of writing a journal paper about proto and I wanted to give a realistic snapshot of who is using proto and for what. I know some already (the whole MSM Spirit team etc ) but i am sure there is other people lurking around here. So, if you want to contribute, I wish any of you, proto user, to tell me who you are, what you're using proto for and if you have a reference (for academic) or a website (for other). It's a win-win as you may get exposure and you help us make this paper a nice PR for proto. Of course, you can do this on the list or in private if you prefer. Thanks in advance. ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto -- Dr. Karsten Ahnert Ambrosys GmbH - Gesellschaft für Management komplexer Systeme Geschwister-Scholl-Str. 63a D-14471 Potsdam Tel: +4917682001688 Fax: +493319791300 Ambrosys GmbH - Gesellschaft für Management komplexer Systems Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: Geschwister-Scholl-Str. 63a, 14471 Potsdam Registergericht: Amtsgericht Potsdam, HRB 21228 P Geschäftsführer: Dr. Karsten Ahnert, Dr. Markus Abel ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] Who's using proto ?
On 06/06/2012 09:24 PM, Joel Falcou wrote: Hi, i'm in the process of writing a journal paper about proto and I wanted to give a realistic snapshot of who is using proto and for what. I know some already (the whole MSM Spirit team etc ) but i am sure there is other people lurking around here. So, if you want to contribute, I wish any of you, proto user, to tell me who you are, what you're using proto for and if you have a reference (for academic) or a website (for other). It's a win-win as you may get exposure and you help us make this paper a nice PR for proto. Of course, you can do this on the list or in private if you prefer. Thanks in advance. Hi Joel, we use proto for the Taylor series method to solve ordinary differential equations. The method is based on automatic differentiation, and proto is the tool of choice to do this. The main advantage is that you can solve ODEs with very high precision within reasonable computation time, where the classical ODE solvers are relatively slow. The whole method should be integrated into odeint (odeint.com), which is a general library for solving ODEs. At the moment we are preparing odeint for a boost review. We have given some talks about odeint (one at this years C++Now) and the Taylor series method and there are two small conference proceedings [1]. Karsten P.S. sorry for the empty mail. [1] http://link.aip.org/link/?APCPCS/1389/1586/1 or http://arxiv.org/abs/1110.3397 ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
[proto] restructuring expression
I have an arithmetic expression template where multiplication is commutative. Is there an easy way to order a chain of multiplications such that terminals with values (like proto::terminal double ) appear at the beginning? For example that arg1 * arg1 * 1.5 * arg1 will be transformed to 1.5 * arg1 * arg1 * arg1 ? I can imagine some complicated algorithms swapping expressions and child expressions but I wonder if there is a simpler way. ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] Manipulating an expression tree
On 04/08/2011 02:16 PM, Bart Janssens wrote: On Fri, Apr 8, 2011 at 2:11 PM, Karsten Ahnert karsten.ahn...@ambrosys.de wrote: Thank you for your example. I have one question: how do you use (or assign something to) the intermediate values in StoredMatrixExpression? Once the wrapping is done, every wrapped node (multiplies expressions in your case) will have the value member. This can be used from within any primitive transform or context, if you are working on the expression after it is transformed by WrapExpression. So instead of eval(your_expr) you would do something like eval(WrapExpression()(your_expr)) and then you can assume value exists when it is needed. Ok, I think I understand how you replace the nodes, but I don't understand how you parse the tree and how you access the value member. Do you use contexts and eval()? Could you please show a small piece of code? Thanks, Cheers, -- Dr. Karsten Ahnert Ambrosys GmbH - Gesellschaft für Management komplexer Systeme Geschwister-Scholl-Str. 63a D-14471 Potsdam Tel: +4917682001688 Fax: +493319791300 Ambrosys GmbH - Gesellschaft für Management komplexer Systems Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: Geschwister-Scholl-Str. 63a, 14471 Potsdam Registergericht: Amtsgericht Potsdam, HRB 21228 P Geschäftsführer: Dr. Karsten Ahnert, Dr. Markus Abel ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] Manipulating an expression tree
If you need to compute intermediate values, you can use a transform to build a parallel structure. Do you mean to build an entire new tree, or just to replace some nodes? If only some nodes have associated intermediate result, then you could just replace some nodes. Ok, this is a clear hint. In my current algorithm I use callable contexts to do the work. I think this is more favorable since I have to evaluate the tree N times to obtain the result. Why does that matter? Transforms are almost always a better choice. I think it would be nice to replace some nodes and customizing the evaluation context, such that these nodes can be used to store the intermediates. If you're doing calculation *and* tree transformation, then drop the callable contexts. They can't do the job. First I do tree transformation and then calculation. A Callable context will not do the job, since one only gets the tag of the current node, but not the node itself. So I have to implement my own context. I am not sure if transforms can do that job. It is definitely not possible to obtain the full tree for 10th derivative. Maybe some other tricks are possible with transforms. At the moment I don't understand them in detail, but I will try to change this. Thanks for your advice. ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] Manipulating an expression tree
Why not just write a transform that calculates one derivative and call it N times to get the Nth derivative? Yes, that may be easy if you need two or three higher derivatives. For my application I need 10 to 20 or even more. I guess that currently no compiler can handle such large trees. For example, the simple product rule will result in 2^N terms. But in the case of the product rule, one can use Leibnitz rule: If f(x)=g1(x) g2(x), then the N-th derivative of f(x) is sum_{k=0}^N binomial(N , k ) g1^k(x) g2^(N-k)(x). (g1^k is the k-th derivative of g1). This is exactly the point where I need intermediate values, to store previously calculated values of the derivatives of g1 and g2. Nevertheless, thank you for your example. I am a beginner with proto such that every example is highly illuminating. ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] Manipulating an expression tree
Thank you for your example. I have one question: how do you use (or assign something to) the intermediate values in StoredMatrixExpression? On Thu, Apr 7, 2011 at 12:45 AM, Karsten Ahnert karsten.ahn...@ambrosys.de wrote: Another question is: can a node have a state. In my algorithm it would be nice, if every proto::multiplies node stores some intermediate values which are used during later evaluations of the tree. I did something similar to this to resolve the issue I had with the Eigen matrix library. I am replacing multiplies nodes with an expression that uses proto::extends to add extra state, in this case a correctly sized matrix to store the temporary matrix Eigen generates. I've attached the header that does the node replacement in all the cases that match the WrappableElementExpressions (Wrap in the header means replacing the node). Note that this header is ripped out of the context of a larger application (used for finite elements), so some stuff will not make sense, but the general idea might be helpful. I am using a primitive transform (WrapMatrixExpression) to do the actual node replacement here. An alternative would be to create a domain, and then use the make_... family of transforms to create nodes in that domain. I went for the primitive transform because it seemed to compile faster and with less memory. I intend to post a more detailed example on how I solved the problem with Eigen later on, with examples that are more stand-alone. Cheers, -- Bart ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto Karsten Ahnert Ambrosys GmbH - Gesellschaft für Management komplexer Systeme Geschwister-Scholl-Str. 63a D-14471 Potsdam Tel: +4917682001688 Fax: +493319791300 Ambrosys GmbH - Gesellschaft für Management komplexer Systems Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: Geschwister-Scholl-Str. 63a, 14471 Potsdam Registergericht: Amtsgericht Potsdam, HRB 21228 P Geschäftsführer: Karsten Ahnert, Dr. Markus Abel Karsten Ahnert Ambrosys GmbH - Gesellschaft für Management komplexer Systeme Geschwister-Scholl-Str. 63a D-14471 Potsdam Tel: +4917682001688 Fax: +493319791300 Ambrosys GmbH - Gesellschaft für Management komplexer Systems Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: Geschwister-Scholl-Str. 63a, 14471 Potsdam Registergericht: Amtsgericht Potsdam, HRB 21228 P Geschäftsführer: Karsten Ahnert, Dr. Markus Abel ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] Manipulating an expression tree
Great! It works perfectly, alltough I don't understand the code completely yet. Another question is: can a node have a state. In my algorithm it would be nice, if every proto::multiplies node stores some intermediate values which are used during later evaluations of the tree. Thanks, Karsten On 04/06/2011 10:53 PM, Bart Janssens wrote: On Wed, Apr 6, 2011 at 10:29 PM, Karsten Ahnert karsten.ahn...@ambrosys.de wrote: Is there a direct way to transform an expression tree into another one? For example, is it possible that every proto::plus node is transformed to it left child? I tried to solve this problem via protos build-in transforms without success. It seems that they are suited for evaluation of an existing tree, but I might be wrong. Hi Karsten, I'm pretty sure they can do both. For your example, I think something along the lines of this might work (untested): struct LeftPlus : boost::proto::or_ boost::proto::terminalboost::proto::_, boost::proto::when boost::proto::plusboost::proto::_, boost::proto::_, LeftPlus(boost::proto::_left) , boost::proto::nary_expr boost::proto::_, boost::proto::varargLeftPlus {}; This should recurse through expressions and replace sequences of pluses with the left-most terminal. You may need some other criteria to end the recursion depending on your use case. Disclaimer: I'm relatively new to proto myself, so the experts might have better solutions! Cheers, -- Dr. Karsten Ahnert Ambrosys GmbH - Gesellschaft für Management komplexer Systeme Geschwister-Scholl-Str. 63a D-14471 Potsdam Tel: +4917682001688 Fax: +493319791300 Ambrosys GmbH - Gesellschaft für Management komplexer Systems Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: Geschwister-Scholl-Str. 63a, 14471 Potsdam Registergericht: Amtsgericht Potsdam, HRB 21228 P Geschäftsführer: Dr. Karsten Ahnert, Dr. Markus Abel ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] vector of proto expressions
Hmm, this might work. It is similar to my_method( fusion::make_vector( i+i , i*i*i , i*i ) , x ); But the expression might become really large, say 100 elements. A separation between construction and usage would be nicer. In pseudo code it should look like this: Expressions N expressions; construct( expressions );// or something similar do_step( epxressions , x ); // my method How about something like? ~ #include boost/proto/proto.hpp using namespace boost::proto; templateclass Expr, class X void my_method(Expr const e, X const x) { } int main() { using namespace boost::proto; terminalint::type i = {0}; my_method( (i+i, i*i, i*i*i), 10); } ~~ Notice that you don't need to explicitly store the expressions in a container, you can just combine them in a larger expression tree which can be parsed in my_method. Nate This message and any attachments are intended only for the individual or entity to which the message is addressed. This is a private message and may contain privileged information. If you are neither the intended recipient nor the agent responsible for delivering the message to the intended recipient, you are hereby notified that any review, retransmission, dissemination, or taking of any action in reliance upon, the information in this communication is strictly prohibited, and may be unlawful. If you feel you have received this communication in error, please notify me immediately by returning this email to me and deleting it from your computer. ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto Karsten Ahnert Ambrosys GmbH - Gesellschaft für Management komplexer Systeme Geschwister-Scholl-Str. 63a D-14471 Potsdam Tel: +4917682001688 Fax: +493319791300 Ambrosys GmbH - Gesellschaft für Management komplexer Systems Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: Geschwister-Scholl-Str. 63a, 14471 Potsdam Registergericht: Amtsgericht Potsdam, HRB 21228 P Geschäftsführer: Karsten Ahnert, Dr. Markus Abel ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] vector of proto expressions
Ok, but auto is c++0x specific, right? Is there a possibility for c++03? On 03/18/2011 05:02 PM, Nate Knight wrote: On Mar 18, 2011, at 9:17 AM, Karsten Ahnert wrote: Hmm, this might work. It is similar to my_method( fusion::make_vector( i+i , i*i*i , i*i ) , x ); But the expression might become really large, say 100 elements. A separation between construction and usage would be nicer. How about? struct expr_list_tag {}; ... terminalint::type i = {0}; // you could wrap this in a function named construct or whatever auto e = make_exprexpr_list_tag(i+i, i*i, i*i*i); ... do_step(e, x); I think you need to capture terminals by value to do this kind of thing. ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto -- Dr. Karsten Ahnert Ambrosys GmbH - Gesellschaft für Management komplexer Systeme Geschwister-Scholl-Str. 63a D-14471 Potsdam Tel: +4917682001688 Fax: +493319791300 Ambrosys GmbH - Gesellschaft für Management komplexer Systems Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: Geschwister-Scholl-Str. 63a, 14471 Potsdam Registergericht: Amtsgericht Potsdam, HRB 21228 P Geschäftsführer: Dr. Karsten Ahnert, Dr. Markus Abel ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] proto performance
MacBook Pro, 10.6.6, Core 2 Duo ProtoContext ProtoTransform ProtoLambda Loop GCC 4.2.1 (Apple) : 5.3565438 5.3721942 126.38458 1.3657978 GCC 4.4.5 : 1.8878364 1.8845548 70.056237 0.942303 GCC 4.5.2 : 1.8840608 1.889619 1.2806688 1.0589558 GCC 4.6.0 (2/5/11): 1.88547681.8834438 1.2783471.2345208 CLANG 2.9 (125472): 5.455976 5.4627628 3.8251041.2330524 Now, removing the ((noinline)), gives (in the same order) GCC 4.2.1 (Apple) : 4.1448478 5.3795842 126.53211 1.3215378 GCC 4.4.5 : 1.2505956 1.2500816 69.409665 0.7198288 GCC 4.5.2 : 0.5961430.7213138 0.71969283 0.7211534 GCC 4.6.0 (2/5/11): 1.2942638 1.4324828 0.646147 0.6632324 CLANG 2.9 (125472): 1.2975226 1.2966478 1.3849834 1.2452362 Interesting results. I have done a similar test for loops (for, while, with/without pointers) and obtained similar results. Everything depends on the compiler. I think the order of the above numbers will drastically change if the expression is small, like x3 = x1 + 2.0 * x2. I'm not sure how meaningful this second set of numbers is. If the evaluation functions are inlined, the compiler can realize that evaluating them num_of_steps times is unnecessary since the data isn't changing between iterations. It then (I believe) optimizes out certain parts of the loop in certain cases. Maybe it would be better to evaluate something with the increment assign operator, x3 += x1 + 2.0 * x2. ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
[proto] proto performance
Hi, I wrote a tiny linear algebra edsl using proto and std::tr1::array: namespace linear_algebra { const size_t n = 512; typedef std::tr1::array double , n state_type; templatetypename T struct is_terminal : mpl::false_ {}; template struct is_terminal state_type : mpl::true_ {}; template struct is_terminal double : mpl::true_ {}; BOOST_PROTO_DEFINE_OPERATORS( is_terminal , proto::default_domain ) struct vector_context : proto::callable_context vector_context const { size_t m_i; vector_context( size_t i ) : m_i( i ) { } typedef double result_type; double operator()( proto::tag::terminal , state_type arr ) const { return arr[ m_i ]; } }; } template typename Expr void assign_proto( linear_algebra::state_type x , Expr const expr ) { using namespace linear_algebra; for( size_t i=0 ; in ; ++i ) { vector_context ctx( i ); x[i] = proto::eval( expr , ctx ); } } I compared the run-time performance of a particular expression to its hand written version I wonder that Proto is about 2 to 4 times slower (depending on the size of the vectors). Is there something I can do to enhance the performance of proto? The full code is here http://pastebin.com/Je1JEfCN Thanks, Karsten ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] proto performance
On 02/20/2011 12:02 PM, Joel Falcou wrote: On 20/02/11 11:55, Karsten Ahnert wrote: On 02/20/2011 11:57 AM, Eric Niebler wrote: It gcc 4.4 on a 64bit machine. Of course, I compile with -O3. Ding! welcome to gcc-4.4 64bits compiler hellfest. Try 4.5, 4.4 64bits can't inlien for w/e reason. Great, I tried with gcc 4.5 and the proto part is now around 5-10 percents faster. Thank you. ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto -- Dr. Karsten Ahnert Ambrosys GmbH - Gesellschaft für Management komplexer Systeme Geschwister-Scholl-Str. 63a D-14471 Potsdam Tel: +4917682001688 Fax: +493319791300 Ambrosys GmbH - Gesellschaft für Management komplexer Systems Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: Geschwister-Scholl-Str. 63a, 14471 Potsdam Registergericht: Amtsgericht Potsdam, HRB 21228 P Geschäftsführer: Dr. Karsten Ahnert, Dr. Markus Abel ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto
Re: [proto] proto performance
On 02/20/2011 12:08 PM, Joel Falcou wrote: On 20/02/11 12:03, Karsten Ahnert wrote: On 02/20/2011 12:02 PM, Joel Falcou wrote: On 20/02/11 11:55, Karsten Ahnert wrote: On 02/20/2011 11:57 AM, Eric Niebler wrote: It gcc 4.4 on a 64bit machine. Of course, I compile with -O3. Ding! welcome to gcc-4.4 64bits compiler hellfest. Try 4.5, 4.4 64bits can't inlien for w/e reason. Great, I tried with gcc 4.5 and the proto part is now around 5-10 percents faster. Thank you. We banged our heads for weeks on this issue earlier until we found some dubious bug report in gcc bugzilla flagged as nofix :/ Seems the 4.5 branch solved it somehow. It is amazing that the proto expression is faster then the naive one. The compiler must really love the way proto evaluates an expression. You cna also try compiling with 4.4 using -m32 ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto -- Dr. Karsten Ahnert Ambrosys GmbH - Gesellschaft für Management komplexer Systeme Geschwister-Scholl-Str. 63a D-14471 Potsdam Tel: +4917682001688 Fax: +493319791300 Ambrosys GmbH - Gesellschaft für Management komplexer Systems Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: Geschwister-Scholl-Str. 63a, 14471 Potsdam Registergericht: Amtsgericht Potsdam, HRB 21228 P Geschäftsführer: Dr. Karsten Ahnert, Dr. Markus Abel ___ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto