1 // RUN: %libomp-compile-and-run
2 // The runtime currently does not get dependency information from GCC.
5 // Very flaky on openmp-clang-x86_64-linux-debian.
6 // https://bugs.llvm.org/show_bug.cgi?id=45397
12 #include "omp_testsuite.h"
13 #include "omp_my_sleep.h"
16 With task dependencies one can generate proxy tasks from an explicit task
17 being executed by a serial task team. The OpenMP runtime library didn't
18 expect that and tries to free the explicit task that is the parent of the
19 proxy task still working in background. It therefore has incomplete children
20 which triggers a debugging assertion.
23 // Compiler-generated code (emulation)
24 typedef intptr_t kmp_intptr_t
;
25 typedef int32_t kmp_int32
;
26 typedef uint8_t kmp_uint8
;
30 // These structs need to match the implementation within libomp, in kmp.h.
32 typedef struct ident
{
33 kmp_int32 reserved_1
; /**< might be used in Fortran; see above */
34 kmp_int32 flags
; /**< also f.flags; KMP_IDENT_xxx flags; KMP_IDENT_KMPC identifies this union member */
35 kmp_int32 reserved_2
; /**< not really used in Fortran any more; see above */
37 /* but currently used for storing region-specific ITT */
38 /* contextual information. */
39 #endif /* USE_ITT_BUILD */
40 kmp_int32 reserved_3
; /**< source[4] in Fortran, do not use for C++ */
41 char const *psource
; /**< String describing the source location.
42 The string is composed of semi-colon separated fields which describe the source file,
43 the function and a pair of line numbers that delimit the construct.
47 typedef struct kmp_depend_info
{
48 kmp_intptr_t base_addr
;
51 kmp_uint8 flag
; // flag as an unsigned char
52 struct { // flag as a set of 8 bits
64 typedef kmp_int32 (* kmp_routine_entry_t
)( kmp_int32
, struct kmp_task
* );
66 typedef struct kmp_task
{ /* GEH: Shouldn't this be aligned somehow? */
67 void * shareds
; /**< pointer to block of pointers to shared vars */
68 kmp_routine_entry_t routine
; /**< pointer to routine to call for executing task */
69 kmp_int32 part_id
; /**< part id for the task */
75 kmp_int32
__kmpc_global_thread_num ( ident_t
* );
77 __kmpc_omp_task_alloc( ident_t
*loc_ref
, kmp_int32 gtid
, kmp_int32 flags
,
78 size_t sizeof_kmp_task_t
, size_t sizeof_shareds
,
79 kmp_routine_entry_t task_entry
);
80 void __kmpc_proxy_task_completed_ooo ( kmp_task_t
*ptask
);
81 kmp_int32
__kmpc_omp_task_with_deps ( ident_t
*loc_ref
, kmp_int32 gtid
, kmp_task_t
* new_task
,
82 kmp_int32 ndeps
, kmp_depend_info_t
*dep_list
,
83 kmp_int32 ndeps_noalias
, kmp_depend_info_t
*noalias_dep_list
);
85 __kmpc_omp_task( ident_t
*loc_ref
, kmp_int32 gtid
, kmp_task_t
* new_task
);
90 void *target(void *task
)
93 __kmpc_proxy_task_completed_ooo((kmp_task_t
*) task
);
97 pthread_t target_thread
;
100 int task_entry(kmp_int32 gtid
, kmp_task_t
*task
)
102 pthread_create(&target_thread
, NULL
, &target
, task
);
110 #pragma omp taskgroup
114 #pragma omp target nowait depend(out: dep)
119 kmp_depend_info_t dep_info
= { 0 };
120 dep_info
.base_addr
= (kmp_intptr_t
) &dep
;
121 dep_info
.len
= sizeof(int);
122 // out = inout per spec and runtime expects this
123 dep_info
.flags
.in
= 1;
124 dep_info
.flags
.out
= 1;
126 kmp_int32 gtid
= __kmpc_global_thread_num(NULL
);
127 kmp_task_t
*proxy_task
= __kmpc_omp_task_alloc(NULL
,gtid
,17,sizeof(kmp_task_t
),0,&task_entry
);
128 __kmpc_omp_task_with_deps(NULL
,gtid
,proxy_task
,1,&dep_info
,0,NULL
);
130 #pragma omp task depend(in: dep)
134 #pragma omp target nowait
139 kmp_task_t
*nested_proxy_task
= __kmpc_omp_task_alloc(NULL
,gtid
,17,sizeof(kmp_task_t
),0,&task_entry
);
140 __kmpc_omp_task(NULL
,gtid
,nested_proxy_task
);
144 // only check that it didn't crash