]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Add barrier kind to GOMP_barrier and GOMP_barrier_cancel
authorPaul-Antoine Arras <parras@baylibre.com>
Thu, 18 Jun 2026 16:40:22 +0000 (18:40 +0200)
committerPaul-Antoine Arras <parras@baylibre.com>
Wed, 24 Jun 2026 13:24:42 +0000 (15:24 +0200)
GOMP_barrier is called for at least three distinct purposes: implicit
barriers at the end of parallel/teams regions, implicit barriers at the
end of worksharing constructs, and explicit `#pragma omp barrier'
directives. OMPT requires distinguishing these in its sync-region
callbacks.

Create new, semantically equivalent functions GOMP_barrier_ext and
GOMP_barrier_cancel_ext with an integer `kind' parameter. Update all compiler
call sites to pass the appropriate constant. Preserve now unused functions
GOMP_barrier and GOMP_barrier_cancel for backward compatibility.

The `kind' parameter is accepted but not yet acted upon in libgomp; it
is reserved for future OMPT instrumentation.

gcc/c-family/ChangeLog:

* c-omp.cc (c_finish_omp_barrier): Pass GOMP_BARRIER_EXPLICIT to
GOMP_barrier_ext.

gcc/cp/ChangeLog:

* semantics.cc (finish_omp_barrier): Push GOMP_BARRIER_EXPLICIT
onto the argument vector.

gcc/fortran/ChangeLog:

* trans-openmp.cc (gfc_trans_omp_barrier): Pass GOMP_BARRIER_EXPLICIT
to GOMP_barrier_ext.

gcc/ChangeLog:

* omp-builtins.def (BUILT_IN_GOMP_BARRIER): Change function to
GOMP_barrier_ext and type to BT_FN_VOID_INT.
(BUILT_IN_GOMP_BARRIER_CANCEL): Change function to
GOMP_barrier_cancel_ext and type to BT_FN_VOID_INT.
* omp-expand.cc (expand_omp_for_static_nochunk): Pass
GOMP_BARRIER_IMPLICIT_WORKSHARE to omp_build_barrier.
(expand_omp_for_static_chunk): Likewise.
(expand_omp_single): Likewise.
* omp-general.cc (omp_build_barrier): Add kind parameter; pass it
to GOMP_barrier_ext or GOMP_barrier_cancel_ext.
* omp-general.h (omp_build_barrier): Update declaration to add
kind parameter.
* omp-low.cc (lower_rec_input_clauses): Determine barrier kind from
the enclosing gimple statement code and pass it to omp_build_barrier.
(lower_omp_for_scan): Pass GOMP_BARRIER_IMPLICIT_WORKSHARE to
omp_build_barrier.

include/ChangeLog:

* gomp-constants.h (GOMP_BARRIER_IMPLICIT_PARALLEL): New macro.
(GOMP_BARRIER_IMPLICIT_WORKSHARE): New macro.
(GOMP_BARRIER_EXPLICIT): New macro.

libgomp/ChangeLog:

* barrier.c (GOMP_barrier_ext): New function.
(GOMP_barrier_cancel_ext): Likewise.
* libgomp_g.h (GOMP_barrier_ext): Declare.
(GOMP_barrier_cancel_ext): Likewise.
* libgomp.map (GOMP_6.0.2): Add GOMP_barrier_ext and
GOMP_barrier_cancel_ext.
* testsuite/libgomp.c/barrier-1.c: Update GOMP_barrier_ext calls to pass
GOMP_BARRIER_EXPLICIT.

gcc/testsuite/ChangeLog:

* g++.dg/gomp/barrier-1.C: Update scan dump.
* g++.dg/gomp/tpl-barrier-1.C: Likewise.
* gcc.dg/gomp/barrier-1.c: Likewise.
* c-c++-common/gomp/implicit-barrier-1.c: New test.
* gfortran.dg/gomp/lastprivate-allocatable-barrier-1.f90: New test.

18 files changed:
gcc/c-family/c-omp.cc
gcc/cp/semantics.cc
gcc/fortran/trans-openmp.cc
gcc/omp-builtins.def
gcc/omp-expand.cc
gcc/omp-general.cc
gcc/omp-general.h
gcc/omp-low.cc
gcc/testsuite/c-c++-common/gomp/implicit-barrier-1.c [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/barrier-1.C
gcc/testsuite/g++.dg/gomp/tpl-barrier-1.C
gcc/testsuite/gcc.dg/gomp/barrier-1.c
gcc/testsuite/gfortran.dg/gomp/lastprivate-allocatable-barrier-1.f90 [new file with mode: 0644]
include/gomp-constants.h
libgomp/barrier.c
libgomp/libgomp.map
libgomp/libgomp_g.h
libgomp/testsuite/libgomp.c/barrier-1.c

index 181dfb3c7b7be7c739627d831bcf8c1fa989e7bc..006e54d1e3d985553454eb435446d9db5824ceaa 100644 (file)
@@ -175,7 +175,9 @@ c_finish_omp_barrier (location_t loc)
   tree x;
 
   x = builtin_decl_explicit (BUILT_IN_GOMP_BARRIER);
-  x = build_call_expr_loc (loc, x, 0);
+  x = build_call_expr_loc (loc, x, 1,
+                          build_int_cst (integer_type_node,
+                                         GOMP_BARRIER_EXPLICIT));
   add_stmt (x);
 }
 
index 684c6550345bc11b7520302ce804368c9cb06401..3a7e19c190a4de6215aeda6c64c9094fba1475ca 100644 (file)
@@ -12547,6 +12547,7 @@ finish_omp_barrier (void)
 {
   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_BARRIER);
   releasing_vec vec;
+  vec->quick_push (build_int_cst (integer_type_node, GOMP_BARRIER_EXPLICIT));
   tree stmt = finish_call_expr (fn, &vec, false, false, tf_warning_or_error);
   finish_expr_stmt (stmt);
 }
index 0f368d3d805e541c0aa806207fbe424e54452473..8d5842685a55f8b7e5ea5271e7a49eb448093513 100644 (file)
@@ -6977,7 +6977,9 @@ static tree
 gfc_trans_omp_barrier (void)
 {
   tree decl = builtin_decl_explicit (BUILT_IN_GOMP_BARRIER);
-  return build_call_expr_loc (input_location, decl, 0);
+  return build_call_expr_loc (input_location, decl, 1,
+                             build_int_cst (integer_type_node,
+                                            GOMP_BARRIER_EXPLICIT));
 }
 
 static tree
index 82736e773407b6c9bdd7b01b38ee0bfc273bc811..0a9dde8f6187d2b5dff8bb1177998f3ab72a0280 100644 (file)
@@ -98,10 +98,10 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_ATOMIC_START, "GOMP_atomic_start",
                  BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_ATOMIC_END, "GOMP_atomic_end",
                  BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
-DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BARRIER, "GOMP_barrier",
-                 BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
-DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BARRIER_CANCEL, "GOMP_barrier_cancel",
-                 BT_FN_BOOL, ATTR_NOTHROW_LEAF_LIST)
+DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BARRIER, "GOMP_barrier_ext", BT_FN_VOID_INT,
+                 ATTR_NOTHROW_LEAF_LIST)
+DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BARRIER_CANCEL, "GOMP_barrier_cancel_ext",
+                 BT_FN_BOOL_INT, ATTR_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_TASKWAIT, "GOMP_taskwait",
                  BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_TASKWAIT_DEPEND, "GOMP_taskwait_depend",
index de8889a96496f016e6dca7db103469c8c5d544bc..3d799d2803295dada49c4e871a76590eff2db7b8 100644 (file)
@@ -5602,7 +5602,10 @@ expand_omp_for_static_nochunk (struct omp_region *region,
          gsi_insert_after (&gsi, g, GSI_SAME_STMT);
        }
       else
-       gsi_insert_after (&gsi, omp_build_barrier (t), GSI_SAME_STMT);
+       gsi_insert_after (&gsi,
+                         omp_build_barrier (t,
+                                            GOMP_BARRIER_IMPLICIT_WORKSHARE),
+                         GSI_SAME_STMT);
     }
   else if ((fd->have_pointer_condtemp || fd->have_scantemp)
           && !fd->have_nonctrl_scantemp)
@@ -6324,7 +6327,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
          gsi_insert_after (&gsi, g, GSI_SAME_STMT);
        }
       else
-       gsi_insert_after (&gsi, omp_build_barrier (t), GSI_SAME_STMT);
+       gsi_insert_after (&gsi,
+                         omp_build_barrier (t,
+                                            GOMP_BARRIER_IMPLICIT_WORKSHARE),
+                         GSI_SAME_STMT);
     }
   else if (fd->have_pointer_condtemp)
     {
@@ -8702,7 +8708,9 @@ expand_omp_single (struct omp_region *region)
   if (!gimple_omp_return_nowait_p (gsi_stmt (si)))
     {
       tree t = gimple_omp_return_lhs (gsi_stmt (si));
-      gsi_insert_after (&si, omp_build_barrier (t), GSI_SAME_STMT);
+      gsi_insert_after (&si,
+                       omp_build_barrier (t, GOMP_BARRIER_IMPLICIT_WORKSHARE),
+                       GSI_SAME_STMT);
     }
   gsi_remove (&si, true);
   single_succ_edge (exit_bb)->flags = EDGE_FALLTHRU;
index d0307aeba88bee08c616c3b22c54759797220b7e..564fe858cdd48cc6a274cecb39e094081dcf6a92 100644 (file)
@@ -920,11 +920,12 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
 /* Build a call to GOMP_barrier.  */
 
 gimple *
-omp_build_barrier (tree lhs)
+omp_build_barrier (tree lhs, int kind)
 {
   tree fndecl = builtin_decl_explicit (lhs ? BUILT_IN_GOMP_BARRIER_CANCEL
                                           : BUILT_IN_GOMP_BARRIER);
-  gcall *g = gimple_build_call (fndecl, 0);
+  gcall *g = gimple_build_call (fndecl, 1,
+                               build_int_cst (integer_type_node, kind));
   if (lhs)
     gimple_call_set_lhs (g, lhs);
   return g;
index a5126269650c8f8b4415f1362e6e63b61130e0bc..ebfe16d0a4fead546b94fbd5bd8aae759293e0a8 100644 (file)
@@ -189,7 +189,7 @@ extern void omp_adjust_for_condition (location_t loc, enum tree_code *cond_code,
 extern tree omp_get_for_step_from_incr (location_t loc, tree incr);
 extern void omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
                                  struct omp_for_data_loop *loops);
-extern gimple *omp_build_barrier (tree lhs);
+extern gimple *omp_build_barrier (tree lhs, int kind);
 extern tree find_combined_omp_for (tree *, int *, void *);
 extern poly_uint64 omp_max_vf (bool);
 extern int omp_max_simt_vf (void);
index 9ac0da173a514f7d5bc206a52ee8d7cce31cd488..30a4d02f2e20f4a60213c06e9f81a46604f0bce3 100644 (file)
@@ -7043,7 +7043,25 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
       if (!is_task_ctx (ctx)
          && (gimple_code (ctx->stmt) != GIMPLE_OMP_FOR
              || gimple_omp_for_kind (ctx->stmt) == GF_OMP_FOR_KIND_FOR))
-       gimple_seq_add_stmt (ilist, omp_build_barrier (NULL_TREE));
+       {
+         int barrier_kind;
+         switch (gimple_code (ctx->stmt))
+           {
+           case GIMPLE_OMP_SECTIONS:
+           case GIMPLE_OMP_SCOPE:
+           case GIMPLE_OMP_FOR:
+             barrier_kind = GOMP_BARRIER_IMPLICIT_WORKSHARE;
+             break;
+           case GIMPLE_OMP_PARALLEL:
+           case GIMPLE_OMP_TEAMS:
+             barrier_kind = GOMP_BARRIER_IMPLICIT_PARALLEL;
+             break;
+           default:
+             gcc_unreachable ();
+           }
+         gimple_seq_add_stmt (ilist,
+                              omp_build_barrier (NULL_TREE, barrier_kind));
+       }
     }
 
   /* If max_vf is non-zero, then we can use only a vectorization factor
@@ -11477,7 +11495,7 @@ lower_omp_for_scan (gimple_seq *body_p, gimple_seq *dlist, gomp_for *stmt,
   g = gimple_build_label (lab1);
   gimple_seq_add_stmt (body_p, g);
 
-  g = omp_build_barrier (NULL);
+  g = omp_build_barrier (NULL, GOMP_BARRIER_IMPLICIT_WORKSHARE);
   gimple_seq_add_stmt (body_p, g);
 
   tree down = create_tmp_var (unsigned_type_node);
@@ -11594,7 +11612,7 @@ lower_omp_for_scan (gimple_seq *body_p, gimple_seq *dlist, gomp_for *stmt,
   g = gimple_build_label (lab12);
   gimple_seq_add_stmt (body_p, g);
 
-  g = omp_build_barrier (NULL);
+  g = omp_build_barrier (NULL, GOMP_BARRIER_IMPLICIT_WORKSHARE);
   gimple_seq_add_stmt (body_p, g);
 
   g = gimple_build_cond (NE_EXPR, k, build_zero_cst (unsigned_type_node),
diff --git a/gcc/testsuite/c-c++-common/gomp/implicit-barrier-1.c b/gcc/testsuite/c-c++-common/gomp/implicit-barrier-1.c
new file mode 100644 (file)
index 0000000..d53b424
--- /dev/null
@@ -0,0 +1,102 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fdump-tree-ompexp" } */
+
+/* Check that implicit barriers are emitted with the correct kind.  */
+
+void body (void);
+void bar (int);
+void foo (int);
+
+/* OMP for construct with static schedule (with and without chunk) -> workshare
+   barrier.  */
+void wfor (int n) {
+  int i;
+  #pragma omp for schedule(static)
+  for (i = 0; i < n; i++) bar (i);
+  #pragma omp for schedule(static, 4)
+  for (i = 0; i < n; i++) bar (i);
+}
+
+/* OMP for construct with inscan reduction -> workshare barrier.  */
+int r;
+void wfor_scan (int n)
+{
+  int i;
+  #pragma omp for reduction(inscan, + : r) private(i)
+  for (i = 0; i < n; i = i + 1)
+    {
+      {
+       bar (r);
+      }
+      #pragma omp scan inclusive(r)
+      {
+       foo (r);
+      }
+    }
+}
+
+/* OMP sections construct with firstprivate and lastprivate clauses -> workshare
+   barrier.  */
+int a;
+int wsections (void) {
+  #pragma omp sections firstprivate(a) lastprivate(a)
+  { foo (a); }
+  return a;
+}
+
+/* parallel with a copyin variable passed by reference (an aggregate, so
+   use_pointer_for_field is true) -> copyin_by_ref -> parallel barrier.  */
+int tp[64];
+#pragma omp threadprivate (tp)
+void pcopyin (void) {
+  #pragma omp parallel copyin(tp)
+  body ();
+}
+
+/* UDR whose initializer references omp_orig, used on a (non-task) parallel
+   construct -> reduction_omp_orig_ref -> parallel barrier.  */
+struct S { int s; };
+void combine (struct S *out, struct S *in);
+struct S init_from_orig (struct S *orig);
+void use (struct S *);
+
+#pragma omp declare reduction (+: struct S: combine (&omp_out, &omp_in)) \
+       initializer (omp_priv = init_from_orig (&omp_orig))
+
+void preduction_orig (struct S s) {
+  #pragma omp parallel reduction (+: s)
+  use (&s);
+}
+
+/* Same omp_orig UDR on a teams construct -> parallel barrier.  */
+void treduction_orig (struct S s) {
+  #pragma omp teams reduction (+: s)
+  use (&s);
+}
+
+/* Same omp_orig UDR on a scope construct -> workshare barrier.  */
+struct S gs;
+void sreduction_orig (void) {
+  #pragma omp parallel
+  #pragma omp scope reduction (+: gs)
+  use (&gs);
+}
+
+/* OMP single construct (without nowait) -> workshare barrier.  */
+void wsingle (void) {
+  #pragma omp single
+  body ();
+}
+
+/* OMP scope construct (without nowait) -> workshare barrier.  */
+void wscope (void) {
+  #pragma omp scope
+  body ();
+}
+
+/* GOMP_BARRIER_IMPLICIT_PARALLEL (0): pcopyin, preduction_orig,
+   treduction_orig.  */
+/* { dg-final { scan-tree-dump-times "GOMP_barrier_ext \\(0\\)" 3 "ompexp" } } */
+/* GOMP_BARRIER_IMPLICIT_WORKSHARE (1): wfor (x2), wfor_scan (x2), wsections,
+   sreduction_orig, wsingle, wscope.  */
+/* { dg-final { scan-tree-dump-times "GOMP_barrier_ext \\(1\\)" 8 "ompexp" } } */
index 55f3035193eccac932cb4e2082435c92810b7545..a601d85669f535fadc1c41d3654d3f0d1c53f4cb 100644 (file)
@@ -14,4 +14,4 @@ void f2(bool p)
     }
 }
 
-/* { dg-final { scan-tree-dump-times "GOMP_barrier" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_barrier_ext \\(2\\)" 2 "gimple" } } */
index b45cb1ee5cca07d865e4030473ea8176d67c0abd..f198cddb556837ce01620ae3a1bbe1d9187a2486 100644 (file)
@@ -21,4 +21,4 @@ void f3 ()
   f2<0> (true);
 }
 
-// { dg-final { scan-tree-dump-times "GOMP_barrier" 2 "gimple" } }
+// { dg-final { scan-tree-dump-times "GOMP_barrier_ext" 2 "gimple" } }
index 42c70e91163b153e07b113f7443ad52ccbeffb92..be874d38503b761f816441bea1d771f96de0e589 100644 (file)
@@ -14,4 +14,4 @@ void f2(_Bool p)
     }
 }
 
-/* { dg-final { scan-tree-dump-times "GOMP_barrier" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_barrier_ext \\(2\\)" 2 "gimple" } } */
diff --git a/gcc/testsuite/gfortran.dg/gomp/lastprivate-allocatable-barrier-1.f90 b/gcc/testsuite/gfortran.dg/gomp/lastprivate-allocatable-barrier-1.f90
new file mode 100644 (file)
index 0000000..48499f6
--- /dev/null
@@ -0,0 +1,33 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-omplower" }
+
+! A lastprivate allocatable (without a corresponding firstprivate) needs an
+! outer-variable reference (gfc_omp_private_outer_ref is true), which makes
+! lower_rec_input_clauses emit the implicit barrier.  The barrier kind
+! depends on the construct the clause ends up on:
+!   - combined "parallel do"     -> GOMP_BARRIER_IMPLICIT_PARALLEL  (0)
+!   - "do" enclosed in a "parallel" -> GOMP_BARRIER_IMPLICIT_WORKSHARE (1)
+
+subroutine parallel_case
+  integer, allocatable :: a(:)
+  integer :: i
+  !$omp parallel do lastprivate(a)
+  do i = 1, 1
+     a = [i]
+  end do
+end subroutine parallel_case
+
+subroutine workshare_case
+  integer, allocatable :: a(:)
+  integer :: i
+  !$omp parallel
+  !$omp do lastprivate(a)
+  do i = 1, 1
+     a = [i]
+  end do
+  !$omp end do
+  !$omp end parallel
+end subroutine workshare_case
+
+! { dg-final { scan-tree-dump-times "GOMP_barrier_ext \\(0\\)" 1 "omplower" } }
+! { dg-final { scan-tree-dump-times "GOMP_barrier_ext \\(1\\)" 1 "omplower" } }
index def838a949d45c72f766993c210a0a354a22aeb1..32bdedc9c4a8cbbd7fdb2717b6cd03cf1e0e5beb 100644 (file)
@@ -435,4 +435,10 @@ enum gomp_map_kind
 /* Identifiers of device-specific target arguments.  */
 #define GOMP_TARGET_ARG_HSA_KERNEL_ATTRIBUTES  (1 << 8)
 
+/* GOMP_barrier{,_cancel}_ext argument.
+   TODO turn this into an enum?  */
+#define GOMP_BARRIER_IMPLICIT_PARALLEL 0
+#define GOMP_BARRIER_IMPLICIT_WORKSHARE 1
+#define GOMP_BARRIER_EXPLICIT 2
+
 #endif
index 3a6037e43552eb755f21f3b8a0b0f2a3239f7175..d11fd710b19349cd7165b876b2b52dcaf45ce397 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "libgomp.h"
 
+/* GOMP_barrier is no longer called by new code; it is only kept for
+   backward compatibility. New code uses GOMP_barrier_ext.  */
 
 void
 GOMP_barrier (void)
@@ -41,6 +43,22 @@ GOMP_barrier (void)
   gomp_team_barrier_wait (&team->barrier);
 }
 
+void
+GOMP_barrier_ext (int kind __attribute__ ((unused)))
+{
+  struct gomp_thread *thr = gomp_thread ();
+  struct gomp_team *team = thr->ts.team;
+
+  /* It is legal to have orphaned barriers.  */
+  if (team == NULL)
+    return;
+
+  gomp_team_barrier_wait (&team->barrier);
+}
+
+/* GOMP_barrier_cancel is no longer called by new code; it is only kept for
+   backward compatibility. New code uses GOMP_barrier_cancel_ext.  */
+
 bool
 GOMP_barrier_cancel (void)
 {
@@ -52,3 +70,15 @@ GOMP_barrier_cancel (void)
      never have an orphaned cancellable barrier.  */
   return gomp_team_barrier_wait_cancel (&team->barrier);
 }
+
+bool
+GOMP_barrier_cancel_ext (int kind __attribute__ ((unused)))
+{
+  struct gomp_thread *thr = gomp_thread ();
+  struct gomp_team *team = thr->ts.team;
+
+  /* The compiler transforms to barrier_cancel when it sees that the
+     barrier is within a construct that can cancel.  Thus we should
+     never have an orphaned cancellable barrier.  */
+  return gomp_team_barrier_wait_cancel (&team->barrier);
+}
index 4aa518ecdae72e567a803d1a51bb61e951918bb4..92ef5c298f4d9d6ee5e8dfc4b5c7d4ae74dc6fc4 100644 (file)
@@ -487,6 +487,8 @@ GOMP_6.0.2 {
        GOMP_has_masked_thread_num;
        GOMP_loop_static_worksharing;
        GOMP_distribute_static_worksharing;
+       GOMP_barrier_ext;
+       GOMP_barrier_cancel_ext;
 } GOMP_6.0.1;
 
 OACC_2.0 {
index 6dc1fd46fcea531b084c82cfc0aeca243e8f51f5..89ed7b3462e33afe8f77ccbe5eefc7c55decea1e 100644 (file)
@@ -41,7 +41,9 @@ extern void GOMP_atomic_end (void);
 /* barrier.c */
 
 extern void GOMP_barrier (void);
+extern void GOMP_barrier_ext (int);
 extern bool GOMP_barrier_cancel (void);
+extern bool GOMP_barrier_cancel_ext (int);
 
 /* critical.c */
 
index 1f8d1f0d3f987410a7df865d45167a67e2484636..1fe678a0a0932f7a5ea4c4f81d701e88d944a18d 100644 (file)
@@ -5,7 +5,7 @@
 #include <unistd.h>
 #include <assert.h>
 #include "libgomp_g.h"
-
+#include <gomp-constants.h>
 
 struct timeval stamps[3][3];
 
@@ -17,7 +17,7 @@ static void function(void *dummy)
   if (iam == 0)
     usleep (10);
 
-  GOMP_barrier ();
+  GOMP_barrier_ext (GOMP_BARRIER_EXPLICIT);
 
   if (iam == 0)
     {
@@ -25,8 +25,8 @@ static void function(void *dummy)
       usleep (10);
     }
 
-  GOMP_barrier ();
-  
+  GOMP_barrier_ext (GOMP_BARRIER_EXPLICIT);
+
   gettimeofday (&stamps[iam][2], NULL);
 }