[PATCH] [OPENMP] Codegen for 'copyprivate' clause ('single' directive).

Alexey Bataev a.bataev at hotmail.com
Wed Mar 18 02:15:54 PDT 2015


Hi rjmccall, hfinkel, fraggamuffin, ejstotzer,

If there is at least one 'copyprivate' clause is associated with the single directive, the following code is generated:
```
i32 did_it = 0;                                  \\ for 'copyprivate' clause
if(__kmpc_single(ident_t *, gtid)) {
  SingleOpGen();
  __kmpc_end_single(ident_t *, gtid);
  did_it = 1;                                    \\ for 'copyprivate' clause
}
<copyprivate_list>[0] = &var0;
...
<copyprivate_list>[n] = &varn;
call __kmpc_copyprivate(ident_t *, gtid, <copyprivate_list_size>, <copyprivate_list>, <copy_func>, did_it);
...
void <copy_func>(void* LHSArg, void *RHSArg) {
  Dst = (void*[n])(LHSArg);
  Src = (void*[n])(RHSArg);
  Dst[0] = Src[0];
  ...
  Dst[n] = Src[n];
}
```
All list items from all 'copyprivate' clauses are gathered into single <copyprivate list> (<copyprivate_list_size> is a size in bytes of this list) and <copy_func> is used to propagate values of private or threadprivate variables from the 'single' region to other implicit threads from outer 'parallel' region.

http://reviews.llvm.org/D8410

Files:
  include/clang/AST/DataRecursiveASTVisitor.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  lib/AST/Stmt.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/single_codegen.cpp
  test/OpenMP/single_copyprivate_messages.cpp
  tools/libclang/CIndex.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8410.22167.patch
Type: text/x-patch
Size: 39949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150318/4de84482/attachment.bin>


More information about the cfe-commits mailing list