Skip to content

Conversation

@s-mayani
Copy link
Collaborator

@s-mayani s-mayani commented Oct 29, 2025

FEMInterpolate.hpp does not work on GPU. Error: CUDA ILLEGAL INSTRUCTION.

It seems that this is happening due accessing functions of the FEM space inside the Kokkos loop, which cannot be done as the FEM space contains host functions too, so trying to access its functions on device results in errors, as the FEMInterpolate is not within the FEM space class so cannot put the loop inside the class and use KOKKOS_CLASS_LAMBDA.

To fix this, there is now a possibility to create a lightweight device copy of a FEM space through the function space.getDeviceMirror(), which returns a struct containing all the relevant members and functions of the LagrangeSpace class which are needed in FEMInterpolate, and which contains stuff which can be fully on device (only KOKKOS_FUNCTIONS). The signature of the FEMInterpolate functions have not changed, but inside the FEMInterpolate functions we get a device mirror of the space (so a DeviceStruct) before going into the Kokkos loop, and then access the functions of this one.

Minor changes: changed the locate_element_nd_and_xi function to not take the mesh but only the quantities it needs (mesh spacing and origin).

@s-mayani s-mayani self-assigned this Oct 29, 2025
@s-mayani s-mayani requested a review from srikrrish October 29, 2025 14:32
@s-mayani
Copy link
Collaborator Author

@JoMee there is a unit test failing in the CI, which is AssembleRHS on CPU. However, this test passes on Alps. I assume it's due to different tolerances on different systems. I have not changed any types in the FEMInterpolate though, so I do not understand why it wouldn't work if it was working before. I checked the output and the numbers are pretty close (see CI Allure report for PR #438). Do you have any idea?

@aaadelmann aaadelmann requested review from aaadelmann and srikrrish and removed request for srikrrish November 3, 2025 12:34
@s-mayani
Copy link
Collaborator Author

s-mayani commented Nov 5, 2025

Adding a KOKKOS_INLINE_FUNCTION constructor did not help. Should I try to go the helper class way or are we fine with this as it is?

@srikrrish
Copy link
Member

Adding a KOKKOS_INLINE_FUNCTION constructor did not help. Should I try to go the helper class way or are we fine with this as it is?

If it is relatively easy and not make take much time it can be done. Otherwise I would suggest to defer it to prioritize other efforts for the paper.

@s-mayani
Copy link
Collaborator Author

s-mayani commented Nov 5, 2025

Then I would say let's merge this as I have found another GPU issue in the FEM+Landau, so I will concentrate on that for now, then will come back to this once we have it working. I can open an issue for it.

@s-mayani s-mayani merged commit e1be1f7 into IPPL-framework:master Nov 5, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants