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.
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
CoordinateViewusage. For example,pcms/src/pcms/field/evaluator/mesh_fields.h
Lines 131 to 142 in 3325cb2
CoordinateViewtakes 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.