-
Notifications
You must be signed in to change notification settings - Fork 15
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
Enable inlining of a subroutine with an array subrange in an argument #484
Open
awnawab
wants to merge
3
commits into
main
Choose a base branch
from
naan-inline-array-arg
base: main
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.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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 |
---|---|---|
|
@@ -318,18 +318,19 @@ def test_inline_transformation_adjust_imports(frontend, tmp_path): | |
""" | ||
|
||
fcode_outer = """ | ||
subroutine test_inline_outer(a, b) | ||
subroutine test_inline_outer(a, b, f) | ||
use bnds_module, only: n | ||
use test_inline_mod, only: test_inline_inner | ||
use test_inline_another_mod, only: test_inline_another_inner | ||
implicit none | ||
|
||
real(kind=8), intent(inout) :: a(n), b(n) | ||
real(kind=8), intent(inout) :: a(n), b(n), f(0:n-1) | ||
real(kind=8) :: c(12) | ||
|
||
!$loki inline | ||
call test_inline_another_inner() | ||
!$loki inline | ||
call test_inline_inner(a, b) | ||
call test_inline_inner(a, b, c(1:4), c(5:8), c(9:12), f) | ||
end subroutine test_inline_outer | ||
""" | ||
|
||
|
@@ -338,18 +339,31 @@ def test_inline_transformation_adjust_imports(frontend, tmp_path): | |
implicit none | ||
contains | ||
|
||
subroutine test_inline_inner(a, b) | ||
subroutine test_inline_inner(a, b, c, d, e, f) | ||
use BNDS_module, only: n, m | ||
use another_module, only: x | ||
|
||
real(kind=8), intent(inout) :: a(n), b(n) | ||
real(kind=8), intent(inout) :: a(n), b(n), f(2:n+1) | ||
real(kind=8), intent(out) :: c(4), d(4), e(0:3) | ||
real(kind=8) :: tmp(m) | ||
integer :: i | ||
|
||
tmp(1:m) = x | ||
do i=1, n | ||
a(i) = b(i) + sum(tmp) | ||
end do | ||
do i=1,4 | ||
c(i) = 0. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add an assignment |
||
d(i) = 0. | ||
e(i-1) = 0. | ||
enddo | ||
c(:) = 1. | ||
d(1:4) = 1. | ||
e(0:3) = 1. | ||
e(:) = 2. | ||
do i=2, n+1 | ||
f(i) = 2. | ||
end do | ||
end subroutine test_inline_inner | ||
end module test_inline_mod | ||
""" | ||
|
@@ -381,11 +395,27 @@ def test_inline_transformation_adjust_imports(frontend, tmp_path): | |
|
||
# Check that the inlining has happened | ||
assign = FindNodes(ir.Assignment).visit(outer.body) | ||
assert len(assign) == 2 | ||
assert len(assign) == 10 | ||
assert assign[0].lhs == 'tmp(1:m)' | ||
assert assign[0].rhs == 'x' | ||
assert assign[1].lhs == 'a(i)' | ||
assert assign[1].rhs == 'b(i) + sum(tmp)' | ||
assert assign[2].lhs == 'c(i)' | ||
assert assign[2].rhs == '0.' | ||
assert assign[3].lhs == 'c(4 + i)' | ||
assert assign[3].rhs == '0.' | ||
assert assign[4].lhs == 'c(8 + i)' | ||
assert assign[4].rhs == '0.' | ||
assert assign[5].lhs == 'c(1:4)' | ||
assert assign[5].rhs == '1.' | ||
assert assign[6].lhs == 'c(5:8)' | ||
assert assign[6].rhs == '1.' | ||
assert assign[7].lhs == 'c(9:12)' | ||
assert assign[7].rhs == '1.' | ||
assert assign[8].lhs == 'c(9:12)' | ||
assert assign[8].rhs == '2.' | ||
assert assign[9].lhs == 'f(-2 + i)' | ||
assert assign[9].rhs == '2.' | ||
|
||
# Now check that the right modules have been moved, | ||
# and the import of the call has been removed | ||
|
Oops, something went wrong.
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.
[no action] Note to self, there's a similar index-shifting problem in the associate resolver. We could possibly re-use a shared utility for this if we were to externalise this? This is beyond this PR tho.