Skip to content

Improve data life time management #324

Description

@Sichao25

PCMS need to clarify where ownership and copying of data are actually required.

A general question is, conceptually, PCMS field evaluation should not need to own the data itself. When a field is created, the underlying data and coordinates likely already exist elsewhere. However, I am not sure if it is practical to completely avoid copying since we need local array eventually for coupler. At least we should try to use the same data in each memory space

Another specific case can be improved is about CoordinateView usage. For example,

auto coordinates = coords.GetCoordinates();
Kokkos::View<Real* [2], DeviceMemorySpace> coords_search(
"coords_search", coordinates.extent(0));
Kokkos::parallel_for(
"copy_coords",
Kokkos::RangePolicy<DeviceMemorySpace::execution_space>(
0, coordinates.extent(0)),
KOKKOS_LAMBDA(const int i) {
coords_search(i, 0) = coordinates(i, 0);
coords_search(i, 1) = coordinates(i, 1);
});
auto results = search_(coords_search);

CoordinateView takes no ownership, is used in evaluation requests and evaluators, but point search requires a Kokkos view — forcing an internal copy of the coordinates inside the evaluator. This is not ideal and potentially avoidable pattern worth addressing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions