Hello All,
So, I wanted to try out some of the new C++17 parallel algorithms and luckily I have access to Parallel Studio 2018. Compiled the following code:
#include <vector>
#include <iostream>
#include "pstl/execution"
#include "pstl/algorithm"
#include "pstl/numeric"
#include "pstl/memory"
int main() {
// 1,000,000 double vector with 1/2
std::vector<double> v(1'000'000);
std::fill(std::execution::par_unseq, v.begin(), v.end(), 0.5);
// Reduction
auto result = std::reduce(std::execution::par, v.begin(), v.end(), 0.0);
std::cout << "Result: "<< result << "\n";
return 0;
}If I run it through vtune, I see it uses the 12 threads on my machine. I did a little googling, but I don't see how I restrict the number of threads this code uses. I saw some ancient suggestions of TBB_NUM_THREADS but that doesn't appear to change anything. How do I control the number of threads if I wanted to run PSTL code in my HPC scheduler?
Thanks.
Barry