Skip to content

Avoid array temporaries#504

Merged
matt-frey merged 4 commits intodev-0.14.0from
no-temporaries-debug-mode
Jul 14, 2023
Merged

Avoid array temporaries#504
matt-frey merged 4 commits intodev-0.14.0from
no-temporaries-debug-mode

Conversation

@matt-frey
Copy link
Member

Fortran creates temporary arrays when passing sub-ranges to subroutines.

@matt-frey matt-frey added enhancement / optimisation Improve algorithm or behaviour 3D Issues and pull requests related to the 3D version labels Jun 30, 2023
@matt-frey matt-frey added this to the 0.14.0 milestone Jun 30, 2023
@matt-frey matt-frey requested a review from sjboeing June 30, 2023 09:17
@matt-frey matt-frey self-assigned this Jun 30, 2023
Copy link
Collaborator

@sjboeing sjboeing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for writing this Matthias! I can see why you initially went for the other approach, but thought it would be worth trying to get rid of the compiler warnings. Not quite sure whether to do anything (by default) with the values of the output fields at z=-1 and z=nz+1.

@matt-frey
Copy link
Member Author

We could also get rid of these warnings by explicitly creating a temporary variable ourselves.

@sjboeing
Copy link
Collaborator

What do you think is best practice/most efficient? I would be OK with either solution. Guess this is the next one to merge after the period BCs PR.

@matt-frey
Copy link
Member Author

matt-frey commented Jul 14, 2023

Avoiding temporary arrays is definitely more efficient as we do not copy memory. The indices -1 and nz+1 for these arrays are never used and we can either set them to zero or (maybe better) use linear extrapolation.

@matt-frey
Copy link
Member Author

My suggested change: 5759bce

@sjboeing
Copy link
Collaborator

Let's use the extrapolation, which I agree should be safer.

@matt-frey matt-frey requested a review from sjboeing July 14, 2023 08:49
@matt-frey matt-frey removed the request for review from sjboeing July 14, 2023 11:20
@matt-frey matt-frey merged commit 0ffbe2b into dev-0.14.0 Jul 14, 2023
@matt-frey matt-frey deleted the no-temporaries-debug-mode branch July 14, 2023 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3D Issues and pull requests related to the 3D version enhancement / optimisation Improve algorithm or behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants