testsuite/libgomp.c/nested-3.c

Go to the documentation of this file.
00001 #include <omp.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 
00005 int
00006 main (void)
00007 {
00008   int e[3];
00009 
00010   memset (e, '\0', sizeof (e));
00011   omp_set_nested (1);
00012   omp_set_dynamic (0);
00013   if (omp_in_parallel ()
00014       || omp_get_level () != 0
00015       || omp_get_ancestor_thread_num (0) != 0
00016       || omp_get_ancestor_thread_num (-1) != -1
00017       || omp_get_ancestor_thread_num (1) != -1
00018       || omp_get_team_size (0) != 1
00019       || omp_get_team_size (-1) != -1
00020       || omp_get_team_size (1) != -1
00021       || omp_get_active_level () != 0)
00022     abort ();
00023 #pragma omp parallel num_threads (4)
00024   {
00025     int tn1 = omp_get_thread_num ();
00026     if (omp_in_parallel () != 1
00027     || omp_get_num_threads () != 4
00028     || tn1 >= 4 || tn1 < 0
00029     || omp_get_level () != 1
00030     || omp_get_ancestor_thread_num (0) != 0
00031     || omp_get_ancestor_thread_num (1) != tn1
00032     || omp_get_ancestor_thread_num (-1) != -1
00033     || omp_get_ancestor_thread_num (2) != -1
00034     || omp_get_team_size (0) != 1
00035     || omp_get_team_size (1) != omp_get_num_threads ()
00036     || omp_get_team_size (-1) != -1
00037     || omp_get_team_size (2) != -1
00038     || omp_get_active_level () != 1)
00039       #pragma omp atomic
00040     e[0] += 1;
00041     #pragma omp parallel if (0) num_threads(5) firstprivate(tn1)
00042     {
00043       int tn2 = omp_get_thread_num ();
00044       if (omp_in_parallel () != 1
00045       || omp_get_num_threads () != 1
00046       || tn2 != 0
00047       || omp_get_level () != 2
00048       || omp_get_ancestor_thread_num (0) != 0
00049       || omp_get_ancestor_thread_num (1) != tn1
00050       || omp_get_ancestor_thread_num (2) != tn2
00051       || omp_get_ancestor_thread_num (-1) != -1
00052       || omp_get_ancestor_thread_num (3) != -1
00053       || omp_get_team_size (0) != 1
00054       || omp_get_team_size (1) != 4
00055       || omp_get_team_size (2) != 1
00056       || omp_get_team_size (-1) != -1
00057       || omp_get_team_size (3) != -1
00058       || omp_get_active_level () != 1)
00059     #pragma omp atomic
00060       e[1] += 1;
00061       #pragma omp parallel num_threads(2) firstprivate(tn1, tn2)
00062       {
00063     int tn3 = omp_get_thread_num ();
00064     if (omp_in_parallel () != 1
00065         || omp_get_num_threads () != 2
00066         || tn3 > 1 || tn3 < 0
00067         || omp_get_level () != 3
00068         || omp_get_ancestor_thread_num (0) != 0
00069         || omp_get_ancestor_thread_num (1) != tn1
00070         || omp_get_ancestor_thread_num (2) != tn2
00071         || omp_get_ancestor_thread_num (3) != tn3
00072         || omp_get_ancestor_thread_num (-1) != -1
00073         || omp_get_ancestor_thread_num (4) != -1
00074         || omp_get_team_size (0) != 1
00075         || omp_get_team_size (1) != 4
00076         || omp_get_team_size (2) != 1
00077         || omp_get_team_size (3) != 2
00078         || omp_get_team_size (-1) != -1
00079         || omp_get_team_size (4) != -1
00080         || omp_get_active_level () != 2)
00081       #pragma omp atomic
00082         e[2] += 1;
00083       }
00084     }
00085   }
00086   if (e[0] || e[1] || e[2])
00087     abort ();
00088   return 0;
00089 }

Generated on Fri Apr 5 05:38:10 2013 for Libgomp by  doxygen 1.4.7