[all-commits] [llvm/llvm-project] 738bab: [OPENMP]Add support for allocate vars in untied ta...

Alexey Bataev via All-commits all-commits at lists.llvm.org
Tue Sep 15 11:01:19 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 738bab743b5c6cfcf1a1feb116de9e35a3f1e326
      https://github.com/llvm/llvm-project/commit/738bab743b5c6cfcf1a1feb116de9e35a3f1e326
  Author: Alexey Bataev <a.bataev at hotmail.com>
  Date:   2020-09-15 (Tue, 15 Sep 2020)

  Changed paths:
    M clang/lib/CodeGen/CGOpenMPRuntime.cpp
    M clang/lib/CodeGen/CGOpenMPRuntime.h
    M clang/lib/CodeGen/CGStmtOpenMP.cpp
    M clang/test/OpenMP/allocate_codegen.cpp
    M clang/test/OpenMP/for_lastprivate_codegen.cpp
    M clang/test/OpenMP/for_linear_codegen.cpp
    M clang/test/OpenMP/for_reduction_codegen_UDR.cpp
    M clang/test/OpenMP/parallel_firstprivate_codegen.cpp
    M clang/test/OpenMP/parallel_private_codegen.cpp
    M clang/test/OpenMP/task_codegen.cpp

  Log Message:
  -----------
  [OPENMP]Add support for allocate vars in untied tasks.

Local vars, marked with pragma allocate, mustbe allocate by the call of
the runtime function and cannot be allocated as other local variables.
Instead, we allocate a space for the pointer in private record and store
the address, returned by kmpc_alloc call in this pointer.
So, for untied tasks

```
 #pragma omp task untied
 {
   S s;
    #pragma omp allocate(s) allocator(allocator)
   s = x;
 }
```
compiler generates something like this:
```
struct task_with_privates {
  S *ptr;
};

void entry(task_with_privates *p) {
  S *s = p->s;
  switch(partid) {
  case 1:
    p->s = (S*)kmpc_alloc();
    kmpc_omp_task();
    br exit;
  case 2:
    *s = x;
    kmpc_omp_task();
    br exit;
  case 2:
    ~S(s);
    kmpc_free((void*)s);
    br exit;
  }
exit:
}
```

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D86558




More information about the All-commits mailing list