brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 69ad980 Raw
49 lines · cpp
1// REQUIRES: ompx_taskgraph2// RUN: %libomp-cxx-compile-and-run3#include <iostream>4#include <cassert>5#define NT 1006 7// Compiler-generated code (emulation)8typedef struct ident {9    void* dummy;10} ident_t;11 12 13#ifdef __cplusplus14extern "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#endif20 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 parallel30  #pragma omp single31  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);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: Passed49