1 // RUN: %libomp-cxx-compile-and-run
12 // omp_get_max_threads() will do middle initialization
13 int nthreads
= omp_get_max_threads();
14 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
17 int main(int argc
, char *argv
[]) {
18 const int N
= std::min(std::max(std::max(32, 4 * omp_get_max_threads()),
19 4 * omp_get_num_procs()),
20 std::numeric_limits
<int>::max());
22 std::vector
<int> data(N
);
24 // Create a new thread to initialize the OpenMP RTL. The new thread will not
25 // be taken as the "initial thread".
26 std::thread
root(dummy_root
);
28 #pragma omp parallel for num_threads(N)
29 for (unsigned i
= 0; i
< N
; ++i
) {
33 #pragma omp parallel for num_threads(N + 1)
34 for (unsigned i
= 0; i
< N
; ++i
) {
38 for (unsigned i
= 0; i
< N
; ++i
) {
39 assert(data
[i
] == 2 * i
);