BT_FN_VOID_CONST_PTR_SIZE, ATTR_NOTHROW_LEAF_LIST)
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_ERROR, "GOMP_error",
BT_FN_VOID_CONST_PTR_SIZE, ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST)
+DEF_GOMP_BUILTIN (BUILT_IN_GOMP_HAS_MASKED_THREAD_NUM,
+ "GOMP_has_masked_thread_num", BT_FN_BOOL_INT,
+ ATTR_CONST_NOTHROW_LEAF_LIST)
gsi_replace (gsi_p, bind, true);
gimple_bind_add_stmt (bind, stmt);
- bfn_decl = builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM);
- x = build_call_expr_loc (loc, bfn_decl, 0);
- x = build2 (EQ_EXPR, boolean_type_node, x, filter);
+ bfn_decl = builtin_decl_explicit (BUILT_IN_GOMP_HAS_MASKED_THREAD_NUM);
+ x = build_call_expr_loc (loc, bfn_decl, 1, filter);
x = build3 (COND_EXPR, void_type_node, x, NULL, build_and_jump (&lab));
tseq = NULL;
gimplify_and_add (x, &tseq);
+/* { dg-do compile } */
+/* { dg-additional-options "-fdump-tree-omplower" } */
+
void bar (void);
void
#pragma omp masked filter (x)
;
}
+
+/* { dg-final { scan-tree-dump "GOMP_has_masked_thread_num" "omplower" } } */
+/* { dg-final { scan-tree-dump-not "omp_get_thread_num" "omplower" } } */
bar(0);
}
-/* { dg-final { scan-tree-dump-times "omp_get_thread_num" 1 "omplower" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_has_masked_thread_num" 1 "omplower" } } */
bar(0);
}
-/* { dg-final { scan-tree-dump-times "omp_get_thread_num" 1 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_has_masked_thread_num" 1 "ompexp" } } */
-! { dg-additional-options "-ffree-line-length-none" }
+! { dg-do compile }
+! { dg-additional-options "-ffree-line-length-none -fdump-tree-omplower" }
+
subroutine foo (x, a)
implicit none
integer, value :: x
end do
!$omp end parallel masked taskloop simd
end subroutine
+
+! { dg-final { scan-tree-dump "GOMP_has_masked_thread_num" "omplower" } }
omp_target_memset_async;
} GOMP_6.0;
+GOMP_6.0.2 {
+ global:
+ GOMP_has_masked_thread_num;
+} GOMP_6.0.1;
+
OACC_2.0 {
global:
acc_get_num_devices;
unsigned);
extern bool GOMP_cancel (int, bool);
extern bool GOMP_cancellation_point (int);
+extern bool GOMP_has_masked_thread_num (int);
/* task.c */
gomp_team_barrier_cancel (team);
return true;
}
+
+/* Return true if the current thread number equals TID.
+ Used to implement the masked construct's filter clause. */
+
+bool
+GOMP_has_masked_thread_num (int tid)
+{
+ return tid == gomp_thread ()->ts.team_id;
+}
\f
/* The public OpenMP API for thread and team related inquiries. */