]> granicus.if.org Git - clang/commit
[OPENMP] Codegen for 'reduction' clause in 'parallel' directive.
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 10 Apr 2015 10:43:45 +0000 (10:43 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 10 Apr 2015 10:43:45 +0000 (10:43 +0000)
commitec17a34f771531b6799cee301dbacb21b23e236e
treeaf5e7f98f2e5d4195547a8ca99eec3e0e9236f02
parent914d1bd47f6252559e110929949d69a7a145881d
[OPENMP] Codegen for 'reduction' clause in 'parallel' directive.

Emit a code for reduction clause. Next code should be emitted for reductions:

static kmp_critical_name lock = { 0 };

void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
  ...
  *(Type<i> *)lhs[i] = RedOp<i>(*(Type<i> *)lhs[i], *(Type<i> *)rhs[i]);
  ...
}

... void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n> - 1]};
switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) {
case 1:
  ...
  <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]);
  ...
  __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>);
  break;
case 2:
  ...
  Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]));
  ...
  break;
default:
  ;
}
Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation.

Differential Revision: http://reviews.llvm.org/D8915

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234583 91177308-0d34-0410-b5e6-96231b3b80d8
24 files changed:
include/clang/AST/DataRecursiveASTVisitor.h
include/clang/AST/OpenMPClause.h
include/clang/AST/RecursiveASTVisitor.h
include/clang/Basic/DiagnosticSemaKinds.td
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/for_reduction_messages.cpp
test/OpenMP/for_simd_reduction_messages.cpp
test/OpenMP/parallel_for_reduction_messages.cpp
test/OpenMP/parallel_for_simd_reduction_messages.cpp
test/OpenMP/parallel_reduction_codegen.cpp [new file with mode: 0644]
test/OpenMP/parallel_reduction_messages.cpp
test/OpenMP/parallel_sections_reduction_messages.cpp
test/OpenMP/sections_reduction_messages.cpp
test/OpenMP/simd_reduction_messages.cpp
test/OpenMP/teams_reduction_messages.cpp
tools/libclang/CIndex.cpp