LLVM OpenMP 20.0.0git
kmp_taskwait_nowait.c
Go to the documentation of this file.
1// RUN: %libomp-compile-and-run
2
3// test checks IN dep kind in depend clause on taskwait nowait
4// uses codegen emulation
5// Note: no outlined task routine used
6#include <stdio.h>
7#include <omp.h>
8// ---------------------------------------------------------------------------
9// internal data to emulate compiler codegen
10#define TIED 1
11typedef struct DEP {
12 size_t addr;
13 size_t len;
14 unsigned char flags;
16typedef struct ID {
17 int reserved_1;
18 int flags;
19 int reserved_2;
20 int reserved_3;
21 char *psource;
23typedef struct task {
24 void** shareds;
25 void* entry;
26 int part_id;
27 void* destr_thunk;
28 int priority;
29 long long device_id;
30 int f_priv;
32typedef int(*entry_t)(int, task_t*);
33
34#ifdef __cplusplus
35extern "C" {
36#endif
38task_t *__kmpc_omp_task_alloc(_id *loc, int gtid, int flags,
39 size_t sz, size_t shar, entry_t rtn);
40int __kmpc_omp_task_with_deps(_id *loc, int gtid, task_t *task, int ndeps,
41 _dep *dep_lst, int nd_noalias, _dep *noalias_l);
42#ifdef __cplusplus
43} // extern "C"
44#endif
45
46int main()
47{
48 int i1,i2,i3;
50 printf("addresses: %p %p %p\n", &i1, &i2, &i3);
51 #pragma omp parallel
52 {
53 int t = omp_get_thread_num();
54 printf("thread %d enters parallel\n", t);
55 #pragma omp single
56 {
57 #pragma omp task depend(in: i3)
58 {
59 int th = omp_get_thread_num();
60 printf("task 0 created by th %d, executed by th %d\n", t, th);
61 }
62 #pragma omp task depend(in: i2)
63 {
64 int th = omp_get_thread_num();
65 printf("task 1 created by th %d, executed by th %d\n", t, th);
66 }
67// #pragma omp taskwait depend(in: i1, i2) nowait
68 {
69 _dep sdep[2];
70 static _id loc = {0, 2, 0, 0, ";test.c;func;67;0;;"};
71 int gtid = __kmpc_global_thread_num(&loc);
72// instead of creating an empty task function we can now send NULL to runtime
73 task_t *ptr = __kmpc_omp_task_alloc(&loc, gtid, TIED,
74 sizeof(task_t), 0, NULL);
75 sdep[0].addr = (size_t)&i2;
76 sdep[0].flags = 1; // 1-in, 2-out, 3-inout, 4-mtx, 8-inoutset
77 sdep[1].addr = (size_t)&i1;
78 sdep[1].flags = 1; // in
79 __kmpc_omp_task_with_deps(&loc, gtid, ptr, 2, sdep, 0, NULL);
80 }
81 printf("single done\n");
82 }
83 }
84 printf("passed\n");
85 return 0;
86}
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d int
#define omp_set_num_threads
Definition: kmp_stub.cpp:34
int __kmpc_global_thread_num(_id *)
int(* entry_t)(int, task_t *)
struct DEP _dep
task_t * __kmpc_omp_task_alloc(_id *loc, int gtid, int flags, size_t sz, size_t shar, entry_t rtn)
int __kmpc_omp_task_with_deps(_id *loc, int gtid, task_t *task, int ndeps, _dep *dep_lst, int nd_noalias, _dep *noalias_l)
#define TIED
struct task task_t
struct ID _id
int main()
static id loc
size_t len
unsigned char flags
size_t addr
int reserved_2
char * psource
int reserved_3
int reserved_1
void * entry
void ** shareds
void * destr_thunk
long long device_id