-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[MLIR][OpenMP] Add OpenMPToLLVMIRTranslation support for is_device_ptr #169367
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
Open
TIFitis
wants to merge
1
commit into
users/Akash/is_device_ptr_lower
Choose a base branch
from
users/Akash/is_device_ptr_translate
base: users/Akash/is_device_ptr_lower
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+82
−17
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| ! Validate that a device pointer obtained via omp_get_mapped_ptr can be used | ||
| ! inside a TARGET region with the is_device_ptr clause. | ||
| ! REQUIRES: flang, amdgcn-amd-amdhsa | ||
|
|
||
| ! RUN: %libomptarget-compile-fortran-run-and-check-generic | ||
|
|
||
| program is_device_ptr_target | ||
| use iso_c_binding, only : c_ptr, c_loc | ||
| implicit none | ||
|
|
||
| interface | ||
| function omp_get_mapped_ptr(host_ptr, device_num) & | ||
| bind(C, name="omp_get_mapped_ptr") | ||
| use iso_c_binding, only : c_ptr, c_int | ||
| type(c_ptr) :: omp_get_mapped_ptr | ||
| type(c_ptr), value :: host_ptr | ||
| integer(c_int), value :: device_num | ||
| end function omp_get_mapped_ptr | ||
| end interface | ||
|
|
||
| integer, parameter :: n = 4 | ||
| integer, parameter :: dev = 0 | ||
| integer, target :: a(n) | ||
| type(c_ptr) :: dptr | ||
| integer :: flag | ||
|
|
||
| a = [2, 4, 6, 8] | ||
| flag = 0 | ||
|
|
||
| !$omp target data map(tofrom: a, flag) | ||
| dptr = omp_get_mapped_ptr(c_loc(a), dev) | ||
|
|
||
| !$omp target is_device_ptr(dptr) map(tofrom: flag) | ||
| flag = flag + 1 | ||
| !$omp end target | ||
| !$omp end target data | ||
|
|
||
| if (flag .eq. 1 .and. all(a == [2, 4, 6, 8])) then | ||
| print *, "PASS" | ||
| else | ||
| print *, "FAIL", a | ||
| end if | ||
|
|
||
| end program is_device_ptr_target | ||
|
|
||
| !CHECK: PASS | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dptris still not used inside the target construct. Is your goal to validate thatdptris correctly passed into thetarget, or just that this doesn't cause a segfault/offload-failure?If it's the former, then one way to do it is by calling c_f_pointer inside the target region, and reading/writing the pointee via the fortran pointer. Another way is to
transferdptr into anINTEGER(C_INTPTR_T)both inside and outside the target region, print it, and CHECK that the two addresses printed are identical.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried adding the call to c_f_pointer inside the target region in the previous test. But it causes a runtime failure, and I'm not sure if the failure is directly related to the is_device_ptr implementation or some other mapping bug.
If you're happy with the current simpler test for this PR, then I can work on debugging a fix for that failure when I return from vacation in the new year. Otherwise, I'll put this PR on hold until I can come up with a working version of that test with a call to c_f_pointer inside the target region.
Let me know which you prefer, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to tighten the test before merging. I might be missing something but I tried the following experiment:
And this prints:
which might mean that the device pointer kernel argument is not properly passed to the kernel. Let me know if I misinterpreted this.