Issue 1330 - Deprecate Kokkos abstractions#1632
Merged
Rohit-Kakodkar merged 4 commits intodevelfrom Feb 5, 2026
Merged
Conversation
- [x] Removes kokkos abstractions - wrappers to kokkos functions
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the project-specific kokkos_abstractions layer and replaces usages with direct Kokkos types and utilities, while simplifying field synchronization APIs and cleaning up legacy testing helpers.
Changes:
- Remove
include/kokkos_abstractions.hand allspecfem::kokkosview typedefs in favor of explicitKokkos::ViewandKokkos::TeamPolicy/MDRangePolicyusage across core and tests. - Update assembly, mesh, IO, sources/receivers, and quadrature code to use new Kokkos types and retain host/device mirror support through
Kokkos::create_mirror_viewand new copy helpers (copy_to_host/copy_to_device). - Delete legacy unit-test array comparison utilities (
compare_array.hpp/.tpp,utilities/include/interface.hpp, andcompare_arraysCMake target) and update affected tests to work without them.
Notable Issues
-
Layout mismatch in seismogram test helpers (compile-time type incompatibility)
- In both
tests/unit-tests/seismogram/elastic/seismogram_tests.cppandtests/unit-tests/seismogram/acoustic/seismogram_tests.cpp,read_fieldis now declared as:void read_field( const std::string filename, Kokkos::View<type_real **, Kokkos::LayoutRight, Kokkos::HostSpace> &field, const int n1, const int n2);
- The simulation fields expose host views via
field_implas:(seeKokkos::View<type_real **, Kokkos::LayoutLeft, Kokkos::HostSpace> field_impl::get_host_field() const; // analogous for get_host_field_dot, get_host_field_dot_dot
core/specfem/assembly/fields/impl/field_impl.hpparoundget_host_field). - The tests pass
assembly.fields.forward.elastic.h_field/.h_field_dot/.h_field_dot_dotintoread_field. These host field views are consistent withget_host_field*()and thus areLayoutLeft, notLayoutRight. - This is a compile-time type mismatch: a
Kokkos::View<..., LayoutLeft, HostSpace>cannot bind to aKokkos::View<..., LayoutRight, HostSpace>&. - Suggestion (mandatory): Change
read_field’s parameter to useKokkos::LayoutLeft(or, better, template on the layout and memory space to accept the exact type from the fields), e.g.:Kokkos::View<type_real **, Kokkos::LayoutLeft, Kokkos::HostSpace> &field, or- a template
template <class ViewType> void read_field(..., ViewType &field, ...)with appropriatestatic_asserton rank.
- In both
-
Minor type alias inconsistency in
compute_tests.cpp(optional clean-up)- In
tests/unit-tests/assembly_mesh/index/compute_tests.cpp, the aliasesare defined but never used in the file.using HostView1d = Kokkos::View<type_real *, Kokkos::LayoutRight, Kokkos::HostSpace>; using HostView2d = Kokkos::View<type_real **, Kokkos::LayoutRight, Kokkos::HostSpace>; using HostView3d = Kokkos::View<type_real ***, Kokkos::LayoutRight, Kokkos::HostSpace>;
- On main, these aliases referred to integer-index views (
HostView{1,2,3}d<int>), matching their semantic use; changing them totype_realis misleading even though they are currently unused. - Suggestion (optional, maintainability): Either remove these unused aliases or restore them to
intto match their intended purpose, to avoid confusion for future readers.
- In
Reviewed changes
Copilot reviewed 130 out of 130 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit-tests/utilities/src/compare_array.cpp | Removes dependency on kokkos_abstractions.h and legacy interface, leaving only basic equate helpers and commented-out array comparison code. |
| tests/unit-tests/utilities/include/interface.hpp | Deletes the unit-test header that only re-exported compare_array utilities. |
| tests/unit-tests/utilities/include/compare_array.tpp | Removes template implementation of array comparison utilities that depended on specfem::kokkos views. |
| tests/unit-tests/utilities/include/compare_array.hpp | Removes array comparison template declarations based on specfem::kokkos host views. |
| tests/unit-tests/source_time_function/source_time_function_tests.cpp | Replaces specfem::kokkos::HostView2d with explicit Kokkos::View<..., LayoutRight, HostSpace> for STF arrays in multiple tests. |
| tests/unit-tests/source/source.hpp | Drops unused include of kokkos_abstractions.h from source tests. |
| tests/unit-tests/source/dim3/vector_sources/force_source.hpp | Switches specfem::kokkos::HostView1d force vectors to explicit 1D Kokkos::View in host memory. |
| tests/unit-tests/source/dim3/tensor_sources/moment_tensor_source.hpp | Switches 2D specfem::kokkos::HostView2d source tensors to explicit Kokkos::View host views. |
| tests/unit-tests/source/dim2/vector_sources/force_source.hpp | Uses explicit 1D Kokkos::View for 2D vector source force arrays instead of HostView1d. |
| tests/unit-tests/source/dim2/vector_sources/external_source.hpp | Same as above for external 2D sources: replaces HostView1d with Kokkos::View on host. |
| tests/unit-tests/source/dim2/vector_sources/cosserat_force_source.hpp | Same as above for Cosserat force sources, replacing HostView1d. |
| tests/unit-tests/source/dim2/vector_sources/adjoint_source.hpp | Same as above for adjoint sources, replacing HostView1d. |
| tests/unit-tests/source/dim2/tensor_sources/moment_tensor_source.hpp | Replaces HostView2d for moment tensor source arrays by Kokkos::View host views. |
| tests/unit-tests/seismogram/elastic/seismogram_tests.cpp | Changes read_field to take a 2D LayoutRight host Kokkos::View and uses new assembly.fields.copy_to_device(); introduces the layout mismatch issue described above. |
| tests/unit-tests/seismogram/acoustic/seismogram_tests.cpp | Same read_field change as elastic tests, with same layout mismatch concern. |
| tests/unit-tests/jacobian/dim3/compute_locations_tests.cpp | Removes unused kokkos_abstractions.h include from 3D Jacobian location tests. |
| tests/unit-tests/jacobian/dim3/compute_jacobian_tests.cpp | Removes unused kokkos_abstractions.h include from 3D Jacobian tests. |
| tests/unit-tests/jacobian/dim2/compute_locations_tests.cpp | Removes unused kokkos_abstractions.h include from 2D Jacobian location tests. |
| tests/unit-tests/jacobian/dim2/compute_jacobian_tests.cpp | Removes unused kokkos_abstractions.h include from 2D Jacobian tests. |
| tests/unit-tests/gll/gll_tests.cpp | Replaces specfem::kokkos::{DeviceView1d,HostMirror1d} with concrete Kokkos::View types parameterized by DefaultExecutionSpace::memory_space and HostSpace. |
| tests/unit-tests/displacement_tests/Newmark/dim3/newmark_tests.cpp | Drops dependency on the deleted utilities/include/interface.hpp. |
| tests/unit-tests/displacement_tests/Newmark/dim2/newmark_tests.cpp | Same as above for 2D Newmark tests. |
| tests/unit-tests/assembly_mesh/jacobian_matrix/compute_jacobian_matrix_tests.cpp | Drops interface.hpp include, leaving test to use core assembly/jacobian APIs directly. |
| tests/unit-tests/assembly_mesh/index/compute_tests.cpp | Drops interface.hpp include and updates type aliases to raw Kokkos::View; also switches MDRangePolicy to plain Kokkos (no specfem::kokkos::HostMDrange). |
| tests/unit-tests/assembly/mesh/utilities.cpp | Replaces specfem::kokkos::HostView4d with explicit 4D host Kokkos::View for mesh coordinate construction in tests. |
| tests/unit-tests/assembly/compute_source_array/dim3/compute_source_array_from_vector.cpp | Removes unused kokkos_abstractions.h include from 3D vector source array tests. |
| tests/unit-tests/assembly/compute_source_array/dim3/compute_source_array_from_tensor.cpp | Removes unused kokkos_abstractions.h include from 3D tensor source array tests. |
| tests/unit-tests/assembly/compute_source_array/dim2/compute_source_array_from_vector.cpp | Removes unused kokkos_abstractions.h include from 2D vector source array tests. |
| tests/unit-tests/assembly/compute_source_array/dim2/compute_source_array_from_tensor.cpp | Removes unused kokkos_abstractions.h and switches Jacobian test array to Kokkos::View. |
| tests/unit-tests/algorithms/locate.cpp | Replaces specfem::kokkos-based host views and team policy with plain Kokkos View and TeamPolicy<DefaultHostExecutionSpace> for 2D point-location tests. |
| tests/unit-tests/algorithms/dim3/locate_point_fixture.cpp | Removes kokkos_abstractions.h include from 3D locate-point fixtures. |
| tests/unit-tests/algorithms/dim2/locate_point_fixture.hpp | Removes kokkos_abstractions.h include from 2D locate-point fixtures. |
| tests/unit-tests/CMakeLists.txt | Deletes the compare_arrays utility library target and its linkage from affected tests. |
| include/kokkos_abstractions.h | Entire file removed; project now relies on direct Kokkos APIs and the new specfem::kokkos in domain_view.hpp for chunked domain views only. |
| include/enumerations/specfem_enums.hpp | Removes unnecessary include of kokkos_abstractions.h. |
| core/specfem/source_time_functions/source_time_function.hpp | Drops dependency on kokkos_abstractions.h; keeps direct Kokkos_Core.hpp include. |
| core/specfem/source_time_functions/gaussianhdur.hpp | Removes kokkos_abstractions.h include. |
| core/specfem/source_time_functions/gaussian.hpp | Removes kokkos_abstractions.h include. |
| core/specfem/source_time_functions/external.hpp | Removes kokkos_abstractions.h include; still uses enumerations and base STF APIs. |
| core/specfem/source_time_functions/external.cpp | Drops kokkos_abstractions.h include. |
| core/specfem/source_time_functions/dirac.hpp | Removes kokkos_abstractions.h include. |
| core/specfem/source/tensor_source.hpp | Removes kokkos_abstractions.h include from tensor source interface. |
| core/specfem/source/source.tpp | Cleans up includes (removes kokkos_abstractions.h) and rewraps long make_unique calls for clarity. |
| core/specfem/source/source.hpp | Removes kokkos_abstractions.h include from source interface. |
| core/specfem/source/dim3/vector_source/force_source.hpp | Removes kokkos_abstractions.h include from 3D force source header. |
| core/specfem/source/dim3/tensor_source/moment_tensor_source.hpp | Removes kokkos_abstractions.h include from 3D tensor source header. |
| core/specfem/source/dim3/tensor_source/moment_tensor_source.cpp | Drops kokkos_abstractions.h include from 3D moment tensor implementation. |
| core/specfem/source/dim3/source.tpp | Removes kokkos_abstractions.h include and reflows template constructor code. |
| core/specfem/source/dim3/source.cpp | Removes kokkos_abstractions.h include from 3D source implementation. |
| core/specfem/source/dim2/vector_source/force_source.hpp | Removes kokkos_abstractions.h include from 2D force source header. |
| core/specfem/source/dim2/vector_source/external.hpp | Removes kokkos_abstractions.h include from 2D external source header. |
| core/specfem/source/dim2/vector_source/cosserat_force_source.hpp | Removes kokkos_abstractions.h include from Cosserat source header. |
| core/specfem/source/dim2/vector_source/adjoint_source.hpp | Removes kokkos_abstractions.h include from adjoint source header. |
| core/specfem/source/dim2/tensor_source/moment_tensor_source.hpp | Removes kokkos_abstractions.h include and adjusts doc comment wording. |
| core/specfem/source/dim2/tensor_source/moment_tensor_source.cpp | Drops kokkos_abstractions.h include from 2D moment tensor implementation. |
| core/specfem/source/dim2/source.tpp | Removes kokkos_abstractions.h include and reflows constructor template. |
| core/specfem/source/dim2/source.cpp | Removes kokkos_abstractions.h include from 2D source implementation. |
| core/specfem/receivers/dim3/receiver.hpp | Removes kokkos_abstractions.h include from 3D receiver header. |
| core/specfem/receivers/dim3/receiver.cpp | Drops kokkos_abstractions.h include from 3D receiver implementation. |
| core/specfem/receivers/dim2/receiver.hpp | Removes kokkos_abstractions.h include from 2D receiver header. |
| core/specfem/receivers/dim2/receiver.cpp | Drops kokkos_abstractions.h include from 2D receiver implementation. |
| core/specfem/quadrature/quadrature.hpp | Removes kokkos_abstractions.h include; keeps direct Kokkos usage. |
| core/specfem/quadrature/gll/lagrange_poly.hpp | Removes kokkos_abstractions.h include. |
| core/specfem/quadrature/gll/gll_utils.hpp | Removes kokkos_abstractions.h include. |
| core/specfem/quadrature/gll/gll_utils.cpp | Drops kokkos_abstractions.h include from GLL utilities implementation. |
| core/specfem/quadrature/gll/gll_library.hpp | Removes kokkos_abstractions.h include. |
| core/specfem/quadrature/gll/gll.hpp | Removes kokkos_abstractions.h include from core GLL interface. |
| core/specfem/quadrature/gll/gll.cpp | Drops kokkos_abstractions.h include from GLL implementation. |
| core/specfem/program/program.cpp | Drops kokkos_abstractions.h include from main program driver. |
| core/specfem/mesh/dim2/tags/tags.cpp | Removes kokkos_abstractions.h include from 2D tags implementation. |
| core/specfem/mesh/dim2/mpi_interfaces/mpi_interfaces.hpp | Removes unused kokkos_abstractions.h include. |
| core/specfem/mesh/dim2/mesh.cpp | Drops kokkos_abstractions.h include and updates knods to a host Kokkos::View<int **, LayoutRight, DefaultHostExecutionSpace>. |
| core/specfem/mesh/dim2/materials/materials.hpp | Removes kokkos_abstractions.h include from 2D materials header. |
| core/specfem/mesh/dim2/elements/tangential_elements.hpp | Removes unused kokkos_abstractions.h include. |
| core/specfem/mesh/dim2/elements/axial_elements.hpp | Removes unused kokkos_abstractions.h include. |
| core/specfem/mesh/dim2/control_nodes/control_nodes.hpp | Removes kokkos_abstractions.h include from control nodes header. |
| core/specfem/mesh/dim2/boundaries/forcing_boundaries.hpp | Removes unused kokkos_abstractions.h include. |
| core/specfem/jacobian/dim3/jacobian.hpp | Removes kokkos_abstractions.h include from 3D jacobian header. |
| core/specfem/jacobian/dim2/jacobian.hpp | Removes kokkos_abstractions.h include from 2D jacobian header. |
| core/specfem/jacobian.hpp | Drops kokkos_abstractions.h include from jacobian front-end header. |
| core/specfem/io/seismogram/reader.hpp | Replaces specfem::kokkos::HostView2d with explicit Kokkos::View<type_real **, LayoutRight, DefaultHostExecutionSpace> for source-time-function storage. |
| core/specfem/io/property/reader.tpp | Removes kokkos_abstractions.h and reflows FOR_EACH_IN_PRODUCT arguments for properties reading. |
| core/specfem/io/mesh/impl/fortran/dim2/read_mesh_database.hpp | Replaces specfem::kokkos::HostView2d return type with 2D host Kokkos::View for coordinate arrays. |
| core/specfem/io/mesh/impl/fortran/dim2/read_mesh_database.cpp | Implements read_coorg_elements using explicit 2D host Kokkos::View instead of HostView2d. |
| core/specfem/io/mesh/impl/fortran/dim2/read_material_properties.hpp | Updates knods parameter type to a 2D host Kokkos::View<int **, LayoutRight, DefaultHostExecutionSpace>. |
| core/specfem/io/mesh/impl/fortran/dim2/read_material_properties.cpp | Propagates new knods and material_index_mapping view types (Kokkos::View<..., LayoutRight, DefaultHostExecutionSpace>) in material reading and index assignment. |
| core/specfem/io/mesh/impl/fortran/dim2/read_boundaries.cpp | Rewrites boundary helper functions to use only Kokkos View/Subview on DefaultHostExecutionSpace instead of specfem::kokkos views. |
| core/specfem/io/mesh/impl/fortran/dim2/mesh.cpp | Updates mesh.control_nodes.knods to a Kokkos::View<int **, LayoutRight, DefaultHostExecutionSpace> and removes kokkos_abstractions.h. |
| core/specfem/io/impl/medium_writer.tpp | Removes kokkos_abstractions.h usage, switches to DomainView2d alias, and simplifies element index host extraction. |
| core/specfem/io/NPZ/impl/dataset.tpp | Removes specfem::kokkos::HostMemSpace/DevMemSpace in favor of direct Kokkos::HostSpace and DefaultExecutionSpace::memory_space checks for view memory space. |
| core/specfem/io/NPY/impl/dataset.tpp | Same memory-space simplification as NPZ datasets. |
| core/specfem/io/HDF5/impl/dataset.tpp | Same memory-space simplification as NPZ/NPY datasets. |
| core/specfem/io/ASCII/impl/dataset.tpp | Same memory-space simplification as NPZ/NPY datasets. |
| core/specfem/io/ADIOS2/impl/dataset.tpp | Same memory-space simplification and formatting of ADIOS2 dataset I/O path. |
| core/specfem/assembly/sources/dim3/sources.cpp | Removes kokkos_abstractions.h and depends only on core Kokkos APIs for sources assembly. |
| core/specfem/assembly/sources/dim2/sources.cpp | Same as above for 2D sources. |
| core/specfem/assembly/receivers/dim3/receivers.cpp | Removes kokkos_abstractions.h include, retaining pure Kokkos-based receivers assembly. |
| core/specfem/assembly/receivers/dim2/receivers.cpp | Same as above for 2D receivers. |
| core/specfem/assembly/properties/dim3/properties.hpp | Removes kokkos_abstractions.h include from 3D properties header. |
| core/specfem/assembly/properties/dim2/properties.hpp | Removes kokkos_abstractions.h include from 2D properties header. |
| core/specfem/assembly/mesh/dim3/mesh.hpp | Removes kokkos_abstractions.h include from 3D assembly mesh header. |
| core/specfem/assembly/mesh/dim2/mesh.tpp | Drops kokkos_abstractions.h, updates includes ordering, and uses host Kokkos::View in assign_numbering and adjacency graph routines. |
| core/specfem/assembly/mesh/dim2/impl/utilities.hpp | Replaces kokkos_abstractions.h with basic specfem_setup.hpp and standard headers. |
| core/specfem/assembly/jacobian_matrix/dim2/jacobian_matrix.hpp | Removes kokkos_abstractions.h include; public API still uses Kokkos views for Jacobian fields. |
| core/specfem/assembly/jacobian_matrix/dim2/jacobian_matrix.cpp | Keeps use of specfem::kokkos::create_mirror_view / deep_copy (from domain_view.hpp) while dropping kokkos_abstractions.h. |
| core/specfem/assembly/impl/domain_properties.hpp | Replaces specfem::kokkos::HostView1d<int> with Kokkos::View<int *, LayoutRight, DefaultHostExecutionSpace> for property index mappings. |
| core/specfem/assembly/impl/domain_properties.tpp | Same replacement in 2D and 3D domain properties constructors and formatting improvements. |
| core/specfem/assembly/impl/domain_kernels.hpp | Same replacement for domain kernel property index mapping views. |
| core/specfem/assembly/fields/impl/field_impl.hpp | Removes kokkos_abstractions.h, makes base_field use Kokkos::View<..., LayoutLeft, DefaultExecutionSpace>, and replaces templated sync<HostToDevice/DeviceToHost> with explicit copy_to_host / copy_to_device plus host getters (get_host_field*). |
| core/specfem/assembly/fields/impl/field_impl.tpp | Updates field_impl constructor to call a new assign_assembly_index_mapping helper and drops the sync_fields<sync> function in favor of copy_to_host / copy_to_device. |
| core/specfem/assembly/fields/impl/assign_assembly_index_mapping.hpp | Removes kokkos_abstractions.h and ensures only Kokkos and assembly/element_types headers are included. |
| core/specfem/assembly/fields/dim3/simulation_field.hpp | Replaces sync_fields-based copy helpers with copy_to_host / copy_to_device declarations. |
| core/specfem/assembly/fields/dim3/simulation_field.tpp | Implements copy_to_host/copy_to_device by calling field_impl::copy_to_* for each medium; also updates nglob computation to use core helper. |
| core/specfem/assembly/fields/dim3/simulation_field.cpp | Removes explicit instantiation and sync_fields template instantiation TU (simulation fields now fully header-only for 3D). |
| core/specfem/assembly/fields/dim2/simulation_field.hpp | Same pattern as 3D: removes sync-based helpers and declares copy_to_host / copy_to_device. |
| core/specfem/assembly/fields/dim2/simulation_field.tpp | Implements 2D copy_to_host/copy_to_device via new field_impl methods. |
| core/specfem/assembly/fields/dim2/simulation_field.cpp | Removes explicit instantiation and sync_fields instantiation TU for 2D fields. |
| core/specfem/assembly/compute_source_array/dim3/impl/compute_source_array_from_vector.hpp | Removes kokkos_abstractions.h include from compute-source-array helpers. |
| core/specfem/assembly/compute_source_array/dim3/impl/compute_source_array_from_vector.cpp | Same include cleanup for implementation file. |
| core/specfem/assembly/compute_source_array/dim3/impl/compute_source_array_from_tensor.hpp | Same include cleanup for tensor version. |
| core/specfem/assembly/compute_source_array/dim3/impl/compute_source_array_from_tensor.cpp | Same include cleanup for implementation file. |
| core/specfem/assembly/compute_source_array/dim3/compute_source_array.tpp | Cleans includes and makes template parameter name more conventional; computation logic unchanged. |
| core/specfem/assembly/compute_source_array/dim2/impl/compute_source_array_from_vector.hpp | Same include cleanup for 2D vector source array helper. |
| core/specfem/assembly/compute_source_array/dim2/impl/compute_source_array_from_vector.cpp | Same include cleanup for 2D implementation. |
| core/specfem/assembly/compute_source_array/dim2/impl/compute_source_array_from_tensor.hpp | Same include cleanup for 2D tensor helper. |
| core/specfem/assembly/compute_source_array/dim2/impl/compute_source_array_from_tensor.cpp | Same include cleanup for 2D tensor implementation. |
| core/specfem/assembly/compute_source_array/dim2/compute_source_array.tpp | Cleans includes and asserts rank-3 source arrays; logic unchanged. |
| core/specfem/assembly/compute_source_array.hpp | Removes kokkos_abstractions.h include; interface now uses only Kokkos and assembly headers. |
| core/specfem/algorithms/interpolate.hpp | Removes kokkos_abstractions.h include from interpolation algorithms. |
| core/specfem/algorithms/gradient.hpp | Removes kokkos_abstractions.h include; only textual references to specfem::kokkos::array_type remain in static_assert messages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lsawade
approved these changes
Feb 4, 2026
Collaborator
lsawade
left a comment
There was a problem hiding this comment.
LGTM, we can take care of the conflicts if you don't have time before traveling, just let us know
icui
approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Please describe the changes/features in this pull request.
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.