Skip to content

Conversation

@Yurlungur
Copy link
Collaborator

PR Summary

As discussed in #508 @Yannicked reports problems with the vector API for small vectors. This was partially resolved by #509 . In general, it would be better to use the cell based API in this case. However, specifically for CPU, this can be resolved by capturing by reference instead of by value in the portableFor. This MR adds this optionally. It is off by default and comes with significant warning labels.

This is marked WIP as I'm not sure we want to pursue this. It is, as far as I can tell, safe here. But does fundamentally change the semantics of these functions in some cases, which I consider a risk as far as debugging and maintainability.

An alternative approach would be to expose scalar fortran functions. That would be a lot more boiler plate, but potentially more maintainable. Curious to hear folks thoughts. @dholladay00 @jhp-lanl .

Note that getting scalar fortran functions to bind onto device is apparently a challenge, as C/fortran interop is a fundamentally host-side thing. Going this path would at least let us punt on that until that machinery is potentially more mature.

PR Checklist

  • Adds a test for any bugs fixed. Adds tests for new features.
  • Format your changes by using the make format command after configuring with cmake.
  • Document any new features, update documentation for changes made.
  • Make sure the copyright notice on any files you modified is up to date.
  • After creating a pull request, note it in the CHANGELOG.md file.
  • LANL employees: make sure tests pass both on the github CI and on the Darwin CI

If preparing for a new release, in addition please check the following:

  • Update the version in cmake.
  • Move the changes in the CHANGELOG.md file under a new header for the new release, and reset the categories.
  • Ensure that any when='@main' dependencies are updated to the release version in the package.py

@Yurlungur Yurlungur self-assigned this May 28, 2025
@Yurlungur Yurlungur added discussion interface Library interface work labels May 28, 2025
@Yurlungur Yurlungur changed the title [WIP] Jmm/sometimes capture by reference [WIP] sometimes capture by reference May 28, 2025
@Yurlungur Yurlungur linked an issue May 28, 2025 that may be closed by this pull request
@jhp-lanl
Copy link
Collaborator

Note that getting scalar fortran functions to bind onto device is apparently a challenge, as C/fortran interop is a fundamentally host-side thing. Going this path would at least let us punt on that until that machinery is potentially more mature.

I'm not sure we want to support fortran device binding unless there's a dedicated person willing to invest in that. But it sounds like a scalar fortran interface for the host would be useful, yes?

@Yurlungur
Copy link
Collaborator Author

Note that getting scalar fortran functions to bind onto device is apparently a challenge, as C/fortran interop is a fundamentally host-side thing. Going this path would at least let us punt on that until that machinery is potentially more mature.

I'm not sure we want to support fortran device binding unless there's a dedicated person willing to invest in that. But it sounds like a scalar fortran interface for the host would be useful, yes?

Yes I think that's right. I'm not sure how many LOC it would be but I think it would be a useful addition.

@Yurlungur Yurlungur changed the title [WIP] sometimes capture by reference sometimes capture by reference Jul 3, 2025
@Yurlungur
Copy link
Collaborator Author

@Yannicked I am returning to this as we haven't had any movement towards a scalar fortran API. Does this branch resolve your performance issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discussion interface Library interface work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EOS copies impacting performance with small array calls

4 participants