Is there a C++ compiler such as g++ or Microsoft C++ or
any on-line compiler with all C++17 &
Parallel TS (Technical Standard) features
that can compile below given parallel C++ programs please?
Following web site has small program to parallel sum elements of Vector:
http://en.cppreference.com/w/cpp/experimental/reduce
#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream>
#include <chrono>
#include <vector>
#include <numeric>
// #include <experimental/execution_policy>
// #include <experimental/numeric>
#include <experimental/execution_policy>
#include <experimental/numeric>
int main()
{
std::vector<double> v(10'000'007, 0.5);
{
auto t1 = std::chrono::high_resolution_clock::now();
double result = std::accumulate(v.begin(), v.end(), 0.0);
auto t2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> ms = t2 - t1;
std::cout << std::fixed << "std::accumulate result " << result
<< " took " << ms.count() << " ms\n";
}
{
auto t1 = std::chrono::high_resolution_clock::now();
double result = std::experimental::parallel::reduce(
std::experimental::parallel::par,
v.begin(), v.end());
auto t2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> ms = t2 - t1;
std::cout << "parallel::reduce result "
<< result << " took " << ms.count() << " ms\n";
}
}
|
Above program output will be:
<
std::accumulate result 5000003.50000 took 12.7365 ms
parallel::reduce result 5000003.50000 took 5.06423 ms
>
I compiled this program using Microsoft Visual C++ 2017 Professional.
Compiler is giving following errors:
cannot open source file "experimental/execution_policy"
cannot open source file "experimental/numeric"
Any information to resolve these compilation errors please?
Thanks