Skip to content

Conversation

@int-ptr-ptr
Copy link
Collaborator

Description

Please describe the changes/features in this pull request.

  • updates the point impl_load for nonconforming interfaces
  • adds new chunk_edge containers for compute_coupling
    • since different flux schemes need different data, there is no one-size-fits-all interface_data container. We can decide how to handle delegation along with the accessor compatibility update we will have to do in the future for coupled interfaces.

Issue Number

If there is an issue created for these changes, link it here

Checklist

Please make sure to check developer documentation on specfem docs.

  • I ran the code through pre-commit to check style
  • THE DOCUMENTATION BUILDS WITHOUT WARNINGS/ERRORS
  • I have added labels to the PR (see right hand side of the PR page)
  • My code passes all the integration tests
  • I have added sufficient unittests to test my changes
  • I have added/updated documentation for the changes I am proposing
  • I have updated CMakeLists to ensure my code builds
  • My code builds across all platforms

Copy link
Collaborator

@Rohit-Kakodkar Rohit-Kakodkar left a comment

Choose a reason for hiding this comment

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

Small changes.

Comment on lines 61 to 63
KOKKOS_INLINE_FUNCTION const TransferViewType &get_transfer_function() const {
return transfer_function_self;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We dont need the get function since transfer_function_self is itself public.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

get_transfer_function() is used to abstract the difference between transfer_function_self and transfer_function_coupled so that the same code can be used.

As an example, here's the transfer algorithm using it, where interface_data has already been checked to inherit only one of transfer_function<is_self=true> and transfer_function<is_self=false>. get_transfer_function() is used instead of something like

(stores_self_transfer_function<decltype(interface_data)>::type)?
    interface_data.transfer_function_self : interface_data.transfer_function_coupled

Would storing a const TransferViewType& field be better than the function?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not getting this. What cant you directly reference it in the line you linked const auto& transfer_functions = interface_data.transfer_function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not getting this. What cant you directly reference it in the line you linked const auto& transfer_functions = interface_data.transfer_function

transfer_function_self is different from transfer_function_coupled. You would need a compile-time ternary, which is what the get_transfer_function() method is.

Copy link
Collaborator Author

@int-ptr-ptr int-ptr-ptr Nov 3, 2025

Choose a reason for hiding this comment

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

/** @brief Transfer function (edge -> mortar). Only the relevant side is
* enabled.
*/
TransferViewType transfer_function_self;
TransferViewType &transfer_function = transfer_function_self;
:

intersection_point_view(icomp) +=
coupled_field(iedge, ipoint_edge, icomp) *
interface_data.transfer_function(iedge, ipoint_edge,
ipoint_intersection);

Is this what you had in mind?

Comment on lines 83 to 92
template <typename MemberType>
KOKKOS_INLINE_FUNCTION nonconforming_transfer_function(const MemberType &team)
: transfer_function_self(team.team_scratch(0)) {}

/**
* @brief Get the amount memory in bytes required for shared memory
*
* @return int Amount of shared memory in bytes
*/
constexpr static int shmem_size() { return TransferViewType::shmem_size(); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Point views would not use a team allocator. Point views are instantiated in register space and not scrach space. For example, shmem_size() does not exist for datatype::VectorPointViewType

* enabled.
*/
TransferViewType transfer_function_coupled;
KOKKOS_INLINE_FUNCTION const TransferViewType &get_transfer_function() const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

See comment above.

Comment on lines 144 to 153
template <typename MemberType>
KOKKOS_INLINE_FUNCTION nonconforming_transfer_function(const MemberType &team)
: transfer_function_coupled(team.team_scratch(0)) {}

/**
* @brief Get the amount memory in bytes required for shared memory
*
* @return int Amount of shared memory in bytes
*/
constexpr static int shmem_size() { return TransferViewType::shmem_size(); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

See comment above.

specfem::data_access::is_point<PointType>::value, int> = 0>
KOKKOS_FORCEINLINE_FUNCTION void impl_load(const IndexType &index,
PointType &point) const {
if constexpr (on_device) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this wrong before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was outdated and never had to be compiled, since no point<connection_tag=nonconforming> accessor existed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you merge branch issue-1350 into this. That branch should provide a fix for this.

Copy link
Collaborator

@lsawade lsawade left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@Rohit-Kakodkar Rohit-Kakodkar left a comment

Choose a reason for hiding this comment

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

See comments.

KOKKOS_INLINE_FUNCTION const TransferViewType &get_transfer_function() const {
return transfer_function_self;
}
TransferViewType &transfer_function = transfer_function_self;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still dont understand why you need a reference type? Can you not name the above variable just transfer_function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There will be a flux scheme where compute_coupling needs both transfer_function_self and transfer_function_coupled, and it makes more sense to do it this way than to do something like
intersection_data.specfem::chunk_edge::nonconforming_transfer_function<true,...>::transfer_function.

Right now, the compatibility checker looks for the field names, so if this is something to change, I would rather wait until we rework that.

Copy link
Collaborator

@Rohit-Kakodkar Rohit-Kakodkar Nov 6, 2025

Choose a reason for hiding this comment

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

Would updating this to const auto &transfer_function = interface_container.transfer_function_self in the transfer kernel do the trick?

Comment on lines 75 to 84
/**
* @brief Constructor that initializes data views in Scratch
* Memory.
*
* @tparam MemberType Kokos team member type.
* @param team Kokkos team member.
*/
template <typename MemberType>
KOKKOS_INLINE_FUNCTION nonconforming_transfer_function(const MemberType &team)
: transfer_function_self(team.team_scratch(0)) {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Point views should not have team operator.

Comment on lines 127 to 136
/**
* @brief Constructor that initializes data views in Scratch
* Memory.
*
* @tparam MemberType Kokos team member type.
* @param team Kokkos team member.
*/
template <typename MemberType>
KOKKOS_INLINE_FUNCTION nonconforming_transfer_function(const MemberType &team)
: transfer_function_coupled(team.team_scratch(0)) {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above

specfem::dimension::type DimensionTag, bool UseSIMD>
struct nonconforming_transfer_function;

template <int NQuadIntersection, bool UseSIMD>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont think we'd be able to SIMD vectorize compute coupling yet just because of how data is layed out.

Rohit-Kakodkar and others added 4 commits November 5, 2025 11:55
- [x] Update index function in edge/intersection iterator
- [x] Update `for_all` execution function
@int-ptr-ptr int-ptr-ptr mentioned this pull request Nov 6, 2025
10 tasks
specfem::data_access::is_point<PointType>::value, int> = 0>
KOKKOS_FORCEINLINE_FUNCTION void impl_load(const IndexType &index,
PointType &point) const {
if constexpr (on_device) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you merge branch issue-1350 into this. That branch should provide a fix for this.

revert  ncmarked_conforming_grid_curved CMakeLists.txt sources to relative (to match ncmarked_conforming_grid_flat CmakeLists)
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

Successfully merging this pull request may close these issues.

Add point specializations Add data_access functions (load_on_device etc.)

4 participants