boost::simd log exp pow ...

195 views
Skip to first unread message

engelbert...@uantwerpen.be

unread,
Mar 27, 2014, 7:02:12 AM3/27/14
to nt2...@googlegroups.com
Hi all,
i am evaluating NT2 for building HPC applications. I really liked the idea of boost::simd being a header only library. i know the problematic lack of documentation has been raised before, but repeating it does no harm. 

Basically i wrote a few tests which do computations on arrays of 2000 floats (which fit entirely in L1 cache). really simple stuff like
z = x + y
z = x - y
z = x * y
z = x / y
z = sqrt(x) 
using boost::simd::pack<float> for x, y and z
once i took a look at demo/saxpy/simd/saxpy_simd i was able to figure out the right include files and i got things working quickly. however i am stuck on
z = log(x)
z = exp(x)
z = pow(x,y)
none of the include files like .../log.hpp in boost/simd or nt2 etc could make the code compile 

the test code typically looks like:

typedef boost::simd::pack<float> svfloat_t;
size_t const svfloat_width = svfloat_t::static_size;
size_t const ne = 2000;
std::vector<float,boost::simd::allocator<float>> x_(ne);
std::vector<float,boost::simd::allocator<float>> y_(ne);
std::vector<float,boost::simd::allocator<float>> z_(ne);

for( size_t i=0; i<ne; i+=svfloat_width ) {
     svfloat_t sv_x( &x_[i] );       
     svfloat_t sv_y( &y_[i] );       
     boost::simd::aligned_store( OP( sv_x ), &z_[i] );   
}

as said for OP equal to sqrt this went fine, but for log not

os : ubuntu 13.10
compiler : gcc 4.8.1
cpu : ivy-bridge  (AVX support)

any help is wellcome.

Joel Falcou

unread,
Mar 27, 2014, 9:23:14 AM3/27/14
to nt2...@googlegroups.com
You need to include

nt2/include/functions/log.hpp

as log etc... lives in NT2 and not boost.simd.

If it doesnt solve your issue, we may need to know how you installed the
library.

Engelbert Tijskens

unread,
Mar 28, 2014, 6:50:27 AM3/28/14
to nt2...@googlegroups.com, joel....@metascale.org

Hi joel,
i did as you told and included 
nt2/include/functions/log.hpp 
nt2/include/functions/pow.hpp
compiling with gcc 4.8.1 didn't succeed, but icpc 14 did, so apparently it is a compiler issue. Are there any recommendations as to which gcc can be used?
kindest regards,
bert

Mathias Gaunard

unread,
Mar 28, 2014, 7:03:05 AM3/28/14
to nt2...@googlegroups.com
All GCC versions from 4.1 onwards are supported.
What is your error message?

Joel Falcou

unread,
Mar 28, 2014, 7:03:24 AM3/28/14
to nt2...@googlegroups.com

On 28/03/2014 11:50, Engelbert Tijskens wrote:
>
> Hi joel,
> i did as you told and included
> nt2/include/functions/log.hpp
> nt2/include/functions/pow.hpp
> compiling with gcc 4.8.1 didn't succeed, but icpc 14 did, so
> apparently it is a compiler issue. Are there any recommendations as to
> which gcc can be used?
> kindest regards,
> bert

Strange, care to give us the actual compilation error ?

Engelbert Tijskens

unread,
Mar 28, 2014, 7:26:41 AM3/28/14
to nt2...@googlegroups.com
Hi Joel, Mathias,
i attached a stripped down version of the source file main.hpp resulting in the error below 
many thanks for your consideration
kindest regards, bert

12:22:21 **** Incremental Build of configuration Debug for project boost-simd-log ****
make all 
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -std=c++0x -I/opt/intel/composer_xe_2013_sp1.2.144/ipp/include -I/opt/intel/composer_xe_2013_sp1.2.144/mkl/include -I/opt/intel/composer_xe_2013_sp1.2.144/tbb/include -I/home/etijskens/software/boost/1_55_0/include -I/home/etijskens/software/nt2/Release/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
../main.cpp: In function ‘int main()’:
../main.cpp:36:47: error: cannot convert ‘svfloat_t {aka boost::simd::pack<float>}’ to ‘double’ for argument ‘1’ to ‘double log(double)’
         boost::simd::aligned_store( log( sv_x ), &z_[i] );
                                               ^
../main.cpp:41:52: error: cannot convert ‘svfloat_t {aka boost::simd::pack<float>}’ to ‘double’ for argument ‘1’ to ‘double pow(double, double)’
         boost::simd::aligned_store( pow( sv_x, sv_y), &z_[i] );
                                                    ^
../main.cpp:14:18: warning: unused variable ‘nreps’ [-Wunused-variable]
     size_t const nreps=10000;
                  ^
make: *** [main.o] Error 1

12:22:33 Build Finished (took 11s.741ms)

main.cpp

Mathias Gaunard

unread,
Mar 28, 2014, 9:09:27 AM3/28/14
to nt2...@googlegroups.com
Simply qualify log and pow.
nt2::log(sv_x) etc.
> --
> You received this message because you are subscribed to the Google
> Groups "nt2-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to nt2-dev+u...@googlegroups.com
> <mailto:nt2-dev+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Engelbert Tijskens

unread,
Mar 28, 2014, 9:27:07 AM3/28/14
to nt2...@googlegroups.com
unfortunately that does not help. 
(which i expected because icpc does not need the qualification.)
the error then is 
14:22:23 **** Incremental Build of configuration Debug for project boost-simd-log ****
make all 
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -std=c++0x -I/opt/intel/composer_xe_2013_sp1.2.144/ipp/include -I/opt/intel/composer_xe_2013_sp1.2.144/mkl/include -I/opt/intel/composer_xe_2013_sp1.2.144/tbb/include -I/home/etijskens/software/boost/1_55_0/include -I/home/etijskens/software/nt2/Release/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
../main.cpp: In function ‘int main()’:
../main.cpp:14:18: warning: unused variable ‘nreps’ [-Wunused-variable]
     size_t const nreps=10000;
                  ^
In file included from /home/etijskens/software/boost/1_55_0/include/boost/type_traits/is_volatile.hpp:28:0,
                 from /home/etijskens/software/boost/1_55_0/include/boost/type_traits/intrinsics.hpp:207,
                 from /home/etijskens/software/boost/1_55_0/include/boost/type_traits/is_class.hpp:14,
                 from /home/etijskens/software/nt2/Release/include/boost/simd/sdk/details/aliasing.hpp:14,
                 from /home/etijskens/software/nt2/Release/include/boost/simd/sdk/simd/native_fwd.hpp:12,
                 from /home/etijskens/software/nt2/Release/include/boost/simd/sdk/simd/meta/extension_of.hpp:15,
                 from /home/etijskens/software/nt2/Release/include/boost/simd/sdk/simd/extensions/meta/sse.hpp:16,
                 from /home/etijskens/software/nt2/Release/include/boost/simd/sdk/simd/extensions/x86/sse2.hpp:48,
                 from /home/etijskens/software/nt2/Release/include/boost/simd/sdk/simd/extensions/x86.hpp:29,
                 from /home/etijskens/software/nt2/Release/include/boost/simd/sdk/simd/extensions/extensions.hpp:5,
                 from /home/etijskens/software/nt2/Release/include/boost/simd/sdk/simd/extensions.hpp:16,
                 from /home/etijskens/software/nt2/Release/include/boost/simd/sdk/simd/pack.hpp:12,
                 from ../main.cpp:4:
/home/etijskens/software/boost/1_55_0/include/boost/type_traits/detail/cv_traits_impl.hpp: In instantiation of ‘struct boost::detail::cv_traits_imp<boost::simd::logical<float>*>’:
/home/etijskens/software/boost/1_55_0/include/boost/type_traits/is_const.hpp:64:4:   required from ‘const bool boost::detail::is_const_rvalue_filter<boost::simd::logical<float> >::value’
/home/etijskens/software/boost/1_55_0/include/boost/type_traits/is_const.hpp:77:1:   required from ‘struct boost::is_const<boost::simd::logical<float> >’
/home/etijskens/software/nt2/Release/include/boost/simd/sdk/simd/native.hpp:66:5:   required from ‘struct boost::simd::native<boost::simd::logical<float>, boost::simd::tag::sse_, void>’
/home/etijskens/software/nt2/Release/include/nt2/exponential/functions/simd/common/pow.hpp:60:11:   required from ‘nt2::ext::implement<nt2::tag::pow_(boost::dispatch::meta::simd_<boost::dispatch::meta::floating_<T>, X>, boost::dispatch::meta::simd_<boost::dispatch::meta::floating_<T>, X>), boost::dispatch::tag::cpu_>::result_type nt2::ext::implement<nt2::tag::pow_(boost::dispatch::meta::simd_<boost::dispatch::meta::floating_<T>, X>, boost::dispatch::meta::simd_<boost::dispatch::meta::floating_<T>, X>), boost::dispatch::tag::cpu_>::operator()(const A0&, const A0&) const [with A0 = boost::simd::native<float, boost::simd::tag::sse_, void>; X = boost::simd::tag::sse_; nt2::ext::implement<nt2::tag::pow_(boost::dispatch::meta::simd_<boost::dispatch::meta::floating_<T>, X>, boost::dispatch::meta::simd_<boost::dispatch::meta::floating_<T>, X>), boost::dispatch::tag::cpu_>::result_type = boost::simd::native<float, boost::simd::tag::sse_, void>]’
/home/etijskens/software/nt2/Release/include/boost/simd/dsl/functions/generic/run.hpp:210:33:   required from ‘boost::simd::ext::implement<boost::simd::tag::run_(boost::dispatch::meta::node_<Expr, boost::dispatch::meta::unspecified_<Tag>, mpl_::long_<2l>, D>), boost::dispatch::tag::formal_>::result_type boost::simd::ext::implement<boost::simd::tag::run_(boost::dispatch::meta::node_<Expr, boost::dispatch::meta::unspecified_<Tag>, mpl_::long_<2l>, D>), boost::dispatch::tag::formal_>::operator()(Expr&) const [with Expr = const boost::simd::expression<boost::proto::exprns_::expr<nt2::tag::pow_, boost::proto::argsns_::list2<boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&>, boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&> >, 2l>, boost::simd::native<float, boost::simd::tag::sse_, void> >; T = nt2::tag::pow_; D = boost::simd::domain; boost::simd::ext::implement<boost::simd::tag::run_(boost::dispatch::meta::node_<Expr, boost::dispatch::meta::unspecified_<Tag>, mpl_::long_<2l>, D>), boost::dispatch::tag::formal_>::result_type = boost::simd::native<float, boost::simd::tag::sse_, void>]’
/home/etijskens/software/nt2/Release/include/boost/simd/dsl/functions/run.hpp:23:3:   required from ‘typename boost::dispatch::meta::result_of<typename boost::dispatch::meta::dispatch_call<boost::simd::tag::run_(const A0&)>::type(const A0&)>::type boost::simd::run(const A0&) [with A0 = boost::simd::expression<boost::proto::exprns_::expr<nt2::tag::pow_, boost::proto::argsns_::list2<boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&>, boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&> >, 2l>, boost::simd::native<float, boost::simd::tag::sse_, void> >; typename boost::dispatch::meta::result_of<typename boost::dispatch::meta::dispatch_call<boost::simd::tag::run_(const A0&)>::type(const A0&)>::type = boost::simd::native<float, boost::simd::tag::sse_, void>]’
/home/etijskens/software/nt2/Release/include/boost/simd/dsl/functions/generic/evaluate.hpp:42:20:   required from ‘boost::simd::ext::implement<boost::simd::tag::evaluate_(boost::dispatch::meta::ast_<A0, D>), boost::dispatch::tag::formal_>::result_type boost::simd::ext::implement<boost::simd::tag::evaluate_(boost::dispatch::meta::ast_<A0, D>), boost::dispatch::tag::formal_>::operator()(A0&) const [with A0 = const boost::simd::expression<boost::proto::exprns_::expr<nt2::tag::pow_, boost::proto::argsns_::list2<boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&>, boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&> >, 2l>, boost::simd::native<float, boost::simd::tag::sse_, void> >; D = boost::simd::domain; boost::simd::ext::implement<boost::simd::tag::evaluate_(boost::dispatch::meta::ast_<A0, D>), boost::dispatch::tag::formal_>::result_type = boost::simd::native<float, boost::simd::tag::sse_, void>]’
/home/etijskens/software/nt2/Release/include/boost/simd/dsl/functions/evaluate.hpp:19:3:   required from ‘typename boost::dispatch::meta::result_of<typename boost::dispatch::meta::dispatch_call<boost::simd::tag::evaluate_(const A0&)>::type(const A0&)>::type boost::simd::evaluate(const A0&) [with A0 = boost::simd::expression<boost::proto::exprns_::expr<nt2::tag::pow_, boost::proto::argsns_::list2<boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&>, boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&> >, 2l>, boost::simd::native<float, boost::simd::tag::sse_, void> >; typename boost::dispatch::meta::result_of<typename boost::dispatch::meta::dispatch_call<boost::simd::tag::evaluate_(const A0&)>::type(const A0&)>::type = boost::simd::native<float, boost::simd::tag::sse_, void>]’
/home/etijskens/software/nt2/Release/include/boost/simd/memory/functions/simd/pack/aligned_store.hpp:68:45:   required from ‘boost::simd::ext::implement<boost::simd::tag::aligned_store_(boost::dispatch::meta::ast_<A0, boost::simd::domain>, boost::dispatch::meta::iterator_<boost::dispatch::meta::unspecified_<Tag> >), boost::dispatch::tag::cpu_>::result_type boost::simd::ext::implement<boost::simd::tag::aligned_store_(boost::dispatch::meta::ast_<A0, boost::simd::domain>, boost::dispatch::meta::iterator_<boost::dispatch::meta::unspecified_<Tag> >), boost::dispatch::tag::cpu_>::operator()(const A0&, A1) const [with A0 = const boost::simd::expression<boost::proto::exprns_::expr<nt2::tag::pow_, boost::proto::argsns_::list2<boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&>, boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&> >, 2l>, boost::simd::native<float, boost::simd::tag::sse_, void> >; A1 = float*; boost::simd::ext::implement<boost::simd::tag::aligned_store_(boost::dispatch::meta::ast_<A0, boost::simd::domain>, boost::dispatch::meta::iterator_<boost::dispatch::meta::unspecified_<Tag> >), boost::dispatch::tag::cpu_>::result_type = void]’
/home/etijskens/software/nt2/Release/include/boost/simd/memory/functions/aligned_store.hpp:123:20:   required from ‘void boost::simd::aligned_store(const Value&, const Pointer&) [with Value = boost::simd::expression<boost::proto::exprns_::expr<nt2::tag::pow_, boost::proto::argsns_::list2<boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&>, boost::simd::expression<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<const boost::simd::native<float, boost::simd::tag::sse_, void>&>, 0l>, const boost::simd::native<float, boost::simd::tag::sse_, void>&> >, 2l>, boost::simd::native<float, boost::simd::tag::sse_, void> >; Pointer = float*]’
../main.cpp:41:67:   required from here
/home/etijskens/software/boost/1_55_0/include/boost/type_traits/detail/cv_traits_impl.hpp:36:1: internal compiler error: in finish_member_declaration, at cp/semantics.c:2686
 {
 ^
Please submit a full bug report,
with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
Preprocessed source stored into /tmp/ccoKDSI4.out file, please attach this to your bugreport.
make: *** [main.o] Error 1

14:23:09 Build Finished (took 46s.205ms)

Joel Falcou

unread,
Mar 28, 2014, 10:13:32 AM3/28/14
to nt2...@googlegroups.com
On 28/03/2014 14:27, Engelbert Tijskens wrote:
unfortunately that does not help. 
(which i expected because icpc does not need the qualification.)


Add
-fno-strict-aliasing -DBOOST_SIMD_NO_STRICT_ALIASING
to the command line.



Mathias Gaunard

unread,
Mar 28, 2014, 10:53:21 AM3/28/14
to nt2...@googlegroups.com
On 28/03/2014 14:27, Engelbert Tijskens wrote:
> unfortunately that does not help.
> (which i expected because icpc does not need the qualification.)

icpc might be wrong here, I don't think it should get selected
automatically.


> /home/etijskens/software/boost/1_55_0/include/boost/type_traits/detail/cv_traits_impl.hpp:36:1:
> internal compiler error: in finish_member_declaration, at
> cp/semantics.c:2686
> {
> ^
> Please submit a full bug report,
> with preprocessed source if appropriate.
>
> See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
> Preprocessed source stored into /tmp/ccoKDSI4.out file, please attach
> this to your bugreport.

As the error message says, you ran into a compiler bug.
It is tied to the GCC-specific may_alias attribute, you can work around
it with the option Joel gave in his message.

Reply all
Reply to author
Forward
0 new messages