How to use experimental parallel STL in C ++ 1z?

I want to try the parallel STL from C ++ 17. However, I cannot find the experimental / execute _policy in libC ++. How can I try this?

I am trying to http://en.cppreference.com/w/cpp/experimental/reduce which says that I should include these files, but I cannot find exec_policy.

#include <experimental/execution_policy> 

After installing libC ++ (I followed http://libcxx.llvm.org/docs/BuildingLibcxx.html ), I tried the following commands, but in vain.

 $ clang++-3.5 -std=c++1z test.cpp -lc++experimental test.cpp:5:10: fatal error: 'experimental/execution_policy' file not found #include <experimental/execution_policy> ^ 1 error generated. 

Is it not implemented yet?

+3
source share
2 answers

Is it not implemented yet?

It is right. Neither in parallelism TS (which would live in <experimental/xxx> , or parallel algorithms in the (not yet final) C ++ 1z standard were implemented in libC ++ (for now).

+4
source

I am using the PSTL implementation in Intel 18 Parallel Studio XE beta , which consists of lib ++ and libstd ++ and is based on TBB . I tested for_each and transform , but nothing else.

Update: Intel PSTL is open source ( https://github.com/intel/parallelstl ) and works with GCC and Clang.

Since PSTL support is limited, I make the code portable through the preprocessor:

 #if defined(USE_PSTL) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1800) std::for_each( pstl::execution::par, std::begin(range), std::end(range), [&] (int i) { std::for_each( pstl::execution::par_unseq, std::begin(range), std::end(range), [&] (int j) { #elif defined(USE_PSTL) && defined(__GNUC__) && defined(__GNUC_MINOR__) \ && ( (__GNUC__ == 8) || (__GNUC__ == 7) && (__GNUC_MINOR__ >= 2) ) __gnu_parallel::for_each( std::begin(range), std::end(range), [&] (int i) { __gnu_parallel::for_each( std::begin(range), std::end(range), [&] (int j) { #else #warning Parallel STL is NOT being used! std::for_each( std::begin(range), std::end(range), [&] (int i) { std::for_each( std::begin(range), std::end(range), [&] (int j) { #endif B[i*order+j] += A[j*order+i]; A[j*order+i] += 1.0; }); }); } 

You can see that this code is based on libc++ on Mac, although part of the PSTL itself belongs to Intel headers, which in turn use TBB as a runtime.

 $ otool -L transpose-vector-pstl transpose-vector-pstl: @rpath/libtbb.dylib (compatibility version 0.0.0, current version 0.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0) @rpath/libiomp5.dylib (compatibility version 5.0.0, current version 5.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2) 

Full disclosure: I work for Intel and discuss this implementation with developers, although I am not responsible for this for anything.

0
source

All Articles