Skip to content

Issue 1330 - Deprecate Kokkos abstractions#1632

Merged
Rohit-Kakodkar merged 4 commits intodevelfrom
issue-1330-deprecate-kokkos-abstractions
Feb 5, 2026
Merged

Issue 1330 - Deprecate Kokkos abstractions#1632
Rohit-Kakodkar merged 4 commits intodevelfrom
issue-1330-deprecate-kokkos-abstractions

Conversation

@Rohit-Kakodkar
Copy link
Collaborator

Description

Please describe the changes/features in this pull request.

  • Removes kokkos abstractions - wrappers to kokkos functions

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

- [x] Removes kokkos abstractions - wrappers to kokkos functions
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.h and all specfem::kokkos view typedefs in favor of explicit Kokkos::View and Kokkos::TeamPolicy / MDRangePolicy usage 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_view and new copy helpers (copy_to_host / copy_to_device).
  • Delete legacy unit-test array comparison utilities (compare_array.hpp/.tpp, utilities/include/interface.hpp, and compare_arrays CMake target) and update affected tests to work without them.

Notable Issues

  1. Layout mismatch in seismogram test helpers (compile-time type incompatibility)

    • In both tests/unit-tests/seismogram/elastic/seismogram_tests.cpp and tests/unit-tests/seismogram/acoustic/seismogram_tests.cpp, read_field is 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_impl as:
      Kokkos::View<type_real **, Kokkos::LayoutLeft, Kokkos::HostSpace>
      field_impl::get_host_field() const;
      // analogous for get_host_field_dot, get_host_field_dot_dot
      (see core/specfem/assembly/fields/impl/field_impl.hpp around get_host_field).
    • The tests pass assembly.fields.forward.elastic.h_field / .h_field_dot / .h_field_dot_dot into read_field. These host field views are consistent with get_host_field*() and thus are LayoutLeft, not LayoutRight.
    • This is a compile-time type mismatch: a Kokkos::View<..., LayoutLeft, HostSpace> cannot bind to a Kokkos::View<..., LayoutRight, HostSpace>&.
    • Suggestion (mandatory): Change read_field’s parameter to use Kokkos::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 appropriate static_assert on rank.
  2. Minor type alias inconsistency in compute_tests.cpp (optional clean-up)

    • In tests/unit-tests/assembly_mesh/index/compute_tests.cpp, the aliases
      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>;
      are defined but never used in the file.
    • On main, these aliases referred to integer-index views (HostView{1,2,3}d<int>), matching their semantic use; changing them to type_real is misleading even though they are currently unused.
    • Suggestion (optional, maintainability): Either remove these unused aliases or restore them to int to match their intended purpose, to avoid confusion for future readers.

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.

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, we can take care of the conflicts if you don't have time before traveling, just let us know

@Rohit-Kakodkar Rohit-Kakodkar merged commit 6091976 into devel Feb 5, 2026
8 checks passed
@Rohit-Kakodkar Rohit-Kakodkar deleted the issue-1330-deprecate-kokkos-abstractions branch February 5, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants