Skip to content

[OpenMP][WIP] Use ATTACH maps for array-sections/subscripts on pointers. #153683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 76 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
d867ab3
[Clang][OpenMP] Capture mapped pointers on `target` by reference.
abhinavgaba Jun 23, 2025
97b2dff
Add another test, minor clang-format fix.
abhinavgaba Jun 24, 2025
a31ea2a
Update the comparator for sort, plus minor additions to offload tests.
abhinavgaba Jun 24, 2025
cc90643
[WIP] Use ATTACH maps for array-sections/subscripts on pointers.
abhinavgaba Jun 11, 2025
6ba75e1
[WIP] Commit some more non-debug print changes.
abhinavgaba Jun 25, 2025
001da09
[NFC][Clang] Refactor mapinfo generation for captured vars on target.
abhinavgaba Jul 2, 2025
1ebb7a9
Handle mapping of captured pointers before any dereference of them.
abhinavgaba Jul 2, 2025
7799d0a
No need to change the sorting since we now handle mapping of pointers…
abhinavgaba Jul 2, 2025
9f61909
[NFC][Clang] Refactor mapinfo generation for captured vars on target.
abhinavgaba Jul 2, 2025
5261578
Minor clang-format fix.
abhinavgaba Jul 3, 2025
145160b
[NFC][OpenMP] Add tests for mapping pointers and their dereferences.
abhinavgaba Jul 3, 2025
15e7d50
Minor clang-format fix.
abhinavgaba Jul 3, 2025
9a2fabb
Merge branch 'capture-info-refactor' into tgt-capture-mapped-ptrs-by-ref
abhinavgaba Jul 7, 2025
78fd5e5
Merge branch 'nfc-lit-test-updates-for-incoming-pr' into tgt-capture-…
abhinavgaba Jul 7, 2025
b1540b3
Minor NFC update to a test.
abhinavgaba Jul 7, 2025
f1746b6
Update tests with the current output.
abhinavgaba Jul 7, 2025
9408873
Merge branch 'tgt-capture-mapped-ptrs-by-ref' into map-ptr-array-sect…
abhinavgaba Jul 8, 2025
3ce181f
Fix findAttachComponent
abhinavgaba Jul 8, 2025
50c8d0e
Fix build issues, keep debug prints
abhinavgaba Jul 8, 2025
c23e01f
Fix handling of array-sections in findAttachComponent
abhinavgaba Jul 8, 2025
6c2df5c
Merge remote-tracking branch 'origin/main' into tgt-capture-mapped-pt…
abhinavgaba Jul 8, 2025
9adf9a8
Fix one test.
abhinavgaba Jul 8, 2025
ca0c381
Merge branch 'tgt-capture-mapped-ptrs-by-ref' into map-ptr-array-sect…
abhinavgaba Jul 8, 2025
36f6d9b
Fix star case. Update some tests.
abhinavgaba Jul 9, 2025
8349a49
Refactor AddAttachEntry
abhinavgaba Jul 9, 2025
eaf332f
Delay addition of attach when we populate PartialStruct.
abhinavgaba Jul 9, 2025
da55bf8
Update some more tests.
abhinavgaba Jul 16, 2025
5d72174
[WIP][Offload] Introduce ATTACH map-type support for pointer attachment.
abhinavgaba Jul 16, 2025
fcdc13a
More test updates
abhinavgaba Jul 16, 2025
c35d7a0
[WIP][Offload] Introduce ATTACH map-type support for pointer attachment.
abhinavgaba Jul 16, 2025
b645d58
Minor format/stylistic changes.
abhinavgaba Jul 16, 2025
13faca1
Minor formatting changes.
abhinavgaba Jul 16, 2025
54b2ae4
Remove debug prints.
abhinavgaba Jul 16, 2025
00b0767
Limit attach map-type generation to only map-entering constructs.
abhinavgaba Jul 16, 2025
baa9dbb
Minor clean-up
abhinavgaba Jul 16, 2025
c0d20e9
Minor NFC changes.
abhinavgaba Jul 20, 2025
a9b94d4
Use lb instead of base when attaching to a partialstruct.
abhinavgaba Jul 20, 2025
f1acc37
[NFC] Move computation of ptr/ptee addrs outside the loop.
abhinavgaba Jul 21, 2025
976470c
[NFC] Return Expr* from findAttachBasePtr.
abhinavgaba Jul 21, 2025
fd2d077
[NFC] Minor renaming/comment changes.
abhinavgaba Jul 21, 2025
fdced7d
Fix call to getAttachptrPteeAddrs.
abhinavgaba Jul 21, 2025
d791cb3
Remove unnecessary include.
abhinavgaba Jul 21, 2025
df62d2e
No need to compute the pointee address from scratch.
abhinavgaba Jul 22, 2025
63d2ca4
Update tests after avoiding creating pointee addr, and a minor commen…
abhinavgaba Jul 22, 2025
c9f8c0a
Move initialization of FinalLowestElem earlier.
abhinavgaba Jul 22, 2025
f044a56
Improve readability, add some more comments.
abhinavgaba Jul 23, 2025
de8d968
Merge remote-tracking branch 'upstream/main' into libomptarget-introd…
abhinavgaba Jul 27, 2025
168a2b8
add dataFence to plugin interface
adurang Jul 25, 2025
2370215
Clang-format fixes.
abhinavgaba Jul 27, 2025
2806389
Insert a data-fence before the first pointer-attachment.
abhinavgaba Jul 27, 2025
09c9cf3
Merge branch 'libomptarget-introduce-attach-support' into map-ptr-arr…
abhinavgaba Jul 27, 2025
e411f29
Update new upstream test.
abhinavgaba Jul 27, 2025
40320d2
Use unique_ptr, avoid c-style casts.
abhinavgaba Jul 30, 2025
fcdb2f5
Use unique_ptr, avoid c-style casts.
abhinavgaba Jul 30, 2025
39e4ab1
Add newline at end of file.
abhinavgaba Aug 1, 2025
9462953
Cache the attach-ptr-expr computation result, and reuse it if needed.
abhinavgaba Aug 1, 2025
371918e
Clean-up some debug prints.
abhinavgaba Aug 5, 2025
eb35a3e
Clean-up some debug prints.
abhinavgaba Aug 5, 2025
f1a4e80
[NFC][Offload] Add missing maps to OpenMP offloading tests.
abhinavgaba Aug 6, 2025
c15b2b9
[NFC][Clang][OpenMP] Extract collection of component-lists out of gen…
abhinavgaba Aug 6, 2025
4517cd2
Do pointee lookup and release its TPR before pointer lookup.
abhinavgaba Aug 8, 2025
d2e6a7c
Expand to remove the restriction to only support simple vars as attac…
abhinavgaba Aug 6, 2025
a78e9b0
Do pointee lookup and release its TPR before pointer lookup.
abhinavgaba Aug 8, 2025
4e3956c
Add an attach-ptr-expr comparator and use it to group components-list…
abhinavgaba Aug 9, 2025
3022b9a
Fix comparison of attach-ptrs, group component-lists by attach-ptr for
abhinavgaba Aug 10, 2025
788eb06
Fix matching of use_device_ptr/addr with existing map clauses.
abhinavgaba Aug 11, 2025
3dd11c1
Fix non-conforming tests.
abhinavgaba Aug 11, 2025
af72f97
Apply clang-format.
abhinavgaba Aug 11, 2025
2b31572
Add a fixme.
abhinavgaba Aug 12, 2025
dcd65fc
Remove debug-prints
abhinavgaba Aug 12, 2025
cb21ea4
Use a lambda to avoid uninitialized TgtPteeBegin.
abhinavgaba Aug 13, 2025
ac04da3
Merge remote-tracking branch 'upstream/main' into libomptarget-introd…
abhinavgaba Aug 13, 2025
63531f8
Remove debug prints. Update some tests.
abhinavgaba Aug 14, 2025
6c3def5
Merge branch 'libomptarget-introduce-attach-support' into map-ptr-arr…
abhinavgaba Aug 14, 2025
fb6a48c
Merge remote-tracking branch 'upstream/main' into map-ptr-array-secti…
abhinavgaba Aug 14, 2025
502dbb4
Update copy-gaps tests.
abhinavgaba Aug 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions clang/include/clang/AST/OpenMPClause.h
Original file line number Diff line number Diff line change
Expand Up @@ -5815,6 +5815,12 @@ class OMPClauseMappableExprCommon {
ValueDecl *getAssociatedDeclaration() const {
return AssociatedDeclaration;
}

bool operator==(const MappableComponent &Other) const {
return AssociatedExpressionNonContiguousPr ==
Other.AssociatedExpressionNonContiguousPr &&
AssociatedDeclaration == Other.AssociatedDeclaration;
}
};

// List of components of an expression. This first one is the whole
Expand All @@ -5828,6 +5834,13 @@ class OMPClauseMappableExprCommon {
using MappableExprComponentLists = SmallVector<MappableExprComponentList, 8>;
using MappableExprComponentListsRef = ArrayRef<MappableExprComponentList>;

// Hash function to allow usage as DenseMap keys.
friend llvm::hash_code hash_value(const MappableComponent &MC) {
return llvm::hash_combine(MC.getAssociatedExpression(),
MC.getAssociatedDeclaration(),
MC.isNonContiguous());
}

protected:
// Return the total number of elements in a list of component lists.
static unsigned
Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/Basic/OpenMPKinds.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@ bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind);
/// otherwise - false.
bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind);

/// Checks if the specified directive is a map-entering target directive.
/// \param DKind Specified directive.
/// \return true - the directive is a map-entering target directive like
/// 'omp target', 'omp target data', 'omp target enter data',
/// 'omp target parallel', etc. (excludes 'omp target exit data', 'omp target
/// update') otherwise - false.
bool isOpenMPTargetMapEnteringDirective(OpenMPDirectiveKind DKind);

/// Checks if the specified composite/combined directive constitutes a teams
/// directive in the outermost nest. For example
/// 'omp teams distribute' or 'omp teams distribute parallel for'.
Expand Down
5 changes: 5 additions & 0 deletions clang/lib/Basic/OpenMPKinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,11 @@ bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
}

bool clang::isOpenMPTargetMapEnteringDirective(OpenMPDirectiveKind DKind) {
return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
isOpenMPTargetExecutionDirective(DKind);
}

bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
if (DKind == OMPD_teams)
return true;
Expand Down
Loading
Loading