This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Update target directive codegen to use 4.5 implicit data mappings.
ClosedPublic

Authored by sfantao on Nov 23 2015, 3:51 PM.

Details

Summary

This patch implements the 4.5 specification for the implicit data maps. OpenMP 4.5 specification changes the default way data is captured into a target region. All the non-aggregate kinds are passed by value by default. This required activating the capturing by value during SEMA for the target region. All the non-aggregate values that can be encoded in the size of a pointer are properly casted and forwarded to the runtime library. On top of fixing the previous weird behavior for mapping pointers in nested data regions (an explicit map was always required), this also improves performance as the number of allocations/transactions to the device per non-aggregate map are reduced from two to only one - instead of passing a reference and the value, only the value passed.

Explicit maps will be added later on once firstprivate, private, and map clauses' SEMA and parsing are available.

Diff Detail

Event Timeline

sfantao updated this revision to Diff 40993.Nov 23 2015, 3:51 PM
sfantao retitled this revision from to [OpenMP] Update target directive codegen to use 4.5 implicit data mappings..
sfantao updated this object.
sfantao added reviewers: ABataev, hfinkel, rjmccall.
sfantao added subscribers: carlo.bertolli, cfe-commits.
ABataev added inline comments.Nov 25 2015, 11:58 PM
include/clang/AST/Stmt.h
2009–2011

Also add assertion that only pointers anmd scalars are allowed to be captured by value

lib/CodeGen/CGStmtOpenMP.cpp
139–148

Turn back to range-based loop

lib/Sema/SemaOpenMP.cpp
818–819

Wow. I think it is just enough to check !Ty->isScalarType().

sfantao updated this revision to Diff 41458.Nov 30 2015, 7:53 PM
sfantao marked 3 inline comments as done.
sfantao updated this object.

Use isScalarType to decide whether to capture by reference or value for the target directive.

Hi Alexey,

Thanks for the review!

include/clang/AST/Stmt.h
2009–2011

Done! Note however that VarDecl was an incomplete type here. So I moved the code to Stmt.cpp.

lib/Sema/SemaOpenMP.cpp
818–819

Oh, right. Changed that to use isScalarType.

ABataev accepted this revision.Dec 2 2015, 5:18 AM
ABataev edited edge metadata.
This revision is now accepted and ready to land.Dec 2 2015, 5:18 AM
sfantao closed this revision.Dec 2 2015, 9:47 AM