Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Does TBB require C++0x enabled compiler?

Brijender_B_Intel
372 Views

Does TBB requires C++0x support in compiler? if so, is there a way to still use TBB templates without C++0x?

0 Kudos
1 Solution
robert-reed
Valued Contributor II
372 Views
To elaborate on Raf's correct, albeit terse reply, TBB has features to take advantage of lambda support in the compiler but does not require it. Perhaps the biggest visible change to accommodate lambda constructs is in parallel_reduce(), which has a new interface that contains all the components to present a self-contained means for describing a reduction using a pair of lambda constructs. The original interface is still available but requires a separate body class to permit the definition of two user functions for doing the reduction and doing the join, plus a means to initialize private copies of the reduction variable(s) and recover the final result. Compare the current version of the original interface:

    template 
    void parallel_reduce( const Range& range, Body& body ) {
     internal::start_reduce::run( range, body, __TBB_DEFAULT_PARTITIONER() );
    }

To the new interface to maximize the advantage of lambda constructs:

    template
    Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction ) {
     internal::lambda_reduce_body body(identity, real_body, reduction);
        internal::start_reduce,const __TBB_DEFAULT_PARTITIONER>
     ::run(range, body, __TBB_DEFAULT_PARTITIONER() );
     return body.result();
    }

So if you're currently using TBB but have not made the transition to a compiler that provides lambda support, you should be just fine. Andwhen you're ready to advance your compiler and try lambdas,TBB will be ready for you .

View solution in original post

0 Kudos
3 Replies
RafSchietekat
Valued Contributor III
372 Views

"Does TBB requires C++0x support in compiler?"
No.

0 Kudos
robert-reed
Valued Contributor II
373 Views
To elaborate on Raf's correct, albeit terse reply, TBB has features to take advantage of lambda support in the compiler but does not require it. Perhaps the biggest visible change to accommodate lambda constructs is in parallel_reduce(), which has a new interface that contains all the components to present a self-contained means for describing a reduction using a pair of lambda constructs. The original interface is still available but requires a separate body class to permit the definition of two user functions for doing the reduction and doing the join, plus a means to initialize private copies of the reduction variable(s) and recover the final result. Compare the current version of the original interface:

    template 
    void parallel_reduce( const Range& range, Body& body ) {
     internal::start_reduce::run( range, body, __TBB_DEFAULT_PARTITIONER() );
    }

To the new interface to maximize the advantage of lambda constructs:

    template
    Value parallel_reduce( const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction ) {
     internal::lambda_reduce_body body(identity, real_body, reduction);
        internal::start_reduce,const __TBB_DEFAULT_PARTITIONER>
     ::run(range, body, __TBB_DEFAULT_PARTITIONER() );
     return body.result();
    }

So if you're currently using TBB but have not made the transition to a compiler that provides lambda support, you should be just fine. Andwhen you're ready to advance your compiler and try lambdas,TBB will be ready for you .

0 Kudos
ninhngt
Beginner
372 Views
A place to look for information like this is the TBB manual.

0 Kudos
Reply