1// REQUIRES: ompx_taskgraph
2// RUN: %libomp-cxx-compile-and-run
3#include <iostream>
4#include <cassert>
5#define NT 100
6
7// Compiler-generated code (emulation)
8typedef struct ident {
9 void* dummy;
10} ident_t;
11
12
13#ifdef __cplusplus
14extern "C" {
15 int __kmpc_global_thread_num(ident_t *);
16 int __kmpc_start_record_task(ident_t *, int, int, int);
17 void __kmpc_end_record_task(ident_t *, int, int , int);
18}
19#endif
20
21void func(int *num_exec) {
22 (*num_exec)++;
23}
24
25int main() {
26 int num_exec = 0;
27 int num_tasks = 0;
28 int x=0;
29 #pragma omp parallel
30 #pragma omp single
31 for (int iter = 0; iter < NT; ++iter) {
32 int gtid = __kmpc_global_thread_num(nullptr);
33 int res = __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */ 0, /* tdg_id */0);
34 if (res) {
35 num_tasks++;
36 #pragma omp task
37 func(num_exec: &num_exec);
38 }
39 __kmpc_end_record_task(nullptr, gtid, /* kmp_tdg_flags */0, /* tdg_id */0);
40 }
41
42 assert(num_tasks==1);
43 assert(num_exec==NT);
44
45 std::cout << "Passed" << std::endl;
46 return 0;
47}
48// CHECK: Passed
49

source code of openmp/runtime/test/tasking/omp_record_replay.cpp