[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
Showing
- include/clang/AST/DataRecursiveASTVisitor.h 9 additions, 0 deletionsinclude/clang/AST/DataRecursiveASTVisitor.h
- include/clang/AST/OpenMPClause.h 88 additions, 1 deletioninclude/clang/AST/OpenMPClause.h
- include/clang/AST/RecursiveASTVisitor.h 9 additions, 0 deletionsinclude/clang/AST/RecursiveASTVisitor.h
- include/clang/Basic/DiagnosticSemaKinds.td 1 addition, 1 deletioninclude/clang/Basic/DiagnosticSemaKinds.td
- lib/AST/Stmt.cpp 29 additions, 3 deletionslib/AST/Stmt.cpp
- lib/AST/StmtProfile.cpp 9 additions, 0 deletionslib/AST/StmtProfile.cpp
- lib/CodeGen/CGOpenMPRuntime.cpp 320 additions, 35 deletionslib/CodeGen/CGOpenMPRuntime.cpp
- lib/CodeGen/CGOpenMPRuntime.h 58 additions, 0 deletionslib/CodeGen/CGOpenMPRuntime.h
- lib/CodeGen/CGStmtOpenMP.cpp 185 additions, 96 deletionslib/CodeGen/CGStmtOpenMP.cpp
- lib/CodeGen/CodeGenFunction.h 29 additions, 0 deletionslib/CodeGen/CodeGenFunction.h
- lib/Sema/SemaOpenMP.cpp 201 additions, 66 deletionslib/Sema/SemaOpenMP.cpp
- lib/Serialization/ASTReaderStmt.cpp 12 additions, 0 deletionslib/Serialization/ASTReaderStmt.cpp
- lib/Serialization/ASTWriterStmt.cpp 6 additions, 0 deletionslib/Serialization/ASTWriterStmt.cpp
- test/OpenMP/for_reduction_messages.cpp 25 additions, 25 deletionstest/OpenMP/for_reduction_messages.cpp
- test/OpenMP/for_simd_reduction_messages.cpp 24 additions, 24 deletionstest/OpenMP/for_simd_reduction_messages.cpp
- test/OpenMP/parallel_for_reduction_messages.cpp 24 additions, 24 deletionstest/OpenMP/parallel_for_reduction_messages.cpp
- test/OpenMP/parallel_for_simd_reduction_messages.cpp 24 additions, 24 deletionstest/OpenMP/parallel_for_simd_reduction_messages.cpp
- test/OpenMP/parallel_reduction_codegen.cpp 703 additions, 0 deletionstest/OpenMP/parallel_reduction_codegen.cpp
- test/OpenMP/parallel_reduction_messages.cpp 24 additions, 24 deletionstest/OpenMP/parallel_reduction_messages.cpp
- test/OpenMP/parallel_sections_reduction_messages.cpp 24 additions, 24 deletionstest/OpenMP/parallel_sections_reduction_messages.cpp
Loading
Please register or sign in to comment