Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,10 @@ endif(SPECFEM_ENABLE_DOUBLE_PRECISION)

# Add the include directories so that the generated files can be found
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core)
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)

message(STATUS "INCLUDE DIRECTORIES:")
message(STATUS " core: ${CMAKE_CURRENT_SOURCE_DIR}/core")
message(STATUS " include: ${CMAKE_SOURCE_DIR}/include")
message(STATUS " binary: ${CMAKE_BINARY_DIR}/include")


Expand Down
40 changes: 20 additions & 20 deletions core/specfem/assembly/jacobian_matrix/dim2/jacobian_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ specfem::assembly::jacobian_matrix<
gammaz("specfem::assembly::jacobian_matrix::gammaz", nspec, ngllz, ngllx),
jacobian("specfem::assembly::jacobian_matrix::jacobian", nspec, ngllz,
ngllx),
h_xix(specfem::kokkos::create_mirror_view(xix)),
h_xiz(specfem::kokkos::create_mirror_view(xiz)),
h_gammax(specfem::kokkos::create_mirror_view(gammax)),
h_gammaz(specfem::kokkos::create_mirror_view(gammaz)),
h_jacobian(specfem::kokkos::create_mirror_view(jacobian)) {
h_xix(specfem::datatype::create_mirror_view(xix)),
h_xiz(specfem::datatype::create_mirror_view(xiz)),
h_gammax(specfem::datatype::create_mirror_view(gammax)),
h_gammaz(specfem::datatype::create_mirror_view(gammaz)),
h_jacobian(specfem::datatype::create_mirror_view(jacobian)) {
return;
};

Expand All @@ -37,11 +37,11 @@ specfem::assembly::jacobian_matrix<specfem::element::dimension_tag::dim2>::
gammaz("specfem::assembly::jacobian_matrix::gammaz", nspec, ngllz, ngllx),
jacobian("specfem::assembly::jacobian_matrix::jacobian", nspec, ngllz,
ngllx),
h_xix(specfem::kokkos::create_mirror_view(xix)),
h_xiz(specfem::kokkos::create_mirror_view(xiz)),
h_gammax(specfem::kokkos::create_mirror_view(gammax)),
h_gammaz(specfem::kokkos::create_mirror_view(gammaz)),
h_jacobian(specfem::kokkos::create_mirror_view(jacobian)) {
h_xix(specfem::datatype::create_mirror_view(xix)),
h_xiz(specfem::datatype::create_mirror_view(xiz)),
h_gammax(specfem::datatype::create_mirror_view(gammax)),
h_gammaz(specfem::datatype::create_mirror_view(gammaz)),
h_jacobian(specfem::datatype::create_mirror_view(jacobian)) {

const int ngnod = mesh.ngnod;

Expand Down Expand Up @@ -85,22 +85,22 @@ specfem::assembly::jacobian_matrix<specfem::element::dimension_tag::dim2>::
}
};

specfem::kokkos::deep_copy(xix, h_xix);
specfem::kokkos::deep_copy(xiz, h_xiz);
specfem::kokkos::deep_copy(gammax, h_gammax);
specfem::kokkos::deep_copy(gammaz, h_gammaz);
specfem::kokkos::deep_copy(jacobian, h_jacobian);
specfem::datatype::deep_copy(xix, h_xix);
specfem::datatype::deep_copy(xiz, h_xiz);
specfem::datatype::deep_copy(gammax, h_gammax);
specfem::datatype::deep_copy(gammaz, h_gammaz);
specfem::datatype::deep_copy(jacobian, h_jacobian);

return;
}

void specfem::assembly::jacobian_matrix<
specfem::element::dimension_tag::dim2>::sync_views() {
specfem::kokkos::deep_copy(xix, h_xix);
specfem::kokkos::deep_copy(xiz, h_xiz);
specfem::kokkos::deep_copy(gammax, h_gammax);
specfem::kokkos::deep_copy(gammaz, h_gammaz);
specfem::kokkos::deep_copy(jacobian, h_jacobian);
specfem::datatype::deep_copy(xix, h_xix);
specfem::datatype::deep_copy(xiz, h_xiz);
specfem::datatype::deep_copy(gammax, h_gammax);
specfem::datatype::deep_copy(gammaz, h_gammaz);
specfem::datatype::deep_copy(jacobian, h_jacobian);
}

std::tuple<bool, Kokkos::View<bool *, Kokkos::DefaultHostExecutionSpace> >
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "domain_view.hpp"
#include "specfem/datatype.hpp"

#include "specfem/assembly/mesh.hpp"
#include "specfem/data_access.hpp"
Expand Down
8 changes: 4 additions & 4 deletions core/specfem/data_access/container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "accessor.hpp"
#include "data_class.hpp"
#include "domain_view.hpp"
#include "specfem/datatype.hpp"
#include "specfem/enums.hpp"
#include <Kokkos_Core.hpp>

Expand Down Expand Up @@ -30,11 +30,11 @@ template <>
struct ContainerValueType<specfem::data_access::ContainerType::domain,
specfem::element::dimension_tag::dim2> {
template <typename T, typename MemorySpace>
using scalar_type = specfem::kokkos::DomainView2d<T, 3, MemorySpace>;
using scalar_type = specfem::datatype::DomainView2d<T, 3, MemorySpace>;
template <typename T, typename MemorySpace>
using vector_type = specfem::kokkos::DomainView2d<T, 4, MemorySpace>;
using vector_type = specfem::datatype::DomainView2d<T, 4, MemorySpace>;
template <typename T, typename MemorySpace>
using tensor_type = specfem::kokkos::DomainView2d<T, 5, MemorySpace>;
using tensor_type = specfem::datatype::DomainView2d<T, 5, MemorySpace>;
};

template <>
Expand Down
1 change: 1 addition & 0 deletions core/specfem/datatype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace specfem::datatype {}
#include "datatype/accessor_type.hpp"
#include "datatype/chunk_edge_view.hpp"
#include "datatype/chunk_element_view.hpp"
#include "datatype/domain_view.hpp"
#include "datatype/element_view.hpp"
#include "datatype/point_view.hpp"
#include "datatype/simd.hpp"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <tuple>

namespace specfem {
namespace kokkos {
namespace datatype {

namespace impl {
template <int ElementChunkSize, typename Extents>
Expand Down Expand Up @@ -249,17 +249,17 @@ using DomainView =
MemorySpace>;

template <typename ViewType>
specfem::kokkos::View<typename ViewType::value_type,
typename ViewType::extents_type,
typename ViewType::layout_type, Kokkos::HostSpace>
specfem::datatype::View<typename ViewType::value_type,
typename ViewType::extents_type,
typename ViewType::layout_type, Kokkos::HostSpace>
create_mirror_view(const ViewType view) {
if constexpr (std::is_same_v<typename ViewType::memory_space,
Kokkos::HostSpace>) {
return view;
} else if constexpr (std::is_same_v<
typename ViewType::memory_space,
Kokkos::DefaultExecutionSpace::memory_space>) {
return specfem::kokkos::View<
return specfem::datatype::View<
typename ViewType::value_type, typename ViewType::extents_type,
typename ViewType::layout_type, Kokkos::HostSpace>("mirror",
view.get_mapping());
Expand All @@ -272,5 +272,5 @@ template <typename SrcViewType, typename DstViewType>
void deep_copy(const DstViewType dst, const SrcViewType src) {
Kokkos::deep_copy(dst.get_base_view(), src.get_base_view());
}
} // namespace kokkos
} // namespace datatype
} // namespace specfem
4 changes: 2 additions & 2 deletions core/specfem/io/impl/medium_writer.tpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "domain_view.hpp"
#include "specfem/datatype.hpp"
#include "specfem/element.hpp"
#include "specfem/element.hpp"
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

Duplicate include statement. The line #include "specfem/element.hpp" appears twice (lines 4 and 5). Remove one of these duplicate includes.

Suggested change
#include "specfem/element.hpp"

Copilot uses AI. Check for mistakes.
#include "specfem/io/impl/medium_writer.hpp"
Expand All @@ -18,7 +18,7 @@ void specfem::io::impl::write_container(
&element_types,
ContainerType &container) {
using DomainView =
specfem::kokkos::DomainView2d<type_real, 3, Kokkos::HostSpace>;
specfem::datatype::DomainView2d<type_real, 3, Kokkos::HostSpace>;

container.copy_to_host();

Expand Down
28 changes: 14 additions & 14 deletions core/specfem/macros/data_container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
}

#define _DEFINE_DOMAIN_VIEW(r, data, elem) \
specfem::kokkos::DomainView< \
specfem::datatype::DomainView< \
dimension_tag, type_real, \
specfem::element::dimension<dimension_tag>::dim + 1, \
Kokkos::DefaultExecutionSpace::memory_space> \
Expand All @@ -122,7 +122,7 @@

#define _INSTANCE_HOST_VIEW(r, data, elem) \
BOOST_PP_CAT(h_, BOOST_PP_SEQ_ELEM(0, elem)) \
(specfem::kokkos::create_mirror_view(BOOST_PP_SEQ_ELEM(0, elem)))
(specfem::datatype::create_mirror_view(BOOST_PP_SEQ_ELEM(0, elem)))

#define _DATA_DEFINITION(seq) BOOST_PP_SEQ_FOR_EACH(_DEFINE_DOMAIN_VIEW, _, seq)

Expand All @@ -147,12 +147,12 @@
BOOST_PP_SEQ_TRANSFORM(_INSTANCE_HOST_VIEW, _, seq)) {}

#define _SYNC_DEVICE(r, data, elem) \
specfem::kokkos::deep_copy(BOOST_PP_SEQ_ELEM(0, elem), \
BOOST_PP_CAT(h_, BOOST_PP_SEQ_ELEM(0, elem)));
specfem::datatype::deep_copy(BOOST_PP_SEQ_ELEM(0, elem), \
BOOST_PP_CAT(h_, BOOST_PP_SEQ_ELEM(0, elem)));

#define _SYNC_HOST(r, data, elem) \
specfem::kokkos::deep_copy(BOOST_PP_CAT(h_, BOOST_PP_SEQ_ELEM(0, elem)), \
BOOST_PP_SEQ_ELEM(0, elem));
specfem::datatype::deep_copy(BOOST_PP_CAT(h_, BOOST_PP_SEQ_ELEM(0, elem)), \
BOOST_PP_SEQ_ELEM(0, elem));

#define _DATA_SYNCHRONIZE(seq) \
void copy_to_device() { BOOST_PP_SEQ_FOR_EACH(_SYNC_DEVICE, _, seq) } \
Expand Down Expand Up @@ -226,15 +226,15 @@
* data_container(const int nspec, const int ngllz, const int ngllx)
* : rho("rho", nspec, ngllz, ngllx),
* kappa("kappa", nspec, ngllz, ngllx),
* h_rho(specfem::kokkos::create_mirror_view(rho)),
* h_kappa(specfem::kokkos::create_mirror_view(kappa)) {
* h_rho(specfem::datatype::create_mirror_view(rho)),
* h_kappa(specfem::datatype::create_mirror_view(kappa)) {
* static_assert(dimension_tag == specfem::element::dimension_tag::dim2,
* "Calling 2D constructor from non-2D container");
* }
* data_container(const int nspec, const int ngllz, const int nglly, const int
* ngllx) : rho("rho", nspec, ngllz, ngllx), kappa("kappa", nspec, ngllz,
* ngllx), h_rho(specfem::kokkos::create_mirror_view(rho)),
* h_kappa(specfem::kokkos::create_mirror_view(kappa)) {
* ngllx), h_rho(specfem::datatype::create_mirror_view(rho)),
* h_kappa(specfem::datatype::create_mirror_view(kappa)) {
* static_assert(dimension_tag == specfem::element::dimension_tag::dim3,
* "Calling 3D constructor from non-3D container");
* }
Expand All @@ -254,12 +254,12 @@
* f(h_kappa[_index], "kappa");
* }
* void copy_to_device() {
* specfem::kokkos::deep_copy(rho, h_rho);
* specfem::kokkos::deep_copy(kappa, h_kappa);
* specfem::datatype::deep_copy(rho, h_rho);
* specfem::datatype::deep_copy(kappa, h_kappa);
* }
* void copy_to_host() {
* specfem::kokkos::deep_copy(h_rho, rho);
* specfem::kokkos::deep_copy(h_kappa, kappa);
* specfem::datatype::deep_copy(h_rho, rho);
* specfem::datatype::deep_copy(h_kappa, kappa);
* }
* template <typename FunctorType>
* void for_each_device_view(FunctorType f) const {
Expand Down
2 changes: 1 addition & 1 deletion core/specfem/medium_container/impl/domain_container.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "domain_view.hpp"
#include "specfem/datatype.hpp"
#include "specfem/element.hpp"
#include "specfem/macros.hpp"
#include <boost/preprocessor.hpp>
Expand Down
6 changes: 3 additions & 3 deletions core/specfem/parallel_configuration/chunk_config.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include "specfem/constants.hpp"
#include "specfem/datatype.hpp"
#include "specfem/element.hpp"
#include <Kokkos_Core.hpp>
#include <Kokkos_SIMD.hpp>

namespace specfem {

Expand Down Expand Up @@ -33,11 +33,11 @@ constexpr int chunk_size = impl::cuda_chunk_size;
constexpr int storage_chunk_size = impl::hip_chunk_size;
constexpr int chunk_size = impl::hip_chunk_size;
#elif defined(KOKKOS_ENABLE_OPENMP)
constexpr int simd_size = specfem::datatype::simd<type_real, true>::size();
constexpr int simd_size = Kokkos::Experimental::simd<type_real>::size();
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

This change directly uses Kokkos::Experimental::simd<type_real> instead of specfem::datatype::simd<type_real, true>. This bypasses the SPECFEM_ENABLE_SIMD compile-time flag check that exists in the wrapper class. When SPECFEM_ENABLE_SIMD is not defined, the wrapper falls back to Kokkos::Experimental::basic_simd<T, Kokkos::Experimental::simd_abi::scalar>. Directly using Kokkos::Experimental::simd<type_real> may cause different behavior or compilation issues when SPECFEM_ENABLE_SIMD is disabled. Consider using specfem::datatype::simd<type_real, true>::size() to maintain consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.
constexpr int storage_chunk_size = impl::openmp_chunk_size * simd_size;
constexpr int chunk_size = impl::openmp_chunk_size;
#else
constexpr int simd_size = specfem::datatype::simd<type_real, true>::size();
constexpr int simd_size = Kokkos::Experimental::simd<type_real>::size();
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

This change directly uses Kokkos::Experimental::simd<type_real> instead of specfem::datatype::simd<type_real, true>. This bypasses the SPECFEM_ENABLE_SIMD compile-time flag check that exists in the wrapper class. When SPECFEM_ENABLE_SIMD is not defined, the wrapper falls back to Kokkos::Experimental::basic_simd<T, Kokkos::Experimental::simd_abi::scalar>. Directly using Kokkos::Experimental::simd<type_real> may cause different behavior or compilation issues when SPECFEM_ENABLE_SIMD is disabled. Consider using specfem::datatype::simd<type_real, true>::size() to maintain consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.
constexpr int storage_chunk_size = impl::serial_chunk_size * simd_size;
constexpr int chunk_size = impl::serial_chunk_size;
#endif
Expand Down