[OPENMP50]Codegen for reduction clauses with 'task' modifier.
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 24 Apr 2020 13:56:29 +0000 (09:56 -0400)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 1 May 2020 15:40:27 +0000 (11:40 -0400)
commit8c2f4e0e855cd41c412cb1c824960a8adf938b8f
tree9aed543b2037559325d579782a213a69b65ff5a9
parent07d448135f328d040e51f49541467004643525ea
[OPENMP50]Codegen for reduction clauses with 'task' modifier.

Summary:
Added codegen for reduction clause with task modifier.
```
  #pragma omp ... reduction(task, +: a)
  {
  #pragma omp ... in_reduction(+: a)
  }
```
is translated into something like this:
```
  #pragma omp ... reduction(+:a)
  {
    struct red_input_t {
      void *reduce_shar;
      void *reduce_orig;
      size_t reduce_size;
      void *reduce_init;
      void *reduce_fini;
      void *reduce_comb;
      unsigned flags;
    } r_var;
    r_var.reduce_shar = &a;
    r_var.reduce_orig = &original a;
    r_var.reduce_size = sizeof(a);
    r_var.reduce_init = [](void* l,void*){return *(int*)l=0;};
    r_var.reduce_fini = nullptr;
    r_var.reduce_comb = [](void* l,void* r){return *(int*)l += *(int)r;};
    void *tg = __kmpc_taskred_modifier_init(<loc_addr>,<gtid>,
      <flag - 0 for parallel, 1 for worksharing>,
      <1 - number of reduction elements>,
      &r_var);
    {
    #pragma omp ... in_reduction(+: a) firstprivate(tg)
    ...
    }
    __kmpc_task_reduction_modifier_fini(<loc_addr>,<gtid>,
      <flag - 0 for parallel, 1 for worksharing>);
  }
```

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, jfb, cfe-commits, caomhin

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79034
19 files changed:
clang/include/clang/AST/StmtOpenMP.h
clang/lib/AST/StmtOpenMP.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/for_reduction_task_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/parallel_reduction_task_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/sections_reduction_task_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp [new file with mode: 0644]