[Spirit2X] custom version of Boost.Math signbit / fpclassify

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Spirit2X] custom version of Boost.Math signbit / fpclassify

Francois Barel
I see many tests failing to compile against Boost svn HEAD with this
kind of errors:
.../support/detail/sign.hpp:56: error: no type named 'bits' in
        'struct boost::math::detail::fp_traits_native<float>'
.../support/detail/sign.hpp:57: error: 'get_bits' is not a member
        of 'boost::math::detail::fp_traits_native<float>'
coming from boost::spirit::detail::changesign.

This looks related to the use of a custom version of
boost::math::signbit depending on the Boost version. I didn't follow
closely the original problem and the history of changes, so I thought
I should ask before committing random stuff in that area :)


The attached patch makes those tests pass again with both Boost 1.38
and svn HEAD. It:
- fixes another error when building with Boost <1.39 (missing include
of Boost.Math fpclassify.hpp),
- fixes the errors above when building with Boost svn HEAD by moving
the include of fp_traits.hpp out of the condition on Boost version,
since boost::spirit::detail::changesign always needs it (as there is
no boost::math::changesign, even in Boost svn HEAD).
Does this look OK to you?


By the way, is it useful to keep support/detail/math/fpclassify.hpp
and signbit.hpp, I don't see where they are used? (presumably Johan
Rade's whole FP traits library was copied, but only fp_traits.hpp is
actually used?)

Thanks,
François

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

Spirit2X-fp.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] custom version of Boost.Math signbit / fpclassify

Hartmut Kaiser
François,

> I see many tests failing to compile against Boost svn HEAD with this
> kind of errors:
> .../support/detail/sign.hpp:56: error: no type named 'bits' in
>         'struct boost::math::detail::fp_traits_native<float>'
> .../support/detail/sign.hpp:57: error: 'get_bits' is not a member
>         of 'boost::math::detail::fp_traits_native<float>'
> coming from boost::spirit::detail::changesign.
>
> This looks related to the use of a custom version of
> boost::math::signbit depending on the Boost version. I didn't follow
> closely the original problem and the history of changes, so I thought I
> should ask before committing random stuff in that area :)
>
>
> The attached patch makes those tests pass again with both Boost 1.38
> and svn HEAD. It:
> - fixes another error when building with Boost <1.39 (missing include
> of Boost.Math fpclassify.hpp),
> - fixes the errors above when building with Boost svn HEAD by moving
> the include of fp_traits.hpp out of the condition on Boost version,
> since boost::spirit::detail::changesign always needs it (as there is no
> boost::math::changesign, even in Boost svn HEAD).
> Does this look OK to you?

Thanks for the patch! And thanks for trying to clean up my mess. But I think
I've got a better solution by clearly distinguishing between old and new
Boost versions, not trying to somehow integrate both into one big blob of
un-maintainable version-entangled code. Could you verify it's working for
you?

> By the way, is it useful to keep support/detail/math/fpclassify.hpp
> and signbit.hpp, I don't see where they are used? (presumably Johan
> Rade's whole FP traits library was copied, but only fp_traits.hpp is
> actually used?)

That points towards a general problem. Currently we try to allow compiling
Spirit2x using any (recent) Boost version. For this reason we need some
custom Boost libraries to make it working. Almost all of those libraries are
going to be part of Boost at some point (the FP stuff will be in V1.39, the
endian stuff not long thereafter. So the question is: what Boost version are
we targeting at while developing Spirit2x? My current way of implementing
things was to include those libraries to the extent they are needed and
switch to the 'native' libraries as soon as those are available (using #if
BOOST_VERSION > ...). This seems to be a viable path at least as long
Spirit2x isn't integrated with the main Boost code base. Any thoughts?

Regards Hartmut




------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] custom version of Boost.Math signbit / fpclassify

Francois Barel
Hartmut Kaiser wrote:
> François,
>
> Thanks for the patch! And thanks for trying to clean up my mess. But I think
> I've got a better solution by clearly distinguishing between old and new
> Boost versions, not trying to somehow integrate both into one big blob of
> un-maintainable version-entangled code. Could you verify it's working for
> you?

Nope (in r1135), sorry :) Two problems:

1. boost/spirit/home/karma/numeric/detail/numeric_utils.hpp calls
boost::math::fpclassify, without #include'ing
<boost/math/special_functions/fpclassify.hpp> first. This gives an
error when compiling with Boost 1.38.
With Boost svn HEAD it works "by chance" since
boost/spirit/home/support/detail/sign.hpp contains that include (not
sure why? anyway it's probably not right for another file to rely on a
header named sign.hpp to include fpclassify?).

2. The Boost svn HEAD version of boost::spirit::detail::changesign
(boost/spirit/home/support/detail/sign.hpp) uses fp_traits directly
without including it.
I think it should include and call boost::spirit::math::changesign
instead (the same as for Boost <1.39)?


>> By the way, is it useful to keep support/detail/math/fpclassify.hpp
>> and signbit.hpp, I don't see where they are used? (presumably Johan
>> Rade's whole FP traits library was copied, but only fp_traits.hpp is
>> actually used?)
>
> That points towards a general problem. Currently we try to allow compiling
> Spirit2x using any (recent) Boost version. For this reason we need some
> custom Boost libraries to make it working. Almost all of those libraries are
> going to be part of Boost at some point (the FP stuff will be in V1.39, the
> endian stuff not long thereafter. So the question is: what Boost version are
> we targeting at while developing Spirit2x? My current way of implementing
> things was to include those libraries to the extent they are needed and
> switch to the 'native' libraries as soon as those are available (using #if
> BOOST_VERSION > ...). This seems to be a viable path at least as long
> Spirit2x isn't integrated with the main Boost code base. Any thoughts?

Indeed, that makes sense. It lets users experiment more easily with
Spirit2X, especially those who are already using other Boost libraries
and cannot easily switch to a svn version. Since Spirit2X is
header-only, those users can still get it and use it with a recent
Boost release.

Regards,
François

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] custom version of Boost.Math signbit / fpclassify

Hartmut Kaiser
François,

> > Thanks for the patch! And thanks for trying to clean up my mess. But
> I think
> > I've got a better solution by clearly distinguishing between old and
> new
> > Boost versions, not trying to somehow integrate both into one big
> blob of
> > un-maintainable version-entangled code. Could you verify it's working
> for
> > you?
>
> Nope (in r1135), sorry :) Two problems:
>
> 1. boost/spirit/home/karma/numeric/detail/numeric_utils.hpp calls
> boost::math::fpclassify, without #include'ing
> <boost/math/special_functions/fpclassify.hpp> first. This gives an
> error when compiling with Boost 1.38.
> With Boost svn HEAD it works "by chance" since
> boost/spirit/home/support/detail/sign.hpp contains that include (not
> sure why? anyway it's probably not right for another file to rely on a
> header named sign.hpp to include fpclassify?).
>
> 2. The Boost svn HEAD version of boost::spirit::detail::changesign
> (boost/spirit/home/support/detail/sign.hpp) uses fp_traits directly
> without including it.
> I think it should include and call boost::spirit::math::changesign
> instead (the same as for Boost <1.39)?

Ok, should be really fixed this time. I tried compiling with Boost 1.37,
1.38 and trunk.

Thanks for your patience!
Regards Hartmut



------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] custom version of Boost.Math signbit / fpclassify

Francois Barel
Hartmut Kaiser wrote:
> Ok, should be really fixed this time. I tried compiling with Boost 1.37,
> 1.38 and trunk.

We're getting there! :) It works here (I'm testing if Karma tests
"int_numerics" + "real_numerics" and Qi test "real" compile) with
older Boost versions (tested with 1.37 and 1.38).

However it doesn't work with trunk:
.../support/detail/sign.hpp: In function
        'T boost::spirit::detail::changesign(T) [with T = float]':
.../qi/numeric/detail/real_impl.hpp:83:
        instantiated from here
.../support/detail/sign.hpp:57: error: no type named 'bits'
        in 'struct boost::math::detail::fp_traits_native<float>'
.../support/detail/sign.hpp:58: error: 'get_bits' is not a
        member of 'boost::math::detail::fp_traits_native<float>'

Interesting: by looking at Boost.Math fp_traits, I see that it
dispatches to fp_traits_native in my case (I'm with gcc-4.1 and its
standard STL on Linux), and there is no bits-related stuff in it -- it
is only in fp_traits_non_native.
I would guess your configuration is different, so that in your case
fp_traits dispatches to fp_traits_non_native? By forcing that behavior
(with -DBOOST_MATH_DISABLE_STD_FPCLASSIFY), indeed, it works for me
too.


Side note: Karma tests give this error in karma/detail/output_iterator.hpp:
.../output_iterator.hpp:113: error:
        dependent-name 'std::basic_string<T>::const_iterator'
        is parsed as a non-type, but instantiation yields a type
.../output_iterator.hpp:113: note: say
        'typename std::basic_string<T>::const_iterator' if a type is meant

I added "typename" in r1134, but it was removed in r1136, was that intentional?

Thanks,
François

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] custom version of Boost.Math signbit / fpclassify

Hartmut Kaiser
> > Ok, should be really fixed this time. I tried compiling with Boost
> 1.37,
> > 1.38 and trunk.
>
> We're getting there! :) It works here (I'm testing if Karma tests
> "int_numerics" + "real_numerics" and Qi test "real" compile) with
> older Boost versions (tested with 1.37 and 1.38).
>
> However it doesn't work with trunk:
> .../support/detail/sign.hpp: In function
>         'T boost::spirit::detail::changesign(T) [with T = float]':
> .../qi/numeric/detail/real_impl.hpp:83:
>         instantiated from here
> .../support/detail/sign.hpp:57: error: no type named 'bits'
>         in 'struct boost::math::detail::fp_traits_native<float>'
> .../support/detail/sign.hpp:58: error: 'get_bits' is not a
>         member of 'boost::math::detail::fp_traits_native<float>'
>
> Interesting: by looking at Boost.Math fp_traits, I see that it
> dispatches to fp_traits_native in my case (I'm with gcc-4.1 and its
> standard STL on Linux), and there is no bits-related stuff in it -- it
> is only in fp_traits_non_native.
> I would guess your configuration is different, so that in your case
> fp_traits dispatches to fp_traits_non_native? By forcing that behavior
> (with -DBOOST_MATH_DISABLE_STD_FPCLASSIFY), indeed, it works for me
> too.

Ok that explains why it worked for me and not for you. Thanks for
investigating.
I committed a change which I believe should do the trick.

> Side note: Karma tests give this error in
> karma/detail/output_iterator.hpp:
> .../output_iterator.hpp:113: error:
>         dependent-name 'std::basic_string<T>::const_iterator'
>         is parsed as a non-type, but instantiation yields a type
> .../output_iterator.hpp:113: note: say
>         'typename std::basic_string<T>::const_iterator' if a type is
> meant
>
> I added "typename" in r1134, but it was removed in r1136, was that
> intentional?

Ooops, that got lost underway while resolving a merge conflict (and VC is
not always enforcing typenames, so it stayed unnoticed). I re-added the
typename again.

Thanks!
Regards Hartmut


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] custom version of Boost.Math signbit / fpclassify

Francois Barel
Hartmut Kaiser wrote:
> Ok that explains why it worked for me and not for you. Thanks for
> investigating.
> I committed a change which I believe should do the trick.

It works, thanks!
François

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel