Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Namespaces | Classes | Enumerations | Functions | Variables
shamalgs::primitives Namespace Reference

namespace for primitive algorithm (e.g. sort, scan, reductions, ...) More...

Namespaces

namespace  impl
 namespace to control implementation behavior
 

Classes

class  ImplControl
 

Enumerations

enum class  IS_ALL_TRUE_IMPL : u32 { HOST , SUM_REDUCTION }
 
enum class  REDUCTION_IMPL : u32 { FALLBACK }
 
enum class  EXSCAN_IN_PLACE_IMPL : u32 { STD_SCAN }
 

Functions

template<class T >
void append_subset_to (const sham::DeviceBuffer< T > &buf, const sham::DeviceBuffer< u32 > &idxs_buf, u32 nvar, sham::DeviceBuffer< T > &buf_other, u32 start_enque)
 Appends a subset of elements from one buffer to another.
 
template<class Tkey >
constexpr void binary_range_search (const Tkey *__restrict__ key, u32 first, u32 last, const Tkey &value_min, const Tkey &value_max, u32 &inf, u32 &sup)
 Find the range of indices for which key[inf] <= value_min <= value_max <= key[sup].
 
template<class T , class Tbins , class... Targs, class Tfunctor >
sham::DeviceBuffer< T > compute_histogram (const sham::DeviceScheduler_ptr &dev_sched, const sham::DeviceBuffer< Tbins > &bin_edge_inf, const sham::DeviceBuffer< Tbins > &bin_edge_sup, size_t element_count, Tfunctor &&functor, const sham::DeviceBuffer< Targs > &...input_data)
 
template<class T >
sham::DeviceBuffer< T > compute_histogram_basic (const sham::DeviceScheduler_ptr &dev_sched, const sham::DeviceBuffer< T > &bin_edge_inf, const sham::DeviceBuffer< T > &bin_edge_sup, const sham::DeviceBuffer< T > &positions)
 
template<class T >
shambase::VecComponent< T > dot_sum (sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
 Compute the sum of dot products of elements in a device buffer with themselves.
 
template<class T >
shambase::VecComponent< T > dot_sum (sham::DeviceBuffer< T > &buf1)
 
template<class T >
bool equals (sycl::queue &q, sycl::buffer< T > &buf1, sycl::buffer< T > &buf2, u32 cnt)
 Compare elements between two sycl::buffers for equality.
 
template<class T >
bool equals (const sham::DeviceScheduler_ptr &dev_sched, sham::DeviceBuffer< T > &buf1, sham::DeviceBuffer< T > &buf2, u32 cnt)
 Compare elements between two sham::DeviceBuffers for equality.
 
template<class T >
bool equals (const sham::DeviceScheduler_ptr &q, sham::DeviceBuffer< T > &buf1, sham::DeviceBuffer< T > &buf2)
 Compare all elements between two sham::DeviceBuffers for equality.
 
template<class T >
bool equals (sycl::queue &q, sycl::buffer< T > &buf1, sycl::buffer< T > &buf2)
 Compare all elements between two sycl::buffers for equality.
 
template<class T >
bool equals_ptr_s (sycl::queue &q, const std::unique_ptr< sycl::buffer< T > > &buf1, const std::unique_ptr< sycl::buffer< T > > &buf2, u32 cnt)
 Compare elements between two unique_ptr-wrapped sycl::buffers with count.
 
template<class T >
bool equals_ptr (sycl::queue &q, const std::unique_ptr< sycl::buffer< T > > &buf1, const std::unique_ptr< sycl::buffer< T > > &buf2)
 Compare all elements between two unique_ptr-wrapped sycl::buffers.
 
template<class Tvec , sham::USMKindTarget target>
sham::DeviceBuffer< typename shambase::VectorProperties< Tvec >::component_type, target > flatten_buffer (const sham::DeviceBuffer< Tvec, target > &buffer)
 Flatten a buffer of vector type into a buffer of scalar type.
 
template<class Tvec , sham::USMKindTarget target>
sham::DeviceBuffer< Tvec, target > unflatten_buffer (const sham::DeviceBuffer< typename shambase::VectorProperties< Tvec >::component_type, target > &buffer)
 Unflatten a buffer that contains a flattened vector.
 
sham::DeviceBuffer< u32gen_buffer_index (sham::DeviceScheduler_ptr sched, u32 len)
 Generates a buffer where buf[i] = i.
 
void fill_buffer_index (sham::DeviceBuffer< u32 > &buf, u32 len)
 Fills a buffer with sequential indices, such that buf[i] = i.
 
template<class T >
bool is_all_true (sycl::buffer< T > &buf, u32 cnt)
 Check if all elements in a sycl::buffer are non-zero.
 
template<class T >
bool is_all_true (sham::DeviceBuffer< T > &buf, u32 cnt)
 Check if all elements in a sham::DeviceBuffer are non-zero.
 
template<typename Tval >
sham::DeviceBuffer< Tval > linspace (Tval Rmin, Tval Rmax, u32 N)
 Create an array of N values between two values.
 
template<class Tkey >
constexpr u32 binary_search_lower_bound (const Tkey *__restrict__ key, u32 first, u32 last, const Tkey &value)
 GPU compatible implementation of std::lower_bound.
 
template<class T , class Engine = std::mt19937>
mock_value (Engine &eng, T min_bound, T max_bound)
 Generates a random mock value within specified bounds.
 
template<class T , class Engine = std::mt19937>
mock_value (Engine &eng)
 Generates a random mock value using default bounds.
 
template<class T >
std::vector< T > mock_vector (u64 seed, u32 len, T min_bound, T max_bound)
 Generates a vector of random mock values within specified bounds.
 
template<class T >
std::vector< T > mock_vector (u64 seed, u32 len)
 Generates a vector of random mock values using default bounds.
 
template<class T >
sum (const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
 Compute the sum of elements in a device buffer within a specified range.
 
template<class T >
min (const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
 Find the minimum element in a device buffer within a specified range.
 
template<class T >
max (const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
 Find the maximum element in a device buffer within a specified range.
 
template<class T >
void scan_exclusive_sum_in_place (sham::DeviceBuffer< T > &buf1, u32 len)
 Compute exclusive prefix sum in-place on a device buffer.
 
template<class T >
void segmented_sort_in_place (sham::DeviceBuffer< T > &buf, const sham::DeviceBuffer< u32 > &offsets)
 
template<class Tkey , class Tval >
void sort_by_key_pow2_len (sycl::queue &q, sycl::buffer< Tkey > &buf_key, sycl::buffer< Tval > &buf_values, u32 len)
 Sort key-value pairs using sycl::buffers (power-of-2 optimized)
 
template<class Tkey , class Tval >
void sort_by_key_pow2_len (const sham::DeviceScheduler_ptr &sched, sham::DeviceBuffer< Tkey > &buf_key, sham::DeviceBuffer< Tval > &buf_values, u32 len)
 Sort key-value pairs using USM buffers (power-of-2 optimized)
 
template<class Tkey , class Tval >
void sort_by_key (sycl::queue &q, sycl::buffer< Tkey > &buf_key, sycl::buffer< Tval > &buf_values, u32 len)
 Sort key-value pairs using sycl::buffers.
 
template<class Tkey , class Tval >
void sort_by_key (const sham::DeviceScheduler_ptr &sched, sham::DeviceBuffer< Tkey > &buf_key, sham::DeviceBuffer< Tval > &buf_values, u32 len)
 Sort key-value pairs using USM buffers.
 
template<class Tkey >
constexpr u32 binary_search_upper_bound (const Tkey *__restrict__ key, u32 first, u32 last, const Tkey &value)
 GPU compatible implementation of std::upper_bound.
 
IS_ALL_TRUE_IMPL is_all_true_impl_from_params (const std::string &impl)
 
shamalgs::impl_param is_all_true_impl_to_params (const IS_ALL_TRUE_IMPL &impl)
 
template bool is_all_true (sham::DeviceBuffer< u8 > &buf, u32 cnt)
 
template<>
u8 mock_value (std::mt19937 &eng, u8 min_bound, u8 max_bound)
 
template<>
u16 mock_value (std::mt19937 &eng, u16 min_bound, u16 max_bound)
 
template<>
u32 mock_value (std::mt19937 &eng, u32 min_bound, u32 max_bound)
 
template<>
u64 mock_value (std::mt19937 &eng, u64 min_bound, u64 max_bound)
 
template<>
i8 mock_value (std::mt19937 &eng, i8 min_bound, i8 max_bound)
 
template<>
i16 mock_value (std::mt19937 &eng, i16 min_bound, i16 max_bound)
 
template<>
i32 mock_value (std::mt19937 &eng, i32 min_bound, i32 max_bound)
 
template<>
i64 mock_value (std::mt19937 &eng, i64 min_bound, i64 max_bound)
 
template<>
f32 mock_value (std::mt19937 &eng, f32 min_bound, f32 max_bound)
 
template<>
f64 mock_value (std::mt19937 &eng, f64 min_bound, f64 max_bound)
 
template<>
sycl::vec< u64, 2 > mock_value (std::mt19937 &eng, sycl::vec< u64, 2 > min_bound, sycl::vec< u64, 2 > max_bound)
 
template<>
sycl::vec< u64, 3 > mock_value (std::mt19937 &eng, sycl::vec< u64, 3 > min_bound, sycl::vec< u64, 3 > max_bound)
 
template<>
sycl::vec< u64, 4 > mock_value (std::mt19937 &eng, sycl::vec< u64, 4 > min_bound, sycl::vec< u64, 4 > max_bound)
 
template<>
sycl::vec< u64, 8 > mock_value (std::mt19937 &eng, sycl::vec< u64, 8 > min_bound, sycl::vec< u64, 8 > max_bound)
 
template<>
sycl::vec< u64, 16 > mock_value (std::mt19937 &eng, sycl::vec< u64, 16 > min_bound, sycl::vec< u64, 16 > max_bound)
 
template<>
sycl::vec< u32, 2 > mock_value (std::mt19937 &eng, sycl::vec< u32, 2 > min_bound, sycl::vec< u32, 2 > max_bound)
 
template<>
sycl::vec< u32, 3 > mock_value (std::mt19937 &eng, sycl::vec< u32, 3 > min_bound, sycl::vec< u32, 3 > max_bound)
 
template<>
sycl::vec< u32, 4 > mock_value (std::mt19937 &eng, sycl::vec< u32, 4 > min_bound, sycl::vec< u32, 4 > max_bound)
 
template<>
sycl::vec< u32, 8 > mock_value (std::mt19937 &eng, sycl::vec< u32, 8 > min_bound, sycl::vec< u32, 8 > max_bound)
 
template<>
sycl::vec< u32, 16 > mock_value (std::mt19937 &eng, sycl::vec< u32, 16 > min_bound, sycl::vec< u32, 16 > max_bound)
 
template<>
sycl::vec< u16, 2 > mock_value (std::mt19937 &eng, sycl::vec< u16, 2 > min_bound, sycl::vec< u16, 2 > max_bound)
 
template<>
sycl::vec< u16, 3 > mock_value (std::mt19937 &eng, sycl::vec< u16, 3 > min_bound, sycl::vec< u16, 3 > max_bound)
 
template<>
sycl::vec< u16, 4 > mock_value (std::mt19937 &eng, sycl::vec< u16, 4 > min_bound, sycl::vec< u16, 4 > max_bound)
 
template<>
sycl::vec< u16, 8 > mock_value (std::mt19937 &eng, sycl::vec< u16, 8 > min_bound, sycl::vec< u16, 8 > max_bound)
 
template<>
sycl::vec< u16, 16 > mock_value (std::mt19937 &eng, sycl::vec< u16, 16 > min_bound, sycl::vec< u16, 16 > max_bound)
 
template<>
sycl::vec< u8, 2 > mock_value (std::mt19937 &eng, sycl::vec< u8, 2 > min_bound, sycl::vec< u8, 2 > max_bound)
 
template<>
sycl::vec< u8, 3 > mock_value (std::mt19937 &eng, sycl::vec< u8, 3 > min_bound, sycl::vec< u8, 3 > max_bound)
 
template<>
sycl::vec< u8, 4 > mock_value (std::mt19937 &eng, sycl::vec< u8, 4 > min_bound, sycl::vec< u8, 4 > max_bound)
 
template<>
sycl::vec< u8, 8 > mock_value (std::mt19937 &eng, sycl::vec< u8, 8 > min_bound, sycl::vec< u8, 8 > max_bound)
 
template<>
sycl::vec< u8, 16 > mock_value (std::mt19937 &eng, sycl::vec< u8, 16 > min_bound, sycl::vec< u8, 16 > max_bound)
 
template<>
sycl::vec< i64, 2 > mock_value (std::mt19937 &eng, sycl::vec< i64, 2 > min_bound, sycl::vec< i64, 2 > max_bound)
 
template<>
sycl::vec< i64, 3 > mock_value (std::mt19937 &eng, sycl::vec< i64, 3 > min_bound, sycl::vec< i64, 3 > max_bound)
 
template<>
sycl::vec< i64, 4 > mock_value (std::mt19937 &eng, sycl::vec< i64, 4 > min_bound, sycl::vec< i64, 4 > max_bound)
 
template<>
sycl::vec< i64, 8 > mock_value (std::mt19937 &eng, sycl::vec< i64, 8 > min_bound, sycl::vec< i64, 8 > max_bound)
 
template<>
sycl::vec< i64, 16 > mock_value (std::mt19937 &eng, sycl::vec< i64, 16 > min_bound, sycl::vec< i64, 16 > max_bound)
 
template<>
sycl::vec< i32, 2 > mock_value (std::mt19937 &eng, sycl::vec< i32, 2 > min_bound, sycl::vec< i32, 2 > max_bound)
 
template<>
sycl::vec< i32, 3 > mock_value (std::mt19937 &eng, sycl::vec< i32, 3 > min_bound, sycl::vec< i32, 3 > max_bound)
 
template<>
sycl::vec< i32, 4 > mock_value (std::mt19937 &eng, sycl::vec< i32, 4 > min_bound, sycl::vec< i32, 4 > max_bound)
 
template<>
sycl::vec< i32, 8 > mock_value (std::mt19937 &eng, sycl::vec< i32, 8 > min_bound, sycl::vec< i32, 8 > max_bound)
 
template<>
sycl::vec< i32, 16 > mock_value (std::mt19937 &eng, sycl::vec< i32, 16 > min_bound, sycl::vec< i32, 16 > max_bound)
 
template<>
sycl::vec< i16, 2 > mock_value (std::mt19937 &eng, sycl::vec< i16, 2 > min_bound, sycl::vec< i16, 2 > max_bound)
 
template<>
sycl::vec< i16, 3 > mock_value (std::mt19937 &eng, sycl::vec< i16, 3 > min_bound, sycl::vec< i16, 3 > max_bound)
 
template<>
sycl::vec< i16, 4 > mock_value (std::mt19937 &eng, sycl::vec< i16, 4 > min_bound, sycl::vec< i16, 4 > max_bound)
 
template<>
sycl::vec< i16, 8 > mock_value (std::mt19937 &eng, sycl::vec< i16, 8 > min_bound, sycl::vec< i16, 8 > max_bound)
 
template<>
sycl::vec< i16, 16 > mock_value (std::mt19937 &eng, sycl::vec< i16, 16 > min_bound, sycl::vec< i16, 16 > max_bound)
 
template<>
sycl::vec< i8, 2 > mock_value (std::mt19937 &eng, sycl::vec< i8, 2 > min_bound, sycl::vec< i8, 2 > max_bound)
 
template<>
sycl::vec< i8, 3 > mock_value (std::mt19937 &eng, sycl::vec< i8, 3 > min_bound, sycl::vec< i8, 3 > max_bound)
 
template<>
sycl::vec< i8, 4 > mock_value (std::mt19937 &eng, sycl::vec< i8, 4 > min_bound, sycl::vec< i8, 4 > max_bound)
 
template<>
sycl::vec< i8, 8 > mock_value (std::mt19937 &eng, sycl::vec< i8, 8 > min_bound, sycl::vec< i8, 8 > max_bound)
 
template<>
sycl::vec< i8, 16 > mock_value (std::mt19937 &eng, sycl::vec< i8, 16 > min_bound, sycl::vec< i8, 16 > max_bound)
 
template<>
sycl::vec< f64, 2 > mock_value (std::mt19937 &eng, sycl::vec< f64, 2 > min_bound, sycl::vec< f64, 2 > max_bound)
 
template<>
sycl::vec< f64, 3 > mock_value (std::mt19937 &eng, sycl::vec< f64, 3 > min_bound, sycl::vec< f64, 3 > max_bound)
 
template<>
sycl::vec< f64, 4 > mock_value (std::mt19937 &eng, sycl::vec< f64, 4 > min_bound, sycl::vec< f64, 4 > max_bound)
 
template<>
sycl::vec< f64, 8 > mock_value (std::mt19937 &eng, sycl::vec< f64, 8 > min_bound, sycl::vec< f64, 8 > max_bound)
 
template<>
sycl::vec< f64, 16 > mock_value (std::mt19937 &eng, sycl::vec< f64, 16 > min_bound, sycl::vec< f64, 16 > max_bound)
 
template<>
sycl::vec< f32, 2 > mock_value (std::mt19937 &eng, sycl::vec< f32, 2 > min_bound, sycl::vec< f32, 2 > max_bound)
 
template<>
sycl::vec< f32, 3 > mock_value (std::mt19937 &eng, sycl::vec< f32, 3 > min_bound, sycl::vec< f32, 3 > max_bound)
 
template<>
sycl::vec< f32, 4 > mock_value (std::mt19937 &eng, sycl::vec< f32, 4 > min_bound, sycl::vec< f32, 4 > max_bound)
 
template<>
sycl::vec< f32, 8 > mock_value (std::mt19937 &eng, sycl::vec< f32, 8 > min_bound, sycl::vec< f32, 8 > max_bound)
 
template<>
sycl::vec< f32, 16 > mock_value (std::mt19937 &eng, sycl::vec< f32, 16 > min_bound, sycl::vec< f32, 16 > max_bound)
 
template<>
u8 mock_value (std::mt19937_64 &eng, u8 min_bound, u8 max_bound)
 
template<>
u16 mock_value (std::mt19937_64 &eng, u16 min_bound, u16 max_bound)
 
template<>
u32 mock_value (std::mt19937_64 &eng, u32 min_bound, u32 max_bound)
 
template<>
u64 mock_value (std::mt19937_64 &eng, u64 min_bound, u64 max_bound)
 
template<>
i8 mock_value (std::mt19937_64 &eng, i8 min_bound, i8 max_bound)
 
template<>
i16 mock_value (std::mt19937_64 &eng, i16 min_bound, i16 max_bound)
 
template<>
i32 mock_value (std::mt19937_64 &eng, i32 min_bound, i32 max_bound)
 
template<>
i64 mock_value (std::mt19937_64 &eng, i64 min_bound, i64 max_bound)
 
template<>
f32 mock_value (std::mt19937_64 &eng, f32 min_bound, f32 max_bound)
 
template<>
f64 mock_value (std::mt19937_64 &eng, f64 min_bound, f64 max_bound)
 
template<>
sycl::vec< u64, 2 > mock_value (std::mt19937_64 &eng, sycl::vec< u64, 2 > min_bound, sycl::vec< u64, 2 > max_bound)
 
template<>
sycl::vec< u64, 3 > mock_value (std::mt19937_64 &eng, sycl::vec< u64, 3 > min_bound, sycl::vec< u64, 3 > max_bound)
 
template<>
sycl::vec< u64, 4 > mock_value (std::mt19937_64 &eng, sycl::vec< u64, 4 > min_bound, sycl::vec< u64, 4 > max_bound)
 
template<>
sycl::vec< u64, 8 > mock_value (std::mt19937_64 &eng, sycl::vec< u64, 8 > min_bound, sycl::vec< u64, 8 > max_bound)
 
template<>
sycl::vec< u64, 16 > mock_value (std::mt19937_64 &eng, sycl::vec< u64, 16 > min_bound, sycl::vec< u64, 16 > max_bound)
 
template<>
sycl::vec< u32, 2 > mock_value (std::mt19937_64 &eng, sycl::vec< u32, 2 > min_bound, sycl::vec< u32, 2 > max_bound)
 
template<>
sycl::vec< u32, 3 > mock_value (std::mt19937_64 &eng, sycl::vec< u32, 3 > min_bound, sycl::vec< u32, 3 > max_bound)
 
template<>
sycl::vec< u32, 4 > mock_value (std::mt19937_64 &eng, sycl::vec< u32, 4 > min_bound, sycl::vec< u32, 4 > max_bound)
 
template<>
sycl::vec< u32, 8 > mock_value (std::mt19937_64 &eng, sycl::vec< u32, 8 > min_bound, sycl::vec< u32, 8 > max_bound)
 
template<>
sycl::vec< u32, 16 > mock_value (std::mt19937_64 &eng, sycl::vec< u32, 16 > min_bound, sycl::vec< u32, 16 > max_bound)
 
template<>
sycl::vec< u16, 2 > mock_value (std::mt19937_64 &eng, sycl::vec< u16, 2 > min_bound, sycl::vec< u16, 2 > max_bound)
 
template<>
sycl::vec< u16, 3 > mock_value (std::mt19937_64 &eng, sycl::vec< u16, 3 > min_bound, sycl::vec< u16, 3 > max_bound)
 
template<>
sycl::vec< u16, 4 > mock_value (std::mt19937_64 &eng, sycl::vec< u16, 4 > min_bound, sycl::vec< u16, 4 > max_bound)
 
template<>
sycl::vec< u16, 8 > mock_value (std::mt19937_64 &eng, sycl::vec< u16, 8 > min_bound, sycl::vec< u16, 8 > max_bound)
 
template<>
sycl::vec< u16, 16 > mock_value (std::mt19937_64 &eng, sycl::vec< u16, 16 > min_bound, sycl::vec< u16, 16 > max_bound)
 
template<>
sycl::vec< u8, 2 > mock_value (std::mt19937_64 &eng, sycl::vec< u8, 2 > min_bound, sycl::vec< u8, 2 > max_bound)
 
template<>
sycl::vec< u8, 3 > mock_value (std::mt19937_64 &eng, sycl::vec< u8, 3 > min_bound, sycl::vec< u8, 3 > max_bound)
 
template<>
sycl::vec< u8, 4 > mock_value (std::mt19937_64 &eng, sycl::vec< u8, 4 > min_bound, sycl::vec< u8, 4 > max_bound)
 
template<>
sycl::vec< u8, 8 > mock_value (std::mt19937_64 &eng, sycl::vec< u8, 8 > min_bound, sycl::vec< u8, 8 > max_bound)
 
template<>
sycl::vec< u8, 16 > mock_value (std::mt19937_64 &eng, sycl::vec< u8, 16 > min_bound, sycl::vec< u8, 16 > max_bound)
 
template<>
sycl::vec< i64, 2 > mock_value (std::mt19937_64 &eng, sycl::vec< i64, 2 > min_bound, sycl::vec< i64, 2 > max_bound)
 
template<>
sycl::vec< i64, 3 > mock_value (std::mt19937_64 &eng, sycl::vec< i64, 3 > min_bound, sycl::vec< i64, 3 > max_bound)
 
template<>
sycl::vec< i64, 4 > mock_value (std::mt19937_64 &eng, sycl::vec< i64, 4 > min_bound, sycl::vec< i64, 4 > max_bound)
 
template<>
sycl::vec< i64, 8 > mock_value (std::mt19937_64 &eng, sycl::vec< i64, 8 > min_bound, sycl::vec< i64, 8 > max_bound)
 
template<>
sycl::vec< i64, 16 > mock_value (std::mt19937_64 &eng, sycl::vec< i64, 16 > min_bound, sycl::vec< i64, 16 > max_bound)
 
template<>
sycl::vec< i32, 2 > mock_value (std::mt19937_64 &eng, sycl::vec< i32, 2 > min_bound, sycl::vec< i32, 2 > max_bound)
 
template<>
sycl::vec< i32, 3 > mock_value (std::mt19937_64 &eng, sycl::vec< i32, 3 > min_bound, sycl::vec< i32, 3 > max_bound)
 
template<>
sycl::vec< i32, 4 > mock_value (std::mt19937_64 &eng, sycl::vec< i32, 4 > min_bound, sycl::vec< i32, 4 > max_bound)
 
template<>
sycl::vec< i32, 8 > mock_value (std::mt19937_64 &eng, sycl::vec< i32, 8 > min_bound, sycl::vec< i32, 8 > max_bound)
 
template<>
sycl::vec< i32, 16 > mock_value (std::mt19937_64 &eng, sycl::vec< i32, 16 > min_bound, sycl::vec< i32, 16 > max_bound)
 
template<>
sycl::vec< i16, 2 > mock_value (std::mt19937_64 &eng, sycl::vec< i16, 2 > min_bound, sycl::vec< i16, 2 > max_bound)
 
template<>
sycl::vec< i16, 3 > mock_value (std::mt19937_64 &eng, sycl::vec< i16, 3 > min_bound, sycl::vec< i16, 3 > max_bound)
 
template<>
sycl::vec< i16, 4 > mock_value (std::mt19937_64 &eng, sycl::vec< i16, 4 > min_bound, sycl::vec< i16, 4 > max_bound)
 
template<>
sycl::vec< i16, 8 > mock_value (std::mt19937_64 &eng, sycl::vec< i16, 8 > min_bound, sycl::vec< i16, 8 > max_bound)
 
template<>
sycl::vec< i16, 16 > mock_value (std::mt19937_64 &eng, sycl::vec< i16, 16 > min_bound, sycl::vec< i16, 16 > max_bound)
 
template<>
sycl::vec< i8, 2 > mock_value (std::mt19937_64 &eng, sycl::vec< i8, 2 > min_bound, sycl::vec< i8, 2 > max_bound)
 
template<>
sycl::vec< i8, 3 > mock_value (std::mt19937_64 &eng, sycl::vec< i8, 3 > min_bound, sycl::vec< i8, 3 > max_bound)
 
template<>
sycl::vec< i8, 4 > mock_value (std::mt19937_64 &eng, sycl::vec< i8, 4 > min_bound, sycl::vec< i8, 4 > max_bound)
 
template<>
sycl::vec< i8, 8 > mock_value (std::mt19937_64 &eng, sycl::vec< i8, 8 > min_bound, sycl::vec< i8, 8 > max_bound)
 
template<>
sycl::vec< i8, 16 > mock_value (std::mt19937_64 &eng, sycl::vec< i8, 16 > min_bound, sycl::vec< i8, 16 > max_bound)
 
template<>
sycl::vec< f64, 2 > mock_value (std::mt19937_64 &eng, sycl::vec< f64, 2 > min_bound, sycl::vec< f64, 2 > max_bound)
 
template<>
sycl::vec< f64, 3 > mock_value (std::mt19937_64 &eng, sycl::vec< f64, 3 > min_bound, sycl::vec< f64, 3 > max_bound)
 
template<>
sycl::vec< f64, 4 > mock_value (std::mt19937_64 &eng, sycl::vec< f64, 4 > min_bound, sycl::vec< f64, 4 > max_bound)
 
template<>
sycl::vec< f64, 8 > mock_value (std::mt19937_64 &eng, sycl::vec< f64, 8 > min_bound, sycl::vec< f64, 8 > max_bound)
 
template<>
sycl::vec< f64, 16 > mock_value (std::mt19937_64 &eng, sycl::vec< f64, 16 > min_bound, sycl::vec< f64, 16 > max_bound)
 
template<>
sycl::vec< f32, 2 > mock_value (std::mt19937_64 &eng, sycl::vec< f32, 2 > min_bound, sycl::vec< f32, 2 > max_bound)
 
template<>
sycl::vec< f32, 3 > mock_value (std::mt19937_64 &eng, sycl::vec< f32, 3 > min_bound, sycl::vec< f32, 3 > max_bound)
 
template<>
sycl::vec< f32, 4 > mock_value (std::mt19937_64 &eng, sycl::vec< f32, 4 > min_bound, sycl::vec< f32, 4 > max_bound)
 
template<>
sycl::vec< f32, 8 > mock_value (std::mt19937_64 &eng, sycl::vec< f32, 8 > min_bound, sycl::vec< f32, 8 > max_bound)
 
template<>
sycl::vec< f32, 16 > mock_value (std::mt19937_64 &eng, sycl::vec< f32, 16 > min_bound, sycl::vec< f32, 16 > max_bound)
 
REDUCTION_IMPL get_default_reduction_impl ()
 
REDUCTION_IMPL reduction_impl_from_params (const std::string &impl)
 
shamalgs::impl_param reduction_impl_to_params (const REDUCTION_IMPL &impl)
 
EXSCAN_IN_PLACE_IMPL get_default_scan_exclusive_sum_in_place_impl ()
 
EXSCAN_IN_PLACE_IMPL scan_exclusive_sum_in_place_impl_from_params (const std::string &impl)
 
shamalgs::impl_param scan_exclusive_sum_in_place_impl_to_params (const EXSCAN_IN_PLACE_IMPL &impl)
 
template void scan_exclusive_sum_in_place< u32 > (sham::DeviceBuffer< u32 > &buf1, u32 len)
 
template<class T , class Comp >
void internal_segmented_sort_in_place (sham::DeviceBuffer< T > &buf, const sham::DeviceBuffer< u32 > &offsets, Comp &&comp)
 
template<>
void segmented_sort_in_place< u32_2 > (sham::DeviceBuffer< u32_2 > &buf, const sham::DeviceBuffer< u32 > &offsets)
 
template<>
void segmented_sort_in_place< u32 > (sham::DeviceBuffer< u32 > &buf, const sham::DeviceBuffer< u32 > &offsets)
 
template void sort_by_key_pow2_len (sycl::queue &q, sycl::buffer< u32 > &buf_key, sycl::buffer< u32 > &buf_values, u32 len)
 
template void sort_by_key_pow2_len (sycl::queue &q, sycl::buffer< u64 > &buf_key, sycl::buffer< u32 > &buf_values, u32 len)
 
template void sort_by_key_pow2_len (const sham::DeviceScheduler_ptr &sched, sham::DeviceBuffer< u32 > &buf_key, sham::DeviceBuffer< u32 > &buf_values, u32 len)
 
template void sort_by_key_pow2_len (const sham::DeviceScheduler_ptr &sched, sham::DeviceBuffer< u64 > &buf_key, sham::DeviceBuffer< u32 > &buf_values, u32 len)
 
template void sort_by_key_pow2_len (const sham::DeviceScheduler_ptr &sched, sham::DeviceBuffer< f64 > &buf_key, sham::DeviceBuffer< f64 > &buf_values, u32 len)
 
template void sort_by_key_pow2_len (const sham::DeviceScheduler_ptr &sched, sham::DeviceBuffer< f32 > &buf_key, sham::DeviceBuffer< f32 > &buf_values, u32 len)
 

Variables

IS_ALL_TRUE_IMPL is_all_true_impl = IS_ALL_TRUE_IMPL::HOST
 
REDUCTION_IMPL reduction_impl = get_default_reduction_impl()
 
EXSCAN_IN_PLACE_IMPL scan_exclusive_sum_in_place_impl = get_default_scan_exclusive_sum_in_place_impl()
 

Detailed Description

namespace for primitive algorithm (e.g. sort, scan, reductions, ...)

Enumeration Type Documentation

◆ EXSCAN_IN_PLACE_IMPL

enum class shamalgs::primitives::EXSCAN_IN_PLACE_IMPL : u32
strong

Definition at line 107 of file scan_exclusive_sum_in_place.cpp.

◆ IS_ALL_TRUE_IMPL

enum class shamalgs::primitives::IS_ALL_TRUE_IMPL : u32
strong

Definition at line 69 of file is_all_true.cpp.

◆ REDUCTION_IMPL

enum class shamalgs::primitives::REDUCTION_IMPL : u32
strong

Definition at line 31 of file reduction.cpp.

Function Documentation

◆ append_subset_to()

template<class T >
void shamalgs::primitives::append_subset_to ( const sham::DeviceBuffer< T > &  buf,
const sham::DeviceBuffer< u32 > &  idxs_buf,
u32  nvar,
sham::DeviceBuffer< T > &  buf_other,
u32  start_enque 
)

Appends a subset of elements from one buffer to another.

The elements to append are specified by indices in idxs_buf. The source buffer buf is treated as an array of objects, each with nvar variables. The elements are appended to buf_other.

Template Parameters
TThe type of data in the buffers.
Parameters
bufThe source buffer.
idxs_bufA buffer of indices specifying which objects to copy from buf.
nvarThe number of variables per object.
buf_otherThe destination buffer to which the subset will be appended.
start_enqueThe starting index in buf_other where the subset will be appended.

Definition at line 45 of file append_subset_to.cpp.

+ Here is the call graph for this function:

◆ binary_range_search()

template<class Tkey >
constexpr void shamalgs::primitives::binary_range_search ( const Tkey *__restrict__  key,
u32  first,
u32  last,
const Tkey &  value_min,
const Tkey &  value_max,
u32 inf,
u32 sup 
)
constexpr

Find the range of indices for which key[inf] <= value_min <= value_max <= key[sup].

Precondition
key is sorted in ascending order
value_min <= value_max
first < last
key[first] <= value_min
key[last - 1] >= value_max
Template Parameters
TkeyType of the key
Parameters
keyArray of keys
firstFirst index of the range
lastLast index of the range
value_minLower bound of the range
value_maxUpper bound of the range
infIndex of the first element of the range
supIndex of the last element of the range
// Example usage with a sorted array
std::vector<int> keys = {1, 3, 5, 7, 9, 11, 13, 15};
u32 inf, sup;
// Find range of elements between 5 and 11 (inclusive)
binary_range_search(keys.data(), 0, keys.size(), 5, 11, inf, sup);
// inf = 2, sup = 5 (elements 5, 7, 9, 11 at indices 2, 3, 4, 5)
// Find range with duplicates
std::vector<int> keys2 = {1, 2, 2, 2, 3, 4, 4, 5};
binary_range_search(keys2.data(), 0, keys2.size(), 2, 4, inf, sup);
// inf = 1, sup = 6 (elements 2, 2, 2, 3, 4, 4 at indices 1-6)
std::uint32_t u32
32 bit unsigned integer
constexpr void binary_range_search(const Tkey *__restrict__ key, u32 first, u32 last, const Tkey &value_min, const Tkey &value_max, u32 &inf, u32 &sup)
Find the range of indices for which key[inf] <= value_min <= value_max <= key[sup].

Definition at line 59 of file binary_range_search.hpp.

+ Here is the call graph for this function:

◆ binary_search_lower_bound()

template<class Tkey >
constexpr u32 shamalgs::primitives::binary_search_lower_bound ( const Tkey *__restrict__  key,
u32  first,
u32  last,
const Tkey &  value 
)
constexpr

GPU compatible implementation of std::lower_bound.

Definition at line 25 of file lower_bound.hpp.

◆ binary_search_upper_bound()

template<class Tkey >
constexpr u32 shamalgs::primitives::binary_search_upper_bound ( const Tkey *__restrict__  key,
u32  first,
u32  last,
const Tkey &  value 
)
constexpr

GPU compatible implementation of std::upper_bound.

Definition at line 25 of file upper_bound.hpp.

◆ compute_histogram()

template<class T , class Tbins , class... Targs, class Tfunctor >
sham::DeviceBuffer< T > shamalgs::primitives::compute_histogram ( const sham::DeviceScheduler_ptr &  dev_sched,
const sham::DeviceBuffer< Tbins > &  bin_edge_inf,
const sham::DeviceBuffer< Tbins > &  bin_edge_sup,
size_t  element_count,
Tfunctor &&  functor,
const sham::DeviceBuffer< Targs > &...  input_data 
)
inline

Definition at line 359 of file compute_histogram.hpp.

◆ compute_histogram_basic()

template<class T >
sham::DeviceBuffer< T > shamalgs::primitives::compute_histogram_basic ( const sham::DeviceScheduler_ptr &  dev_sched,
const sham::DeviceBuffer< T > &  bin_edge_inf,
const sham::DeviceBuffer< T > &  bin_edge_sup,
const sham::DeviceBuffer< T > &  positions 
)
inline

Definition at line 430 of file compute_histogram.hpp.

◆ dot_sum() [1/2]

template<class T >
shambase::VecComponent< T > shamalgs::primitives::dot_sum ( sham::DeviceBuffer< T > &  buf1)
inline

Definition at line 45 of file dot_sum.hpp.

◆ dot_sum() [2/2]

template<class T >
shambase::VecComponent< T > shamalgs::primitives::dot_sum ( sham::DeviceBuffer< T > &  buf1,
u32  start_id,
u32  end_id 
)

Compute the sum of dot products of elements in a device buffer with themselves.

Template Parameters
TThe data type of elements in the buffer (e.g., float, double, int).
Parameters
buf1The input buffer containing the elements to sum.
start_idThe starting index (inclusive) of the range to sum.
end_idThe ending index (exclusive) of the range to sum.
Returns
shambase::VecComponent<T> The computed sum of dot products.

Example:

auto sched = shamsys::get_compute_Scheduler_ptr();
f64 result = shamalgs::primitives::dot_sum(sched, values, 0, values.get_size());
double f64
Alias for double.
A buffer allocated in USM (Unified Shared Memory)
size_t get_size() const
Gets the number of elements in the buffer.
shambase::VecComponent< T > dot_sum(sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
Compute the sum of dot products of elements in a device buffer with themselves.
Definition dot_sum.cpp:26

Definition at line 26 of file dot_sum.cpp.

+ Here is the call graph for this function:

◆ equals() [1/4]

template<class T >
bool shamalgs::primitives::equals ( const sham::DeviceScheduler_ptr &  dev_sched,
sham::DeviceBuffer< T > &  buf1,
sham::DeviceBuffer< T > &  buf2,
u32  cnt 
)
inline

Compare elements between two sham::DeviceBuffers for equality.

Performs element-wise comparison between two device buffers to determine if all corresponding elements are equal. The function compares the first cnt elements of each buffer and returns true only if all pairs match. This is the preferred method for USM-based buffer comparisons.

Template Parameters
TElement type - must support equality comparison
Parameters
dev_schedDevice scheduler pointer for execution context
buf1First device buffer to compare
buf2Second device buffer to compare
cntNumber of elements to compare from the beginning of each buffer
Returns
true if all compared elements are equal, false otherwise
Exceptions
std::invalid_argumentif either buffer is smaller than cnt
Note
Returns true immediately if both buffers are the same object
Uses parallel device execution for the comparison operation
// Example: Compare device buffers element-wise
auto sched = shamsys::get_compute_Scheduler_ptr();
std::vector<f32> data1 = {1.0f, 2.0f, 3.0f, 4.0f};
std::vector<f32> data2 = {1.0f, 2.0f, 3.0f, 4.0f};
sham::DeviceBuffer<f32> buffer1(data1.size(), sched);
sham::DeviceBuffer<f32> buffer2(data2.size(), sched);
// Initialize buffers with data
buffer1.copy_from_stdvec(data1);
buffer2.copy_from_stdvec(data2);
// Compare first 4 elements
bool are_equal = equals(sched, buffer1, buffer2, 4);
// Result: true (all elements match)
// Example with tolerance-based comparison
std::vector<f32> data3 = {1.0f, 2.0f, 3.1f, 4.0f};
sham::DeviceBuffer<f32> buffer3(data3.size(), sched);
buffer3.copy_from_stdvec(data3);
bool different = equals(sched, buffer1, buffer3, 4);
// Result: false (third element differs)
bool equals(sycl::queue &q, sycl::buffer< T > &buf1, sycl::buffer< T > &buf2, u32 cnt)
Compare elements between two sycl::buffers for equality.
Definition equals.hpp:77

Definition at line 154 of file equals.hpp.

+ Here is the call graph for this function:

◆ equals() [2/4]

template<class T >
bool shamalgs::primitives::equals ( const sham::DeviceScheduler_ptr &  q,
sham::DeviceBuffer< T > &  buf1,
sham::DeviceBuffer< T > &  buf2 
)
inline

Compare all elements between two sham::DeviceBuffers for equality.

Performs element-wise comparison between two device buffers to determine if all corresponding elements are equal. This function automatically compares all elements if both buffers have the same size, or returns false if sizes differ.

Template Parameters
TElement type - must support equality comparison
Parameters
qDevice scheduler pointer for execution context
buf1First device buffer to compare
buf2Second device buffer to compare
Returns
true if buffers have same size and all elements are equal, false otherwise
Note
Returns false immediately if buffer sizes differ
Convenience function that calls equals(q, buf1, buf2, buf1.get_size())
// Example: Compare entire device buffers
auto sched = shamsys::get_compute_Scheduler_ptr();
std::vector<i32> keys = {10, 20, 30, 40};
std::vector<i32> values = {10, 20, 30, 40};
sham::DeviceBuffer<i32> buffer1(keys.size(), sched);
sham::DeviceBuffer<i32> buffer2(values.size(), sched);
buffer1.copy_from_stdvec(keys);
buffer2.copy_from_stdvec(values);
// Compare entire buffers
bool are_equal = equals(sched, buffer1, buffer2);
// Result: true (all elements match)
// Example with different sizes
std::vector<i32> shorter = {10, 20};
sham::DeviceBuffer<i32> buffer3(shorter.size(), sched);
buffer3.copy_from_stdvec(shorter);
bool size_diff = equals(sched, buffer1, buffer3);
// Result: false (different sizes)

Definition at line 235 of file equals.hpp.

+ Here is the call graph for this function:

◆ equals() [3/4]

template<class T >
bool shamalgs::primitives::equals ( sycl::queue &  q,
sycl::buffer< T > &  buf1,
sycl::buffer< T > &  buf2 
)

Compare all elements between two sycl::buffers for equality.

Performs element-wise comparison between two buffers to determine if all corresponding elements are equal. This function automatically compares all elements if both buffers have the same size, or returns false if sizes differ.

Template Parameters
TElement type - must support equality comparison
Parameters
qsycl::queue for device execution
buf1First buffer to compare
buf2Second buffer to compare
Returns
true if buffers have same size and all elements are equal, false otherwise
Note
Returns false immediately if buffer sizes differ
Convenience function that calls equals(q, buf1, buf2, buf1.size())
Deprecated:
Use equals with sham::DeviceBuffer instead
// Example: Compare entire sycl buffers
std::vector<f64> data1 = {1.0, 2.0, 3.0};
std::vector<f64> data2 = {1.0, 2.0, 3.0};
sycl::buffer<f64> buffer1(data1);
sycl::buffer<f64> buffer2(data2);
sycl::queue q;
// Compare entire buffers
bool are_equal = equals(q, buffer1, buffer2);
// Result: true (all elements match)

Definition at line 280 of file equals.hpp.

+ Here is the call graph for this function:

◆ equals() [4/4]

template<class T >
bool shamalgs::primitives::equals ( sycl::queue &  q,
sycl::buffer< T > &  buf1,
sycl::buffer< T > &  buf2,
u32  cnt 
)

Compare elements between two sycl::buffers for equality.

Performs element-wise comparison between two buffers to determine if all corresponding elements are equal. The function compares the first cnt elements of each buffer and returns true only if all pairs match.

Template Parameters
TElement type - must support equality comparison
Parameters
qsycl::queue for device execution
buf1First buffer to compare
buf2Second buffer to compare
cntNumber of elements to compare from the beginning of each buffer
Returns
true if all compared elements are equal, false otherwise
Exceptions
std::invalid_argumentif either buffer is smaller than cnt
Deprecated:
Use equals(const sham::DeviceScheduler_ptr &, sham::DeviceBuffer<T> &, sham::DeviceBuffer<T> &, u32 ) instead.
// Example: Compare arrays element-wise
std::vector<i32> data1 = {1, 2, 3, 4, 5};
std::vector<i32> data2 = {1, 2, 3, 4, 5};
sycl::buffer<i32> buffer1(data1);
sycl::buffer<i32> buffer2(data2);
sycl::queue q;
// Compare first 5 elements
bool are_equal = equals(q, buffer1, buffer2, 5);
// Result: true (all elements match)
// Example with different data
std::vector<i32> data3 = {1, 2, 0, 4, 5};
sycl::buffer<i32> buffer3(data3);
bool different = equals(q, buffer1, buffer3, 5);
// Result: false (third element differs)

Definition at line 77 of file equals.hpp.

+ Here is the call graph for this function:

◆ equals_ptr()

template<class T >
bool shamalgs::primitives::equals_ptr ( sycl::queue &  q,
const std::unique_ptr< sycl::buffer< T > > &  buf1,
const std::unique_ptr< sycl::buffer< T > > &  buf2 
)

Compare all elements between two unique_ptr-wrapped sycl::buffers.

Performs element-wise comparison between two unique_ptr-wrapped buffers to determine if all corresponding elements are equal. The function handles null pointer cases and compares all elements if both pointers are valid and buffer sizes match.

Template Parameters
TElement type - must support equality comparison
Parameters
qsycl::queue for device execution
buf1First unique_ptr-wrapped buffer to compare
buf2Second unique_ptr-wrapped buffer to compare
Returns
true if both are null or all elements are equal, false otherwise
Note
Returns false if only one pointer is null
Returns true if both pointers are null
Uses equals(q, *buf1, *buf2) for actual comparison
Deprecated:
Use sham::DeviceBuffer-based functions instead
// Example: Compare optional buffers entirely
sycl::queue q;
std::vector<f32> data1 = {1.0f, 2.0f, 3.0f};
std::vector<f32> data2 = {1.0f, 2.0f, 3.0f};
auto buf1 = std::make_unique<sycl::buffer<f32>>(data1);
auto buf2 = std::make_unique<sycl::buffer<f32>>(data2);
// Compare entire buffers
bool are_equal = equals_ptr(q, buf1, buf2);
// Result: true (all elements match)
// Example with one null pointer
std::unique_ptr<sycl::buffer<f32>> null_buf;
bool one_null = equals_ptr(q, buf1, null_buf);
// Result: false (only one is null)
bool equals_ptr(sycl::queue &q, const std::unique_ptr< sycl::buffer< T > > &buf1, const std::unique_ptr< sycl::buffer< T > > &buf2)
Compare all elements between two unique_ptr-wrapped sycl::buffers.
Definition equals.hpp:386

Definition at line 386 of file equals.hpp.

+ Here is the call graph for this function:

◆ equals_ptr_s()

template<class T >
bool shamalgs::primitives::equals_ptr_s ( sycl::queue &  q,
const std::unique_ptr< sycl::buffer< T > > &  buf1,
const std::unique_ptr< sycl::buffer< T > > &  buf2,
u32  cnt 
)

Compare elements between two unique_ptr-wrapped sycl::buffers with count.

Performs element-wise comparison between two unique_ptr-wrapped buffers to determine if all corresponding elements are equal. The function handles null pointer cases and compares the first cnt elements if both pointers are valid.

Template Parameters
TElement type - must support equality comparison
Parameters
qsycl::queue for device execution
buf1First unique_ptr-wrapped buffer to compare
buf2Second unique_ptr-wrapped buffer to compare
cntNumber of elements to compare from the beginning of each buffer
Returns
true if both are null or all compared elements are equal, false otherwise
Note
Returns false if only one pointer is null
Returns true if both pointers are null
Uses equals(q, *buf1, *buf2, cnt) for actual comparison
Deprecated:
Use sham::DeviceBuffer-based functions instead
// Example: Compare optional buffers with count
sycl::queue q;
std::vector<i32> data1 = {1, 2, 3, 4, 5};
std::vector<i32> data2 = {1, 2, 3, 4, 5};
auto buf1 = std::make_unique<sycl::buffer<i32>>(data1);
auto buf2 = std::make_unique<sycl::buffer<i32>>(data2);
// Compare first 3 elements
bool are_equal = equals_ptr_s(q, buf1, buf2, 3);
// Result: true (first 3 elements match)
// Example with null pointers
std::unique_ptr<sycl::buffer<i32>> null_buf1, null_buf2;
bool both_null = equals_ptr_s(q, null_buf1, null_buf2, 0);
// Result: true (both are null)
bool equals_ptr_s(sycl::queue &q, const std::unique_ptr< sycl::buffer< T > > &buf1, const std::unique_ptr< sycl::buffer< T > > &buf2, u32 cnt)
Compare elements between two unique_ptr-wrapped sycl::buffers with count.
Definition equals.hpp:329

Definition at line 329 of file equals.hpp.

+ Here is the call graph for this function:

◆ fill_buffer_index()

void shamalgs::primitives::fill_buffer_index ( sham::DeviceBuffer< u32 > &  buf,
u32  len 
)

Fills a buffer with sequential indices, such that buf[i] = i.

The buffer must have a size of at least len. If len is 0, the function has no effect.

Parameters
bufThe buffer to fill.
lenThe number of elements to fill from the start of the buffer.
Exceptions
std::invalid_argumentif buf.get_size() < len.

Definition at line 23 of file gen_buffer_index.cpp.

+ Here is the call graph for this function:

◆ flatten_buffer()

template<class Tvec , sham::USMKindTarget target>
sham::DeviceBuffer< typename shambase::VectorProperties< Tvec >::component_type, target > shamalgs::primitives::flatten_buffer ( const sham::DeviceBuffer< Tvec, target > &  buffer)
inline

Flatten a buffer of vector type into a buffer of scalar type.

The buffer is flattened in row-major order, i.e. the first element of the first vector is stored first, then the second element of the first vector, and so on.

Parameters
bufferThe buffer to flatten.
Returns
The flattened buffer.

Definition at line 40 of file flatten.hpp.

+ Here is the call graph for this function:

◆ gen_buffer_index()

sham::DeviceBuffer< u32 > shamalgs::primitives::gen_buffer_index ( sham::DeviceScheduler_ptr  sched,
u32  len 
)

Generates a buffer where buf[i] = i.

Parameters
schedThe scheduler to run on.
lenLength of the buffer to generate.
Returns
sham::DeviceBuffer<u32> The generated buffer containing sequential indices.

Definition at line 39 of file gen_buffer_index.cpp.

+ Here is the call graph for this function:

◆ get_default_reduction_impl()

REDUCTION_IMPL shamalgs::primitives::get_default_reduction_impl ( )

Definition at line 40 of file reduction.cpp.

◆ get_default_scan_exclusive_sum_in_place_impl()

EXSCAN_IN_PLACE_IMPL shamalgs::primitives::get_default_scan_exclusive_sum_in_place_impl ( )

Definition at line 120 of file scan_exclusive_sum_in_place.cpp.

◆ internal_segmented_sort_in_place()

template<class T , class Comp >
void shamalgs::primitives::internal_segmented_sort_in_place ( sham::DeviceBuffer< T > &  buf,
const sham::DeviceBuffer< u32 > &  offsets,
Comp &&  comp 
)

Definition at line 168 of file segmented_sort_in_place.cpp.

◆ is_all_true() [1/2]

template<class T >
bool shamalgs::primitives::is_all_true ( sham::DeviceBuffer< T > &  buf,
u32  cnt 
)

Check if all elements in a sham::DeviceBuffer are non-zero.

Performs a boolean reduction operation to determine if every element in the device buffer is non-zero (logically true). The function returns true only if all elements satisfy the condition element != 0.

Template Parameters
TElement type - must support comparison with zero
Parameters
bufDevice buffer containing the elements to check
cntNumber of elements to check from the beginning of the buffer
Returns
true if all elements are non-zero, false otherwise
Note
Currently implemented by copying to sycl::buffer and using CPU processing
The function only checks the first cnt elements of the buffer
// Example: Check device buffer elements
std::vector<u8> flags = {1, 1, 1, 1};
sham::DeviceBuffer<u8> device_buffer(flags);
// Check all flags
bool all_set = is_all_true(device_buffer, flags.size());
// Result: true (all flags are set)
// Example with boolean conditions
std::vector<i32> conditions = {5 > 0, 3 > 0, 0 > 0, 1 > 0};
sham::DeviceBuffer<i32> cond_buffer(conditions);
bool all_conditions_met = is_all_true(cond_buffer, conditions.size());
// Result: false (third condition evaluates to 0)
bool is_all_true(sycl::buffer< T > &buf, u32 cnt)
Check if all elements in a sycl::buffer are non-zero.

Definition at line 109 of file is_all_true.cpp.

+ Here is the call graph for this function:

◆ is_all_true() [2/2]

template<class T >
bool shamalgs::primitives::is_all_true ( sycl::buffer< T > &  buf,
u32  cnt 
)

Check if all elements in a sycl::buffer are non-zero.

Performs a boolean reduction operation to determine if every element in the buffer is non-zero (logically true). The function returns true only if all elements satisfy the condition element != 0.

Template Parameters
TElement type - must support comparison with zero
Parameters
bufBuffer containing the elements to check
cntNumber of elements to check from the beginning of the buffer
Returns
true if all elements are non-zero, false otherwise
Note
Currently implemented on CPU but marked for GPU optimization
The function only checks the first cnt elements of the buffer
Deprecated:
Use is_all_true(sham::DeviceBuffer<T>&, u32) instead.
// Example: Check if all elements are non-zero
std::vector<i32> data = {1, 2, 3, 4, 5};
sycl::buffer<i32> buffer(data);
// Check all elements
bool all_nonzero = is_all_true(buffer, data.size());
// Result: true (all elements are non-zero)
// Example with zeros
std::vector<i32> data_with_zero = {1, 0, 3, 4};
sycl::buffer<i32> buffer2(data_with_zero);
bool has_zero = is_all_true(buffer2, data_with_zero.size());
// Result: false (contains zero)

Definition at line 124 of file is_all_true.cpp.

◆ is_all_true_impl_from_params()

IS_ALL_TRUE_IMPL shamalgs::primitives::is_all_true_impl_from_params ( const std::string &  impl)
inline

Definition at line 72 of file is_all_true.cpp.

◆ is_all_true_impl_to_params()

shamalgs::impl_param shamalgs::primitives::is_all_true_impl_to_params ( const IS_ALL_TRUE_IMPL &  impl)
inline

Definition at line 84 of file is_all_true.cpp.

◆ linspace()

template<typename Tval >
sham::DeviceBuffer< Tval > shamalgs::primitives::linspace ( Tval  Rmin,
Tval  Rmax,
u32  N 
)

Create an array of N values between two values.

Template Parameters
Tvalvalue type in the sequence (same type as bounds)
Parameters
Rminlower bound of the sequence
Rmaxupper bound of the sequence
Nnumber of samples to generate
Returns
a DeviceBuffer containing the sequence

TODO: move to GPU

Definition at line 37 of file linspace.hpp.

◆ max()

template<class T >
T shamalgs::primitives::max ( const sham::DeviceScheduler_ptr &  sched,
const sham::DeviceBuffer< T > &  buf1,
u32  start_id,
u32  end_id 
)

Find the maximum element in a device buffer within a specified range.

This function finds the maximum value among all elements in the buffer between start_id (inclusive) and end_id (exclusive). The computation is performed on the device using the provided scheduler.

Template Parameters
TThe data type of elements in the buffer (e.g., float, double, int).
Parameters
schedThe device scheduler to run on.
buf1The input buffer containing the elements to search.
start_idThe starting index (inclusive) of the range to search.
end_idThe ending index (exclusive) of the range to search.
Returns
T The maximum value found in the specified range.
Precondition
start_id < end_id (range must be non-empty)
end_id <= buf1.get_size()

Example:

auto sched = shamsys::get_compute_Scheduler_ptr();
u32 start = 0;
u32 end = values.get_size();
double maximum = shamalgs::primitives::max(sched, values, start, end);
T max(const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
Find the maximum element in a device buffer within a specified range.

values = {5.0, 2.0, 8.0, 1.0, 6.0}, start = 1, end = 4 result = 8.0 (maximum of {2.0, 8.0, 1.0})

Definition at line 155 of file reduction.cpp.

+ Here is the call graph for this function:

◆ min()

template<class T >
T shamalgs::primitives::min ( const sham::DeviceScheduler_ptr &  sched,
const sham::DeviceBuffer< T > &  buf1,
u32  start_id,
u32  end_id 
)

Find the minimum element in a device buffer within a specified range.

This function finds the minimum value among all elements in the buffer between start_id (inclusive) and end_id (exclusive). The computation is performed on the device using the provided scheduler.

Template Parameters
TThe data type of elements in the buffer (e.g., float, double, int).
Parameters
schedThe device scheduler to run on.
buf1The input buffer containing the elements to search.
start_idThe starting index (inclusive) of the range to search.
end_idThe ending index (exclusive) of the range to search.
Returns
T The minimum value found in the specified range.
Precondition
start_id < end_id (range must be non-empty)
end_id <= buf1.get_size()

Example:

auto sched = shamsys::get_compute_Scheduler_ptr();
u32 start = 0;
u32 end = values.get_size();
double minimum = shamalgs::primitives::min(sched, values, start, end);
T min(const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
Find the minimum element in a device buffer within a specified range.

values = {5.0, 2.0, 8.0, 1.0, 6.0}, start = 1, end = 4 result = 1.0 (minimum of {2.0, 8.0, 1.0})

Definition at line 130 of file reduction.cpp.

+ Here is the call graph for this function:

◆ mock_value() [1/122]

template<class T , class Engine = std::mt19937>
T shamalgs::primitives::mock_value ( Engine &  eng)
inline

Generates a random mock value using default bounds.

This function generates a random value of type T using the default minimum and maximum bounds defined by shambase::VectorProperties<T>. This is a convenience function that automatically determines appropriate bounds based on the type T.

Template Parameters
TThe type of value to generate (supports primitive types and SYCL vectors)
Parameters
engThe random number generator engine to use
Returns
A random value of type T within the default bounds for the type
#include <random>
// Initialize random number generator
std::mt19937 rng(42);
// Generate random values with default bounds
i32 random_int = shamalgs::mock_value<i32>(rng);
f64 random_double = shamalgs::mock_value<f64>(rng);
sycl::vec<f32, 2> random_vec2 = shamalgs::mock_value<sycl::vec<f32, 2>>(rng);
std::int32_t i32
32 bit integer
Utility functions for generating random mock values.

Definition at line 90 of file mock_value.hpp.

◆ mock_value() [2/122]

template<class T , class Engine = std::mt19937>
T shamalgs::primitives::mock_value ( Engine &  eng,
min_bound,
max_bound 
)

Generates a random mock value within specified bounds.

This function generates a random value of type T within the range [min_bound, max_bound]. For integer types, the distribution is uniform over the inclusive range. For floating-point types, the distribution is uniform over the range [min_bound, max_bound). For SYCL vectors, each component is generated independently using the same bounds.

Template Parameters
TThe type of value to generate (supports primitive types and SYCL vectors)
Parameters
engThe random number generator engine to use
min_boundThe minimum bound for the generated value
max_boundThe maximum bound for the generated value
Returns
A random value of type T within the specified bounds
#include <random>
// Initialize random number generator
std::mt19937 rng(42);
// Generate random integers
i32 random_int = shamalgs::mock_value(rng, i32{0}, i32{100});
// Generate random floats
f32 random_float = shamalgs::mock_value(rng, f32{0.0f}, f32{1.0f});
// Generate random SYCL vectors
sycl::vec<f32, 3> random_vec = shamalgs::mock_value(
rng,
sycl::vec<f32, 3>{0.0f, 0.0f, 0.0f},
sycl::vec<f32, 3>{1.0f, 1.0f, 1.0f}
);
float f32
Alias for float.

◆ mock_value() [3/122]

template<>
f32 shamalgs::primitives::mock_value ( std::mt19937 &  eng,
f32  min_bound,
f32  max_bound 
)

Definition at line 70 of file mock_value.cpp.

◆ mock_value() [4/122]

template<>
f64 shamalgs::primitives::mock_value ( std::mt19937 &  eng,
f64  min_bound,
f64  max_bound 
)

Definition at line 76 of file mock_value.cpp.

◆ mock_value() [5/122]

template<>
i16 shamalgs::primitives::mock_value ( std::mt19937 &  eng,
i16  min_bound,
i16  max_bound 
)

Definition at line 52 of file mock_value.cpp.

◆ mock_value() [6/122]

template<>
i32 shamalgs::primitives::mock_value ( std::mt19937 &  eng,
i32  min_bound,
i32  max_bound 
)

Definition at line 58 of file mock_value.cpp.

◆ mock_value() [7/122]

template<>
i64 shamalgs::primitives::mock_value ( std::mt19937 &  eng,
i64  min_bound,
i64  max_bound 
)

Definition at line 64 of file mock_value.cpp.

◆ mock_value() [8/122]

template<>
i8 shamalgs::primitives::mock_value ( std::mt19937 &  eng,
i8  min_bound,
i8  max_bound 
)

Definition at line 46 of file mock_value.cpp.

◆ mock_value() [9/122]

template<>
sycl::vec< f32, 16 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< f32, 16 >  min_bound,
sycl::vec< f32, 16 >  max_bound 
)

Definition at line 162 of file mock_value.cpp.

◆ mock_value() [10/122]

template<>
sycl::vec< f32, 2 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< f32, 2 >  min_bound,
sycl::vec< f32, 2 >  max_bound 
)

Definition at line 162 of file mock_value.cpp.

◆ mock_value() [11/122]

template<>
sycl::vec< f32, 3 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< f32, 3 >  min_bound,
sycl::vec< f32, 3 >  max_bound 
)

Definition at line 162 of file mock_value.cpp.

◆ mock_value() [12/122]

template<>
sycl::vec< f32, 4 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< f32, 4 >  min_bound,
sycl::vec< f32, 4 >  max_bound 
)

Definition at line 162 of file mock_value.cpp.

◆ mock_value() [13/122]

template<>
sycl::vec< f32, 8 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< f32, 8 >  min_bound,
sycl::vec< f32, 8 >  max_bound 
)

Definition at line 162 of file mock_value.cpp.

◆ mock_value() [14/122]

template<>
sycl::vec< f64, 16 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< f64, 16 >  min_bound,
sycl::vec< f64, 16 >  max_bound 
)

Definition at line 161 of file mock_value.cpp.

◆ mock_value() [15/122]

template<>
sycl::vec< f64, 2 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< f64, 2 >  min_bound,
sycl::vec< f64, 2 >  max_bound 
)

Definition at line 161 of file mock_value.cpp.

◆ mock_value() [16/122]

template<>
sycl::vec< f64, 3 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< f64, 3 >  min_bound,
sycl::vec< f64, 3 >  max_bound 
)

Definition at line 161 of file mock_value.cpp.

◆ mock_value() [17/122]

template<>
sycl::vec< f64, 4 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< f64, 4 >  min_bound,
sycl::vec< f64, 4 >  max_bound 
)

Definition at line 161 of file mock_value.cpp.

◆ mock_value() [18/122]

template<>
sycl::vec< f64, 8 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< f64, 8 >  min_bound,
sycl::vec< f64, 8 >  max_bound 
)

Definition at line 161 of file mock_value.cpp.

◆ mock_value() [19/122]

template<>
sycl::vec< i16, 16 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i16, 16 >  min_bound,
sycl::vec< i16, 16 >  max_bound 
)

Definition at line 158 of file mock_value.cpp.

◆ mock_value() [20/122]

template<>
sycl::vec< i16, 2 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i16, 2 >  min_bound,
sycl::vec< i16, 2 >  max_bound 
)

Definition at line 158 of file mock_value.cpp.

◆ mock_value() [21/122]

template<>
sycl::vec< i16, 3 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i16, 3 >  min_bound,
sycl::vec< i16, 3 >  max_bound 
)

Definition at line 158 of file mock_value.cpp.

◆ mock_value() [22/122]

template<>
sycl::vec< i16, 4 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i16, 4 >  min_bound,
sycl::vec< i16, 4 >  max_bound 
)

Definition at line 158 of file mock_value.cpp.

◆ mock_value() [23/122]

template<>
sycl::vec< i16, 8 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i16, 8 >  min_bound,
sycl::vec< i16, 8 >  max_bound 
)

Definition at line 158 of file mock_value.cpp.

◆ mock_value() [24/122]

template<>
sycl::vec< i32, 16 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i32, 16 >  min_bound,
sycl::vec< i32, 16 >  max_bound 
)

Definition at line 157 of file mock_value.cpp.

◆ mock_value() [25/122]

template<>
sycl::vec< i32, 2 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i32, 2 >  min_bound,
sycl::vec< i32, 2 >  max_bound 
)

Definition at line 157 of file mock_value.cpp.

◆ mock_value() [26/122]

template<>
sycl::vec< i32, 3 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i32, 3 >  min_bound,
sycl::vec< i32, 3 >  max_bound 
)

Definition at line 157 of file mock_value.cpp.

◆ mock_value() [27/122]

template<>
sycl::vec< i32, 4 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i32, 4 >  min_bound,
sycl::vec< i32, 4 >  max_bound 
)

Definition at line 157 of file mock_value.cpp.

◆ mock_value() [28/122]

template<>
sycl::vec< i32, 8 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i32, 8 >  min_bound,
sycl::vec< i32, 8 >  max_bound 
)

Definition at line 157 of file mock_value.cpp.

◆ mock_value() [29/122]

template<>
sycl::vec< i64, 16 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i64, 16 >  min_bound,
sycl::vec< i64, 16 >  max_bound 
)

Definition at line 156 of file mock_value.cpp.

◆ mock_value() [30/122]

template<>
sycl::vec< i64, 2 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i64, 2 >  min_bound,
sycl::vec< i64, 2 >  max_bound 
)

Definition at line 156 of file mock_value.cpp.

◆ mock_value() [31/122]

template<>
sycl::vec< i64, 3 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i64, 3 >  min_bound,
sycl::vec< i64, 3 >  max_bound 
)

Definition at line 156 of file mock_value.cpp.

◆ mock_value() [32/122]

template<>
sycl::vec< i64, 4 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i64, 4 >  min_bound,
sycl::vec< i64, 4 >  max_bound 
)

Definition at line 156 of file mock_value.cpp.

◆ mock_value() [33/122]

template<>
sycl::vec< i64, 8 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i64, 8 >  min_bound,
sycl::vec< i64, 8 >  max_bound 
)

Definition at line 156 of file mock_value.cpp.

◆ mock_value() [34/122]

template<>
sycl::vec< i8, 16 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i8, 16 >  min_bound,
sycl::vec< i8, 16 >  max_bound 
)

Definition at line 159 of file mock_value.cpp.

◆ mock_value() [35/122]

template<>
sycl::vec< i8, 2 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i8, 2 >  min_bound,
sycl::vec< i8, 2 >  max_bound 
)

Definition at line 159 of file mock_value.cpp.

◆ mock_value() [36/122]

template<>
sycl::vec< i8, 3 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i8, 3 >  min_bound,
sycl::vec< i8, 3 >  max_bound 
)

Definition at line 159 of file mock_value.cpp.

◆ mock_value() [37/122]

template<>
sycl::vec< i8, 4 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i8, 4 >  min_bound,
sycl::vec< i8, 4 >  max_bound 
)

Definition at line 159 of file mock_value.cpp.

◆ mock_value() [38/122]

template<>
sycl::vec< i8, 8 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< i8, 8 >  min_bound,
sycl::vec< i8, 8 >  max_bound 
)

Definition at line 159 of file mock_value.cpp.

◆ mock_value() [39/122]

template<>
sycl::vec< u16, 16 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u16, 16 >  min_bound,
sycl::vec< u16, 16 >  max_bound 
)

Definition at line 153 of file mock_value.cpp.

◆ mock_value() [40/122]

template<>
sycl::vec< u16, 2 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u16, 2 >  min_bound,
sycl::vec< u16, 2 >  max_bound 
)

Definition at line 153 of file mock_value.cpp.

◆ mock_value() [41/122]

template<>
sycl::vec< u16, 3 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u16, 3 >  min_bound,
sycl::vec< u16, 3 >  max_bound 
)

Definition at line 153 of file mock_value.cpp.

◆ mock_value() [42/122]

template<>
sycl::vec< u16, 4 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u16, 4 >  min_bound,
sycl::vec< u16, 4 >  max_bound 
)

Definition at line 153 of file mock_value.cpp.

◆ mock_value() [43/122]

template<>
sycl::vec< u16, 8 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u16, 8 >  min_bound,
sycl::vec< u16, 8 >  max_bound 
)

Definition at line 153 of file mock_value.cpp.

◆ mock_value() [44/122]

template<>
sycl::vec< u32, 16 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u32, 16 >  min_bound,
sycl::vec< u32, 16 >  max_bound 
)

Definition at line 152 of file mock_value.cpp.

◆ mock_value() [45/122]

template<>
sycl::vec< u32, 2 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u32, 2 >  min_bound,
sycl::vec< u32, 2 >  max_bound 
)

Definition at line 152 of file mock_value.cpp.

◆ mock_value() [46/122]

template<>
sycl::vec< u32, 3 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u32, 3 >  min_bound,
sycl::vec< u32, 3 >  max_bound 
)

Definition at line 152 of file mock_value.cpp.

◆ mock_value() [47/122]

template<>
sycl::vec< u32, 4 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u32, 4 >  min_bound,
sycl::vec< u32, 4 >  max_bound 
)

Definition at line 152 of file mock_value.cpp.

◆ mock_value() [48/122]

template<>
sycl::vec< u32, 8 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u32, 8 >  min_bound,
sycl::vec< u32, 8 >  max_bound 
)

Definition at line 152 of file mock_value.cpp.

◆ mock_value() [49/122]

template<>
sycl::vec< u64, 16 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u64, 16 >  min_bound,
sycl::vec< u64, 16 >  max_bound 
)

Definition at line 151 of file mock_value.cpp.

◆ mock_value() [50/122]

template<>
sycl::vec< u64, 2 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u64, 2 >  min_bound,
sycl::vec< u64, 2 >  max_bound 
)

Definition at line 151 of file mock_value.cpp.

◆ mock_value() [51/122]

template<>
sycl::vec< u64, 3 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u64, 3 >  min_bound,
sycl::vec< u64, 3 >  max_bound 
)

Definition at line 151 of file mock_value.cpp.

◆ mock_value() [52/122]

template<>
sycl::vec< u64, 4 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u64, 4 >  min_bound,
sycl::vec< u64, 4 >  max_bound 
)

Definition at line 151 of file mock_value.cpp.

◆ mock_value() [53/122]

template<>
sycl::vec< u64, 8 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u64, 8 >  min_bound,
sycl::vec< u64, 8 >  max_bound 
)

Definition at line 151 of file mock_value.cpp.

◆ mock_value() [54/122]

template<>
sycl::vec< u8, 16 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u8, 16 >  min_bound,
sycl::vec< u8, 16 >  max_bound 
)

Definition at line 154 of file mock_value.cpp.

◆ mock_value() [55/122]

template<>
sycl::vec< u8, 2 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u8, 2 >  min_bound,
sycl::vec< u8, 2 >  max_bound 
)

Definition at line 154 of file mock_value.cpp.

◆ mock_value() [56/122]

template<>
sycl::vec< u8, 3 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u8, 3 >  min_bound,
sycl::vec< u8, 3 >  max_bound 
)

Definition at line 154 of file mock_value.cpp.

◆ mock_value() [57/122]

template<>
sycl::vec< u8, 4 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u8, 4 >  min_bound,
sycl::vec< u8, 4 >  max_bound 
)

Definition at line 154 of file mock_value.cpp.

◆ mock_value() [58/122]

template<>
sycl::vec< u8, 8 > shamalgs::primitives::mock_value ( std::mt19937 &  eng,
sycl::vec< u8, 8 >  min_bound,
sycl::vec< u8, 8 >  max_bound 
)

Definition at line 154 of file mock_value.cpp.

◆ mock_value() [59/122]

template<>
u16 shamalgs::primitives::mock_value ( std::mt19937 &  eng,
u16  min_bound,
u16  max_bound 
)

Definition at line 28 of file mock_value.cpp.

◆ mock_value() [60/122]

template<>
u32 shamalgs::primitives::mock_value ( std::mt19937 &  eng,
u32  min_bound,
u32  max_bound 
)

Definition at line 34 of file mock_value.cpp.

◆ mock_value() [61/122]

template<>
u64 shamalgs::primitives::mock_value ( std::mt19937 &  eng,
u64  min_bound,
u64  max_bound 
)

Definition at line 40 of file mock_value.cpp.

◆ mock_value() [62/122]

template<>
u8 shamalgs::primitives::mock_value ( std::mt19937 &  eng,
u8  min_bound,
u8  max_bound 
)

Definition at line 22 of file mock_value.cpp.

◆ mock_value() [63/122]

template<>
f32 shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
f32  min_bound,
f32  max_bound 
)

Definition at line 222 of file mock_value.cpp.

◆ mock_value() [64/122]

template<>
f64 shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
f64  min_bound,
f64  max_bound 
)

Definition at line 228 of file mock_value.cpp.

◆ mock_value() [65/122]

template<>
i16 shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
i16  min_bound,
i16  max_bound 
)

Definition at line 204 of file mock_value.cpp.

◆ mock_value() [66/122]

template<>
i32 shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
i32  min_bound,
i32  max_bound 
)

Definition at line 210 of file mock_value.cpp.

◆ mock_value() [67/122]

template<>
i64 shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
i64  min_bound,
i64  max_bound 
)

Definition at line 216 of file mock_value.cpp.

◆ mock_value() [68/122]

template<>
i8 shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
i8  min_bound,
i8  max_bound 
)

Definition at line 198 of file mock_value.cpp.

◆ mock_value() [69/122]

template<>
sycl::vec< f32, 16 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< f32, 16 >  min_bound,
sycl::vec< f32, 16 >  max_bound 
)

Definition at line 314 of file mock_value.cpp.

◆ mock_value() [70/122]

template<>
sycl::vec< f32, 2 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< f32, 2 >  min_bound,
sycl::vec< f32, 2 >  max_bound 
)

Definition at line 314 of file mock_value.cpp.

◆ mock_value() [71/122]

template<>
sycl::vec< f32, 3 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< f32, 3 >  min_bound,
sycl::vec< f32, 3 >  max_bound 
)

Definition at line 314 of file mock_value.cpp.

◆ mock_value() [72/122]

template<>
sycl::vec< f32, 4 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< f32, 4 >  min_bound,
sycl::vec< f32, 4 >  max_bound 
)

Definition at line 314 of file mock_value.cpp.

◆ mock_value() [73/122]

template<>
sycl::vec< f32, 8 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< f32, 8 >  min_bound,
sycl::vec< f32, 8 >  max_bound 
)

Definition at line 314 of file mock_value.cpp.

◆ mock_value() [74/122]

template<>
sycl::vec< f64, 16 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< f64, 16 >  min_bound,
sycl::vec< f64, 16 >  max_bound 
)

Definition at line 313 of file mock_value.cpp.

◆ mock_value() [75/122]

template<>
sycl::vec< f64, 2 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< f64, 2 >  min_bound,
sycl::vec< f64, 2 >  max_bound 
)

Definition at line 313 of file mock_value.cpp.

◆ mock_value() [76/122]

template<>
sycl::vec< f64, 3 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< f64, 3 >  min_bound,
sycl::vec< f64, 3 >  max_bound 
)

Definition at line 313 of file mock_value.cpp.

◆ mock_value() [77/122]

template<>
sycl::vec< f64, 4 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< f64, 4 >  min_bound,
sycl::vec< f64, 4 >  max_bound 
)

Definition at line 313 of file mock_value.cpp.

◆ mock_value() [78/122]

template<>
sycl::vec< f64, 8 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< f64, 8 >  min_bound,
sycl::vec< f64, 8 >  max_bound 
)

Definition at line 313 of file mock_value.cpp.

◆ mock_value() [79/122]

template<>
sycl::vec< i16, 16 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i16, 16 >  min_bound,
sycl::vec< i16, 16 >  max_bound 
)

Definition at line 310 of file mock_value.cpp.

◆ mock_value() [80/122]

template<>
sycl::vec< i16, 2 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i16, 2 >  min_bound,
sycl::vec< i16, 2 >  max_bound 
)

Definition at line 310 of file mock_value.cpp.

◆ mock_value() [81/122]

template<>
sycl::vec< i16, 3 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i16, 3 >  min_bound,
sycl::vec< i16, 3 >  max_bound 
)

Definition at line 310 of file mock_value.cpp.

◆ mock_value() [82/122]

template<>
sycl::vec< i16, 4 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i16, 4 >  min_bound,
sycl::vec< i16, 4 >  max_bound 
)

Definition at line 310 of file mock_value.cpp.

◆ mock_value() [83/122]

template<>
sycl::vec< i16, 8 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i16, 8 >  min_bound,
sycl::vec< i16, 8 >  max_bound 
)

Definition at line 310 of file mock_value.cpp.

◆ mock_value() [84/122]

template<>
sycl::vec< i32, 16 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i32, 16 >  min_bound,
sycl::vec< i32, 16 >  max_bound 
)

Definition at line 309 of file mock_value.cpp.

◆ mock_value() [85/122]

template<>
sycl::vec< i32, 2 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i32, 2 >  min_bound,
sycl::vec< i32, 2 >  max_bound 
)

Definition at line 309 of file mock_value.cpp.

◆ mock_value() [86/122]

template<>
sycl::vec< i32, 3 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i32, 3 >  min_bound,
sycl::vec< i32, 3 >  max_bound 
)

Definition at line 309 of file mock_value.cpp.

◆ mock_value() [87/122]

template<>
sycl::vec< i32, 4 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i32, 4 >  min_bound,
sycl::vec< i32, 4 >  max_bound 
)

Definition at line 309 of file mock_value.cpp.

◆ mock_value() [88/122]

template<>
sycl::vec< i32, 8 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i32, 8 >  min_bound,
sycl::vec< i32, 8 >  max_bound 
)

Definition at line 309 of file mock_value.cpp.

◆ mock_value() [89/122]

template<>
sycl::vec< i64, 16 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i64, 16 >  min_bound,
sycl::vec< i64, 16 >  max_bound 
)

Definition at line 308 of file mock_value.cpp.

◆ mock_value() [90/122]

template<>
sycl::vec< i64, 2 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i64, 2 >  min_bound,
sycl::vec< i64, 2 >  max_bound 
)

Definition at line 308 of file mock_value.cpp.

◆ mock_value() [91/122]

template<>
sycl::vec< i64, 3 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i64, 3 >  min_bound,
sycl::vec< i64, 3 >  max_bound 
)

Definition at line 308 of file mock_value.cpp.

◆ mock_value() [92/122]

template<>
sycl::vec< i64, 4 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i64, 4 >  min_bound,
sycl::vec< i64, 4 >  max_bound 
)

Definition at line 308 of file mock_value.cpp.

◆ mock_value() [93/122]

template<>
sycl::vec< i64, 8 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i64, 8 >  min_bound,
sycl::vec< i64, 8 >  max_bound 
)

Definition at line 308 of file mock_value.cpp.

◆ mock_value() [94/122]

template<>
sycl::vec< i8, 16 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i8, 16 >  min_bound,
sycl::vec< i8, 16 >  max_bound 
)

Definition at line 311 of file mock_value.cpp.

◆ mock_value() [95/122]

template<>
sycl::vec< i8, 2 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i8, 2 >  min_bound,
sycl::vec< i8, 2 >  max_bound 
)

Definition at line 311 of file mock_value.cpp.

◆ mock_value() [96/122]

template<>
sycl::vec< i8, 3 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i8, 3 >  min_bound,
sycl::vec< i8, 3 >  max_bound 
)

Definition at line 311 of file mock_value.cpp.

◆ mock_value() [97/122]

template<>
sycl::vec< i8, 4 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i8, 4 >  min_bound,
sycl::vec< i8, 4 >  max_bound 
)

Definition at line 311 of file mock_value.cpp.

◆ mock_value() [98/122]

template<>
sycl::vec< i8, 8 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< i8, 8 >  min_bound,
sycl::vec< i8, 8 >  max_bound 
)

Definition at line 311 of file mock_value.cpp.

◆ mock_value() [99/122]

template<>
sycl::vec< u16, 16 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u16, 16 >  min_bound,
sycl::vec< u16, 16 >  max_bound 
)

Definition at line 305 of file mock_value.cpp.

◆ mock_value() [100/122]

template<>
sycl::vec< u16, 2 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u16, 2 >  min_bound,
sycl::vec< u16, 2 >  max_bound 
)

Definition at line 305 of file mock_value.cpp.

◆ mock_value() [101/122]

template<>
sycl::vec< u16, 3 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u16, 3 >  min_bound,
sycl::vec< u16, 3 >  max_bound 
)

Definition at line 305 of file mock_value.cpp.

◆ mock_value() [102/122]

template<>
sycl::vec< u16, 4 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u16, 4 >  min_bound,
sycl::vec< u16, 4 >  max_bound 
)

Definition at line 305 of file mock_value.cpp.

◆ mock_value() [103/122]

template<>
sycl::vec< u16, 8 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u16, 8 >  min_bound,
sycl::vec< u16, 8 >  max_bound 
)

Definition at line 305 of file mock_value.cpp.

◆ mock_value() [104/122]

template<>
sycl::vec< u32, 16 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u32, 16 >  min_bound,
sycl::vec< u32, 16 >  max_bound 
)

Definition at line 304 of file mock_value.cpp.

◆ mock_value() [105/122]

template<>
sycl::vec< u32, 2 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u32, 2 >  min_bound,
sycl::vec< u32, 2 >  max_bound 
)

Definition at line 304 of file mock_value.cpp.

◆ mock_value() [106/122]

template<>
sycl::vec< u32, 3 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u32, 3 >  min_bound,
sycl::vec< u32, 3 >  max_bound 
)

Definition at line 304 of file mock_value.cpp.

◆ mock_value() [107/122]

template<>
sycl::vec< u32, 4 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u32, 4 >  min_bound,
sycl::vec< u32, 4 >  max_bound 
)

Definition at line 304 of file mock_value.cpp.

◆ mock_value() [108/122]

template<>
sycl::vec< u32, 8 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u32, 8 >  min_bound,
sycl::vec< u32, 8 >  max_bound 
)

Definition at line 304 of file mock_value.cpp.

◆ mock_value() [109/122]

template<>
sycl::vec< u64, 16 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u64, 16 >  min_bound,
sycl::vec< u64, 16 >  max_bound 
)

Definition at line 303 of file mock_value.cpp.

◆ mock_value() [110/122]

template<>
sycl::vec< u64, 2 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u64, 2 >  min_bound,
sycl::vec< u64, 2 >  max_bound 
)

Definition at line 303 of file mock_value.cpp.

◆ mock_value() [111/122]

template<>
sycl::vec< u64, 3 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u64, 3 >  min_bound,
sycl::vec< u64, 3 >  max_bound 
)

Definition at line 303 of file mock_value.cpp.

◆ mock_value() [112/122]

template<>
sycl::vec< u64, 4 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u64, 4 >  min_bound,
sycl::vec< u64, 4 >  max_bound 
)

Definition at line 303 of file mock_value.cpp.

◆ mock_value() [113/122]

template<>
sycl::vec< u64, 8 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u64, 8 >  min_bound,
sycl::vec< u64, 8 >  max_bound 
)

Definition at line 303 of file mock_value.cpp.

◆ mock_value() [114/122]

template<>
sycl::vec< u8, 16 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u8, 16 >  min_bound,
sycl::vec< u8, 16 >  max_bound 
)

Definition at line 306 of file mock_value.cpp.

◆ mock_value() [115/122]

template<>
sycl::vec< u8, 2 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u8, 2 >  min_bound,
sycl::vec< u8, 2 >  max_bound 
)

Definition at line 306 of file mock_value.cpp.

◆ mock_value() [116/122]

template<>
sycl::vec< u8, 3 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u8, 3 >  min_bound,
sycl::vec< u8, 3 >  max_bound 
)

Definition at line 306 of file mock_value.cpp.

◆ mock_value() [117/122]

template<>
sycl::vec< u8, 4 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u8, 4 >  min_bound,
sycl::vec< u8, 4 >  max_bound 
)

Definition at line 306 of file mock_value.cpp.

◆ mock_value() [118/122]

template<>
sycl::vec< u8, 8 > shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
sycl::vec< u8, 8 >  min_bound,
sycl::vec< u8, 8 >  max_bound 
)

Definition at line 306 of file mock_value.cpp.

◆ mock_value() [119/122]

template<>
u16 shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
u16  min_bound,
u16  max_bound 
)

Definition at line 180 of file mock_value.cpp.

◆ mock_value() [120/122]

template<>
u32 shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
u32  min_bound,
u32  max_bound 
)

Definition at line 186 of file mock_value.cpp.

◆ mock_value() [121/122]

template<>
u64 shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
u64  min_bound,
u64  max_bound 
)

Definition at line 192 of file mock_value.cpp.

◆ mock_value() [122/122]

template<>
u8 shamalgs::primitives::mock_value ( std::mt19937_64 &  eng,
u8  min_bound,
u8  max_bound 
)

Definition at line 174 of file mock_value.cpp.

◆ mock_vector() [1/2]

template<class T >
std::vector< T > shamalgs::primitives::mock_vector ( u64  seed,
u32  len 
)
inline

Generates a vector of random mock values using default bounds.

This function generates a std::vector of random values of type T using the default minimum and maximum bounds defined by shambase::VectorProperties<T>. This is a convenience function that automatically determines appropriate bounds based on the type T. The function uses a deterministic random number generator seeded with the provided seed value.

Template Parameters
TThe type of values to generate (supports primitive types and SYCL vectors)
Parameters
seedThe seed value for the random number generator
lenThe length of the vector to generate
Returns
A std::vector<T> containing len random values within the default bounds for the type
// Generate vectors with default bounds
std::vector<i32> random_ints = shamalgs::mock_vector<i32>(42, 10);
std::vector<f64> random_doubles = shamalgs::mock_vector<f64>(123, 5);
std::vector<sycl::vec<f32, 2>> random_vecs = shamalgs::mock_vector<sycl::vec<f32, 2>>(456,
3);
Utility functions for generating random mock vectors.

Definition at line 100 of file mock_vector.hpp.

+ Here is the call graph for this function:

◆ mock_vector() [2/2]

template<class T >
std::vector< T > shamalgs::primitives::mock_vector ( u64  seed,
u32  len,
min_bound,
max_bound 
)

Generates a vector of random mock values within specified bounds.

This function generates a std::vector of random values of type T within the range [min_bound, max_bound]. Each element in the vector is generated independently using the same bounds. The function uses a deterministic random number generator seeded with the provided seed value, ensuring reproducible results for the same seed.

Template Parameters
TThe type of values to generate (supports primitive types and SYCL vectors)
Parameters
seedThe seed value for the random number generator
lenThe length of the vector to generate
min_boundThe minimum bound for the generated values
max_boundThe maximum bound for the generated values
Returns
A std::vector<T> containing len random values within the specified bounds
// Generate a vector of random integers
std::vector<i32> random_ints = shamalgs::mock_vector<i32>(42, 10, i32{0}, i32{100});
// Generate a vector of random floats
std::vector<f32> random_floats = shamalgs::mock_vector<f32>(123, 5, f32{0.0f}, f32{1.0f});
// Generate a vector of random SYCL vectors
std::vector<sycl::vec<f64, 3>> random_vecs = shamalgs::mock_vector<sycl::vec<f64, 3>>(
456,
3,
sycl::vec<f64, 3>{0.0, 0.0, 0.0},
sycl::vec<f64, 3>{1.0, 1.0, 1.0}
);

Definition at line 62 of file mock_vector.hpp.

+ Here is the call graph for this function:

◆ reduction_impl_from_params()

REDUCTION_IMPL shamalgs::primitives::reduction_impl_from_params ( const std::string &  impl)
inline

Definition at line 50 of file reduction.cpp.

◆ reduction_impl_to_params()

shamalgs::impl_param shamalgs::primitives::reduction_impl_to_params ( const REDUCTION_IMPL &  impl)
inline

Definition at line 68 of file reduction.cpp.

◆ scan_exclusive_sum_in_place()

template<class T >
void shamalgs::primitives::scan_exclusive_sum_in_place ( sham::DeviceBuffer< T > &  buf1,
u32  len 
)

Compute exclusive prefix sum in-place on a device buffer.

Performs an exclusive scan (prefix sum) operation on the device buffer, modifying it in-place. For each position i, the result contains the sum of all elements from index 0 to i-1. The first element is set to 0 (the identity for addition).

The operation transforms: [a, b, c, d] -> [0, a, a+b, a+b+c]

Template Parameters
TElement type - must support addition and assignment
Parameters
buf1Device buffer to scan in-place (modified by this operation)
lenNumber of elements to process from the beginning of the buffer
Note
The buffer is modified in-place; original values are overwritten
// Example: Basic exclusive scan
std::vector<u32> data = {1, 2, 3, 4, 5};
// Perform in-place exclusive scan
scan_exclusive_sum_in_place(buffer, data.size());
// Buffer now contains: [0, 1, 3, 6, 10]
auto result = buffer.copy_to_stdvec();
// result[0] = 0, result[1] = 1, result[2] = 3, result[3] = 6, result[4] = 10
// Example: Partial scan
std::vector<u32> values = {5, 10, 15, 20, 25, 30};
sham::DeviceBuffer<u32> partial_buffer(values);
// Scan only first 4 elements
scan_exclusive_sum_in_place(partial_buffer, 4);
// Buffer now contains: [0, 5, 15, 30, 25, 30]
// Only first 4 elements were modified
void scan_exclusive_sum_in_place(sham::DeviceBuffer< T > &buf1, u32 len)
Compute exclusive prefix sum in-place on a device buffer.

Definition at line 212 of file scan_exclusive_sum_in_place.cpp.

+ Here is the call graph for this function:

◆ scan_exclusive_sum_in_place_impl_from_params()

EXSCAN_IN_PLACE_IMPL shamalgs::primitives::scan_exclusive_sum_in_place_impl_from_params ( const std::string &  impl)
inline

Definition at line 139 of file scan_exclusive_sum_in_place.cpp.

◆ scan_exclusive_sum_in_place_impl_to_params()

shamalgs::impl_param shamalgs::primitives::scan_exclusive_sum_in_place_impl_to_params ( const EXSCAN_IN_PLACE_IMPL &  impl)
inline

Definition at line 163 of file scan_exclusive_sum_in_place.cpp.

◆ segmented_sort_in_place< u32 >()

template<>
void shamalgs::primitives::segmented_sort_in_place< u32 > ( sham::DeviceBuffer< u32 > &  buf,
const sham::DeviceBuffer< u32 > &  offsets 
)

Definition at line 203 of file segmented_sort_in_place.cpp.

◆ segmented_sort_in_place< u32_2 >()

template<>
void shamalgs::primitives::segmented_sort_in_place< u32_2 > ( sham::DeviceBuffer< u32_2 > &  buf,
const sham::DeviceBuffer< u32 > &  offsets 
)

Definition at line 194 of file segmented_sort_in_place.cpp.

◆ sort_by_key() [1/2]

template<class Tkey , class Tval >
void shamalgs::primitives::sort_by_key ( const sham::DeviceScheduler_ptr &  sched,
sham::DeviceBuffer< Tkey > &  buf_key,
sham::DeviceBuffer< Tval > &  buf_values,
u32  len 
)

Sort key-value pairs using USM buffers.

Performs an in-place parallel sort of key-value pairs where the values are reordered according to the sorted order of their corresponding keys.

Template Parameters
TkeyKey type - must be comparable (supports < operator)
TvalValue type - can be any copyable type
Parameters
schedsham::DeviceScheduler_ptr for execution
buf_keyDevice buffer containing the keys to sort by
buf_valuesDevice buffer containing the values to reorder
lenLength of both buffers
Exceptions
std::invalid_argumentif len is not a power of 2
Note
The function modifies both buffers in-place
This function currently only supports powers of 2
// Example: Sort data by keys using USM buffers
auto sched = shamsys::instance::get_compute_scheduler_ptr();
sham::DeviceBuffer<double> keys(input_keys, N);
sham::DeviceBuffer<DataType> values(input_values, N);
// Sort values according to key order
sort_by_key(sched, keys, values, N);
void sort_by_key(sycl::queue &q, sycl::buffer< Tkey > &buf_key, sycl::buffer< Tval > &buf_values, u32 len)
Sort key-value pairs using sycl::buffers.

Definition at line 159 of file sort_by_keys.hpp.

+ Here is the call graph for this function:

◆ sort_by_key() [2/2]

template<class Tkey , class Tval >
void shamalgs::primitives::sort_by_key ( sycl::queue &  q,
sycl::buffer< Tkey > &  buf_key,
sycl::buffer< Tval > &  buf_values,
u32  len 
)

Sort key-value pairs using sycl::buffers.

Performs an in-place parallel sort of key-value pairs where the values are reordered according to the sorted order of their corresponding keys.

Template Parameters
TkeyKey type - must be comparable (supports < operator)
TvalValue type - can be any copyable type
Parameters
qsycl::queue for device execution
buf_keyBuffer containing the keys to sort by
buf_valuesBuffer containing the values to reorder
lenLength of both buffers
Exceptions
std::invalid_argumentif len is not a power of 2
Note
The function modifies both buffers in-place
This function currently only supports powers of 2
// Example: Sort data by keys
sycl::queue q;
sycl::buffer<double> keys(input_keys, N);
sycl::buffer<DataType> values(input_values, N);
// Sort values according to key order
sort_by_key(q, keys, values, N);

Definition at line 123 of file sort_by_keys.hpp.

+ Here is the call graph for this function:

◆ sort_by_key_pow2_len() [1/2]

template<class Tkey , class Tval >
void shamalgs::primitives::sort_by_key_pow2_len ( const sham::DeviceScheduler_ptr &  sched,
sham::DeviceBuffer< Tkey > &  buf_key,
sham::DeviceBuffer< Tval > &  buf_values,
u32  len 
)

Sort key-value pairs using USM buffers (power-of-2 optimized)

Performs an in-place parallel sort of key-value pairs where the values are reordered according to the sorted order of their corresponding keys.

Template Parameters
TkeyKey type - must be comparable (supports < operator)
TvalValue type - can be any copyable type
Parameters
schedsham::DeviceScheduler_ptr for execution
buf_keyDevice buffer containing the keys to sort by
buf_valuesDevice buffer containing the values to reorder
lenLength of both buffers (must be a power of 2)
Note
The function modifies both buffers in-place
// Example: Sort data by keys using USM buffers
auto sched = shamsys::instance::get_compute_scheduler_ptr();
sham::DeviceBuffer<float> keys(input_keys, N);
sham::DeviceBuffer<DataType> values(input_values, N);
// Sort values according to key order
sort_by_key_pow2_len(sched, keys, values, N);
void sort_by_key_pow2_len(sycl::queue &q, sycl::buffer< Tkey > &buf_key, sycl::buffer< Tval > &buf_values, u32 len)
Sort key-value pairs using sycl::buffers (power-of-2 optimized)

Definition at line 36 of file sort_by_keys.cpp.

◆ sort_by_key_pow2_len() [2/2]

template<class Tkey , class Tval >
void shamalgs::primitives::sort_by_key_pow2_len ( sycl::queue &  q,
sycl::buffer< Tkey > &  buf_key,
sycl::buffer< Tval > &  buf_values,
u32  len 
)

Sort key-value pairs using sycl::buffers (power-of-2 optimized)

Performs an in-place parallel sort of key-value pairs where the values are reordered according to the sorted order of their corresponding keys.

Template Parameters
TkeyKey type - must be comparable (supports < operator)
TvalValue type - can be any copyable type
Parameters
qsycl::queue for device execution
buf_keyBuffer containing the keys to sort by
buf_valuesBuffer containing the values to reorder
lenLength of both buffers (must be a power of 2)
Note
The function modifies both buffers in-place
// Example: Sort data by keys
sycl::queue q;
sycl::buffer<float> keys(input_keys, N);
sycl::buffer<DataType> values(input_values, N);
// Sort values according to key order
sort_by_key_pow2_len(q, keys, values, N);

Definition at line 24 of file sort_by_keys.cpp.

◆ sum()

template<class T >
T shamalgs::primitives::sum ( const sham::DeviceScheduler_ptr &  sched,
const sham::DeviceBuffer< T > &  buf1,
u32  start_id,
u32  end_id 
)

Compute the sum of elements in a device buffer within a specified range.

This function computes the sum of all elements in the buffer between start_id (inclusive) and end_id (exclusive). The computation is performed on the device using the provided scheduler.

Template Parameters
TThe data type of elements in the buffer (e.g., float, double, int).
Parameters
schedThe device scheduler to run on.
buf1The input buffer containing the elements to sum.
start_idThe starting index (inclusive) of the range to sum.
end_idThe ending index (exclusive) of the range to sum.
Returns
T The computed sum of elements in the specified range.
Precondition
start_id <= end_id
end_id <= buf1.get_size()

Example:

auto sched = shamsys::get_compute_Scheduler_ptr();
u32 start = 0;
u32 end = values.get_size();
double total = shamalgs::primitives::sum(sched, values, start, end);
T sum(const sham::DeviceScheduler_ptr &sched, const sham::DeviceBuffer< T > &buf1, u32 start_id, u32 end_id)
Compute the sum of elements in a device buffer within a specified range.

values = {1.0, 2.0, 3.0, 4.0, 5.0}, start = 1, end = 4 result = 9.0 (2.0 + 3.0 + 4.0)

Definition at line 105 of file reduction.cpp.

+ Here is the call graph for this function:

◆ unflatten_buffer()

template<class Tvec , sham::USMKindTarget target>
sham::DeviceBuffer< Tvec, target > shamalgs::primitives::unflatten_buffer ( const sham::DeviceBuffer< typename shambase::VectorProperties< Tvec >::component_type, target > &  buffer)
inline

Unflatten a buffer that contains a flattened vector.

Parameters
bufferThe buffer to unflatten
Returns
A new buffer of type Tvec with the same size as the original buffer divided by the number of components in the vector.
Exceptions
std::invalid_argumentif the buffer has a size that is not a multiple of the number of components in the vector.
std::runtime_errorif the buffer is not a device buffer.

Definition at line 116 of file flatten.hpp.

+ Here is the call graph for this function:

Variable Documentation

◆ is_all_true_impl

IS_ALL_TRUE_IMPL shamalgs::primitives::is_all_true_impl = IS_ALL_TRUE_IMPL::HOST

Definition at line 70 of file is_all_true.cpp.

◆ reduction_impl

REDUCTION_IMPL shamalgs::primitives::reduction_impl = get_default_reduction_impl()

Definition at line 48 of file reduction.cpp.

◆ scan_exclusive_sum_in_place_impl

EXSCAN_IN_PLACE_IMPL shamalgs::primitives::scan_exclusive_sum_in_place_impl = get_default_scan_exclusive_sum_in_place_impl()

Definition at line 136 of file scan_exclusive_sum_in_place.cpp.