1 // RUN: %libomp-cxx-compile-and-run
2 
3 #include <omp.h>
4 
5 #include <algorithm>
6 #include <cassert>
7 #include <vector>
8 
main(int argc,char * argv[])9 int main(int argc, char *argv[]) {
10   const int N = std::min(std::max(std::max(32, 4 * omp_get_max_threads()),
11                                   4 * omp_get_num_procs()),
12                          std::numeric_limits<int>::max());
13 
14   std::vector<int> data(N);
15 
16 #pragma omp parallel for num_threads(N)
17   for (unsigned i = 0; i < N; ++i) {
18     data[i] = i;
19   }
20 
21 #pragma omp parallel for num_threads(N + 1)
22   for (unsigned i = 0; i < N; ++i) {
23     data[i] += i;
24   }
25 
26   for (unsigned i = 0; i < N; ++i) {
27     assert(data[i] == 2 * i);
28   }
29 
30   return 0;
31 }
32