specfem::datatype::simd

template<typename T, bool UseSIMD>
struct simd

Wrapper around Kokkos::Experimental::native_simd to provide a consistent interface for SIMD operations.

Template Parameters:
  • T – The base type of the SIMD vector.

  • UseSIMD – Whether to use SIMD operations or not. If false, base type is used directly.

SIMD Based Specializations

SIMD Vector Enabled

template<typename T>
struct simd<T, true>

Specialization enabling SIMD operations.

Uses Kokkos SIMD types when available, falls back to scalar operations.

Template Parameters:

T – Base scalar type for SIMD vector

Public Types

using base_type = T

Base scalar type.

using datatype = Kokkos::Experimental::basic_simd<T, Kokkos::Experimental::simd_abi::scalar>

SIMD vector type (scalar fallback)

using mask_type = typename datatype::mask_type

SIMD mask type for conditional operations.

using tag_type = Kokkos::Experimental::element_aligned_tag

Memory alignment tag for SIMD operations.

Public Static Functions

static inline constexpr int size()

Returns the size of the SIMD vector.

Returns:

constexpr static int The size of the SIMD vector.

Public Static Attributes

static constexpr bool using_simd = true

SIMD operations enabled.

SIMD Vector Disabled

template<typename T>
struct simd<T, false>

Specialization of simd for when UseSIMD is false.

Template Parameters:

T – The base type of the SIMD vector.

Public Types

using base_type = T

The base type of the SIMD vector.

using datatype = T

The type of the SIMD vector. In this case, it is the same as the base type.

using mask_type = bool

The type of the mask used for SIMD operations.

Public Static Functions

static inline constexpr int size()

Returns the size of the SIMD vector.

Returns:

constexpr static int The size of the SIMD vector.

Public Static Attributes

static constexpr bool using_simd = false

Whether SIMD operations are used or not.

specfem::datatype::simd_like

template<typename T, typename simd_type, bool UseSIMD>
struct simd_like

SIMD like data type that can be used when SIMD operations are not defined for type T.

Template Parameters:
  • T – Type of the data.

  • simd_type – Type of mask used for SIMD operations.

  • UseSIMD – Whether to use SIMD operations or not.

Public Types

using datatype = impl::simd_like_value_type<T, simd_type, UseSIMD>

The data type.

using base_type = T

The base type of the data type.

using mask_type = typename datatype::mask_type

The type of the mask used for SIMD operations.

Public Static Functions

static inline constexpr int size()

Returns the size of the SIMD vector.

Returns:

constexpr static int The size of the SIMD vector.

Public Static Attributes

static constexpr bool using_simd = UseSIMD

Whether SIMD operations are used or not.

specfem::datatype::is_simd_mask

template<typename T>
struct is_simd_mask : public std::false_type

Type trait to detect SIMD mask types.

Template Parameters:

T – Type to check

specfem::datatype::all_of

template<typename mask_type>
bool specfem::datatype::all_of(const mask_type &mask)

Check if all mask elements are true.

Efficiently evaluates mask conditions using SIMD operations when available. Falls back to scalar boolean check for non-SIMD masks.

Template Parameters:

mask_type – SIMD mask or boolean type

Parameters:

mask – Mask to evaluate

Returns:

True if all elements are true