cuda::experimental::stf::data_hash

Defined in include/cuda/experimental/__stf/internal/slice.cuh

template<typename E, typename X, typename L, typename A, size_t... i>
size_t cuda::experimental::stf::data_hash([[maybe_unused]] mdspan<E, X, L, A> s, ::std::index_sequence<i...> = {})

Computes a hash value for the contents of an mdspan.

This function recursively hashes all elements of the provided mdspan using either std::hash<E> or a custom hash function, if available. The hash is computed by traversing the multidimensional array in a dimension-major order and combining the hash values of each element. If neither a standard nor custom hash is available for the element type, the function prints an error and aborts.

The function supports both rank deduction and explicit index sequence specification. When called without an explicit index sequence, it generates one corresponding to the mdspan’s rank.

Note

Requires that either std::hash<E> or a custom hash function for E is defined. If neither is available, the function will print an error and terminate the program.

Note

If the mdspan is empty, the function returns 0.

Template Parameters
  • E – Element type stored in the mdspan.

  • X – Extents type describing the shape of the mdspan.

  • L – Layout policy for the mdspan.

  • A – Accessor policy for the mdspan.

  • i... – Index sequence used for multidimensional traversal (automatically deduced).

Parameters

s[in] The mdspan whose contents will be hashed.

Returns

The combined hash value of all elements in the mdspan.