mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-04 05:41:33 +01:00
47 lines
1.2 KiB
C
47 lines
1.2 KiB
C
/*
|
|
* @@name: icv.1c
|
|
* @@type: C
|
|
* @@compilable: yes
|
|
* @@linkable: yes
|
|
* @@expect: success
|
|
*/
|
|
#include <stdio.h>
|
|
#include <omp.h>
|
|
|
|
int main (void)
|
|
{
|
|
omp_set_nested(1);
|
|
omp_set_max_active_levels(8);
|
|
omp_set_dynamic(0);
|
|
omp_set_num_threads(2);
|
|
#pragma omp parallel
|
|
{
|
|
omp_set_num_threads(3);
|
|
|
|
#pragma omp parallel
|
|
{
|
|
omp_set_num_threads(4);
|
|
#pragma omp single
|
|
{
|
|
// The following should print:
|
|
// Inner: max_act_lev=8, num_thds=3, max_thds=4
|
|
// Inner: max_act_lev=8, num_thds=3, max_thds=4
|
|
printf ("Inner: max_act_lev=%d, num_thds=%d, max_thds=%d\n",
|
|
omp_get_max_active_levels(), omp_get_num_threads(),
|
|
omp_get_max_threads());
|
|
}
|
|
}
|
|
|
|
#pragma omp barrier
|
|
#pragma omp single
|
|
{
|
|
// The following should print:
|
|
// Outer: max_act_lev=8, num_thds=2, max_thds=3
|
|
printf ("Outer: max_act_lev=%d, num_thds=%d, max_thds=%d\n",
|
|
omp_get_max_active_levels(), omp_get_num_threads(),
|
|
omp_get_max_threads());
|
|
}
|
|
}
|
|
return 0;
|
|
}
|