
The teams construct only permits omp_get_num_teams and omp_get_team_num as API call in strictly nested regions - check for it. Additionally, for Fortran, using DECL_NAME does not show the mangled name, hence, DECL_ASSEMBLER_NAME had to be used to. Finally, 'target device(ancestor:1)' wrongly rejected non-API calls as well. PR middle-end/102972 gcc/ChangeLog: * omp-low.c (omp_runtime_api_call): Use DECL_ASSEMBLER_NAME to get internal Fortran name; new permit_num_teams arg to permit omp_get_num_teams and omp_get_team_num. (scan_omp_1_stmt): Update call to it, add missing call for reverse offload, and check for strictly nested API calls in teams. gcc/testsuite/ChangeLog: * c-c++-common/gomp/target-device-ancestor-3.c: Add non-API routine test. * gfortran.dg/gomp/order-6.f90: Add missing bind(C). * c-c++-common/gomp/teams-3.c: New test. * gfortran.dg/gomp/teams-3.f90: New test. * gfortran.dg/gomp/teams-4.f90: New test. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/icv-3.c: Nest API calls inside parallel construct. * testsuite/libgomp.c-c++-common/icv-4.c: Likewise. * testsuite/libgomp.c/target-3.c: Likewise. * testsuite/libgomp.c/target-5.c: Likewise. * testsuite/libgomp.c/target-6.c: Likewise. * testsuite/libgomp.c/target-teams-1.c: Likewise. * testsuite/libgomp.c/teams-1.c: Likewise. * testsuite/libgomp.c/thread-limit-2.c: Likewise. * testsuite/libgomp.c/thread-limit-3.c: Likewise. * testsuite/libgomp.c/thread-limit-4.c: Likewise. * testsuite/libgomp.c/thread-limit-5.c: Likewise. * testsuite/libgomp.fortran/icv-3.f90: Likewise. * testsuite/libgomp.fortran/icv-4.f90: Likewise. * testsuite/libgomp.fortran/teams1.f90: Likewise.
86 lines
1.9 KiB
C
86 lines
1.9 KiB
C
/* { dg-additional-options "-Wno-deprecated-declarations" } */
|
|
|
|
#include <omp.h>
|
|
#include <stdlib.h>
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int d_o = omp_get_dynamic ();
|
|
int n_o = omp_get_nested ();
|
|
omp_sched_t s_o;
|
|
int c_o;
|
|
omp_get_schedule (&s_o, &c_o);
|
|
int m_o = omp_get_max_threads ();
|
|
omp_set_dynamic (1);
|
|
omp_set_nested (1);
|
|
omp_set_schedule (omp_sched_static, 2);
|
|
omp_set_num_threads (4);
|
|
int d = omp_get_dynamic ();
|
|
int n = omp_get_nested ();
|
|
omp_sched_t s;
|
|
int c;
|
|
omp_get_schedule (&s, &c);
|
|
int m = omp_get_max_threads ();
|
|
if (!omp_is_initial_device ())
|
|
abort ();
|
|
#pragma omp target if (0)
|
|
{
|
|
omp_sched_t s_c;
|
|
int c_c;
|
|
omp_get_schedule (&s_c, &c_c);
|
|
if (d_o != omp_get_dynamic ()
|
|
|| n_o != omp_get_nested ()
|
|
|| s_o != s_c
|
|
|| c_o != c_c
|
|
|| m_o != omp_get_max_threads ())
|
|
abort ();
|
|
omp_set_dynamic (0);
|
|
omp_set_nested (0);
|
|
omp_set_schedule (omp_sched_dynamic, 4);
|
|
omp_set_num_threads (2);
|
|
if (!omp_is_initial_device ())
|
|
abort ();
|
|
}
|
|
if (!omp_is_initial_device ())
|
|
abort ();
|
|
omp_sched_t s_c;
|
|
int c_c;
|
|
omp_get_schedule (&s_c, &c_c);
|
|
if (d != omp_get_dynamic ()
|
|
|| n != omp_get_nested ()
|
|
|| s != s_c
|
|
|| c != c_c
|
|
|| m != omp_get_max_threads ())
|
|
abort ();
|
|
#pragma omp target if (0)
|
|
#pragma omp teams
|
|
#pragma omp parallel if(0)
|
|
{
|
|
omp_sched_t s_c;
|
|
int c_c;
|
|
omp_get_schedule (&s_c, &c_c);
|
|
if (d_o != omp_get_dynamic ()
|
|
|| n_o != omp_get_nested ()
|
|
|| s_o != s_c
|
|
|| c_o != c_c
|
|
|| m_o != omp_get_max_threads ())
|
|
abort ();
|
|
omp_set_dynamic (0);
|
|
omp_set_nested (0);
|
|
omp_set_schedule (omp_sched_dynamic, 4);
|
|
omp_set_num_threads (2);
|
|
if (!omp_is_initial_device ())
|
|
abort ();
|
|
}
|
|
if (!omp_is_initial_device ())
|
|
abort ();
|
|
omp_get_schedule (&s_c, &c_c);
|
|
if (d != omp_get_dynamic ()
|
|
|| n != omp_get_nested ()
|
|
|| s != s_c
|
|
|| c != c_c
|
|
|| m != omp_get_max_threads ())
|
|
abort ();
|
|
return 0;
|
|
}
|