[Proto] Reducing domain check in operator

Actually, Proto defiens operators that STATIC_ASSERT when the left and right operand domain types are no the same using is_same. How could I have those check be looser than is_same ? Should I just overload boost::is_same for my domain type and perform a proper test here or is there a way to incorporate this into Proto ? Thanks in advance

Joel Falcou wrote:
Could you tell me a bit more about your usage scenario? This is certainly an area in which Proto can improve, and I want to understand your requirements. -- Eric Niebler BoostPro Computing http://www.boostpro.com

Eric Niebler a écrit :
Basically I have template domain and template grammar and I want to have element of two different grammar type instance to be usable by the other for some operator/function. For example, I have a SIMD float entity : vec<float> x; Normally, the grammar that dictates this entity behvaior is tempalte<class SIMDTypeInfo> struct grammar : or_< terminal< simd_data<SIMDTypeInfo> > , arithmetic_values , nary_expr< _, narg< grammar<SIMDTypeInfo> >
{};
(or something related)
This grmmar ensure that I can write things like :
vec<float>+vec<float>
but i can't do :
vec<float>+vec<char>
For most functions and operator it's sufficent.
But there is a few SIMD operator like for example exponent that can take
any vec<T> and return a vec

Joel Falcou wrote:
Strange, you shouldn't be seeing this error in this case. For
operator(), Proto doesn't enforce domains to match -- the resulting
expression assumes the domain of the lhs. Consider the following:
#include

Joel Falcou wrote:
Oh, you're using make_expr. If the result of exponent(x) is always in
the domain of simd_domain

Eric Niebler a écrit :
Concerning the other approach, I guess it boils down to have terminal of the given function object laying around? terminal< exponent_ > exponent ={{}}; How does it scale with a large number of function object (say > 300) in term of compile time ? Is there any advantage over make_expr ? -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35

Joel Falcou wrote:
Cool.
Right, although it would change the resulting tree, because exponent(x) would have tag type proto::tag::function instead of nt2::tag::exponent_. You'd have to make corresponding changes to your grammar.
Hard to say. The only advice I can give is to try it and see. -- Eric Niebler BoostPro Computing http://www.boostpro.com

Joel Falcou wrote:
Yes, or else make A a Proto terminal in the X domain.
Yes.
You might be right. I'll be interested in your results. -- Eric Niebler BoostPro Computing http://www.boostpro.com

Joel Falcou wrote:
In the usual way with a Proto extension. E.g.,
simd_expr

OK.
Last question. I changed my make_expr to use domain_of and
it worked nice for the base case.
Then I changed the domain of the
exponent thingy.
exponent takes a float/double vec adn return
an integral vec of the same size. So I gave to
simd_exprtag::exponent_ the same domain as vec<integer>. Now
I can build things like :
exponent(vf) + vi with the proper
type and everything works.
Now, I had some strange behavior in
my calalble_context. When I debug it, it seems that the type of
exponent(vf) is
simd_expr< vec

joel falcou wrote:
I'm confused. You *were* using domain_of and I told you not to. ???
What is domain here?
Please post complete code that I can test. -- Eric Niebler BoostPro Computing http://www.boostpro.com

Eric Niebler a écrit :
It's a template domain to go with the template generator of the tempalte expression.
Please post complete code that I can test. Here is a small test case :
http://codepad.org/x1U86VS9
I used string and lexical cast instead of real SIMD value cause the
amount of extra code was really large and because those two type
has the same non native casting properties than two different vector
types. This exhibits the same problem than I have currently aka
failure to properly evaluate the to_float expression which is an
expression of domain X with a child of domain Z.
The error log with g++ 4.3 is :
/usr/local/include/boost-1_38/boost/proto/context/callable.hpp||In
member function ‘typename boost::result_of

Joel Falcou wrote:
Still confused. <snip>
Here is a small test case :
Hey, that codepad thing is pretty cool. OK, I see the following in your
simd_context class:
template

Eric Niebler a écrit :
Back on the initial topic, can't the assertion for discriminating domain in operators be added as a domain tempalte parameters usign a lambda ? like struct foo_domain : proto::domain< generator , grammar , is_same< domain_of<_1>, domain_of<_2> > > And use this lambda in the STATIC_ASSERT ? -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35

Joel Falcou wrote:
Dang ... that was it :D Working flawlessly now.
Excellent.
That would associate the check with a domain. If there is an expression involving expressions from N different domains, you have N ways of checking for compatibility and no way to chose between them. -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (3)
-
Eric Niebler
-
joel falcou
-
Joel Falcou