This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Pass argument to device kernel by reference when map is used.
ClosedPublic

Authored by gtbercea on Feb 13 2017, 12:32 PM.

Details

Summary

When a scalar argument is explicitly mapped, the device kernel needs to be passed that argument by reference.

This is a partial fix to this bug.

The full fix requires data sharing support which will land in future patches.

Diff Detail

Repository
rL LLVM

Event Timeline

gtbercea created this revision.Feb 13 2017, 12:32 PM
gtbercea updated this revision to Diff 93859.Apr 3 2017, 7:45 AM

Update test.

ABataev added inline comments.Apr 6 2017, 7:48 AM
lib/Sema/SemaOpenMP.cpp
358–360

Could you join these 2 functions into one?

gtbercea marked an inline comment as done.Apr 11 2017, 7:49 AM
gtbercea added inline comments.
lib/Sema/SemaOpenMP.cpp
358–360

Since SI and StarI use different types of iterations the functions cannot be merged.

gtbercea marked an inline comment as done.Apr 11 2017, 7:49 AM
ABataev added inline comments.Apr 11 2017, 8:28 AM
lib/Sema/SemaOpenMP.cpp
358–360

I still believe you can reuse this new code:

bool checkMappableExprComponentListsForDecl(
    ValueDecl *VD, bool CurrentRegionOnly,
    const llvm::function_ref<
        bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
             OpenMPClauseKind)> &Check) {
  if (Stack.empty())
    return false;

  if (CurrentRegionOnly)
    return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 1, Check);
  
  for (unsigned I = Stack.size(); I > 0; --I)
    if (checkMappableExprComponentListsForDeclAtLevel(VD, I - 1, Check))
      return true; 
  return false;
}

or something like this.

gtbercea updated this revision to Diff 94867.Apr 11 2017, 12:15 PM

Refactor code.

gtbercea marked 2 inline comments as done.Apr 11 2017, 12:15 PM
gtbercea updated this revision to Diff 94972.Apr 12 2017, 8:04 AM

Pass correct levels. Refactor code.

ABataev added inline comments.Apr 12 2017, 8:25 AM
lib/Sema/SemaOpenMP.cpp
355

Are you sure this is correct? If I is 1, I-2 will give you 0xFFFFFFFF. Please, check everything one more time

367

Please, remove this commented code

gtbercea updated this revision to Diff 94983.Apr 12 2017, 9:25 AM

Clean-up.

gtbercea marked an inline comment as done.Apr 12 2017, 9:25 AM
gtbercea updated this revision to Diff 94985.Apr 12 2017, 9:41 AM

Refactor code.

gtbercea marked an inline comment as done.Apr 12 2017, 9:41 AM
gtbercea updated this revision to Diff 94990.Apr 12 2017, 9:57 AM

Fix for loop range.

gtbercea updated this revision to Diff 94991.Apr 12 2017, 10:00 AM

Update check before loop.

This revision is now accepted and ready to land.Apr 12 2017, 10:02 AM

Does this also include the fixes in the following revision?

https://reviews.llvm.org/D29905

Sorry, I wasn't aware of this revision and thought that it had long been committed. I just verified that the bug referenced in the summary is also fixed by my patch in D34888. However, I can't comment on whether this patch is still needed. Sorry for the conflicts if yes...

You probably should commit your patches earlier, you currently have 10 accepted revisions that have not yet been committed. This will also avoid complicated rebases and so on.

Does this also include the fixes in the following revision?

https://reviews.llvm.org/D29905

Sorry, I wasn't aware of this revision and thought that it had long been committed. I just verified that the bug referenced in the summary is also fixed by my patch in D34888. However, I can't comment on whether this patch is still needed. Sorry for the conflicts if yes...

You probably should commit your patches earlier, you currently have 10 accepted revisions that have not yet been committed. This will also avoid complicated rebases and so on.

No problem at all! I am trying to commit the rest of the patches. Currently waiting on one more patch to get approved that will unlock the rest. I do encourage you to review/comment on it: https://reviews.llvm.org/D34784 :)

gtbercea closed this revision.Aug 9 2017, 9:18 AM

Already covered by D34888