Skip to content
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

Support inlining with array slices and non-unit strides #2873

Open
hiker opened this issue Jan 25, 2025 · 0 comments
Open

Support inlining with array slices and non-unit strides #2873

hiker opened this issue Jan 25, 2025 · 0 comments

Comments

@hiker
Copy link
Collaborator

hiker commented Jan 25, 2025

Inlining already handles array slices, but it only allows a step-size of size 1 (mentioned in #1646). E,g,, a call like:

   call test1(a(1:3, 2:5:3, 1:2:2), result)

cannot be inlined:

Transformation Error: Cannot inline routine 'test1' because one of its arguments is an array slice with a non-unit stride: 'a(:3,2:5:3,:2:2)' (TODO #1646)

The TODO is technically wrong (#1646 is about "dotproducttrans does not work if arguments are not plain arrays ", the non-unit stride is only mentioned there), so I decided to open a new issue to properly track this.

A suggested solution is to introduce a new pointer variable when inlining, e.g.:

a_p =>a(1:3, 2:5:3, 1:2:2)

And then use this pointer variable in the inlined routine.The F2003 standard allows that a dummy argument has the target attribute, even if the actual argument doesn't. Page 270 (12.4.1.2 Actual arguments associated with dummy data objects) lines 20-22:

20 If the dummy argument has the TARGET attribute and the corresponding actual argument does not
21 have the TARGET attribute or is an array section with a vector subscript, any pointers associated with
22 the dummy argument become undefined when execution of the procedure completes.

So any pointer set will become undefined when the subroutine exit, but as long as the inlined routine is executed, the pointer will be fine.

So during inline we could just add a target attribute to the dummy argument, introduce the pointer and the assignment, then in the inlined routine replace the original array with the pointer.

@hiker hiker changed the title Support inlining with array slices and step size not 1 Support inlining with array slices and non-unit strides Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant