27namespace shamalgs::primitives::details {
31 template<
class Tkey,
class Tval>
38 std::vector<Tkey> key_sub(key_stdvec.begin(), key_stdvec.begin() + len);
39 std::vector<Tval> val_sub(val_stdvec.begin(), val_stdvec.begin() + len);
43 std::copy(key_sub.begin(), key_sub.end(), key_stdvec.begin());
44 std::copy(val_sub.begin(), val_sub.end(), val_stdvec.begin());
59 static constexpr std::string_view variant_type_name =
"std_sort";
64 static constexpr std::string_view variant_type_name =
"batcher_odd_even_host_serial";
69 static constexpr std::string_view variant_type_name =
"batcher_odd_even";
73 sort_by_keys_impl{[](
const sham::DeviceScheduler_ptr &,
auto &self) {
79 return sort_by_keys_impl.get_default_config_list();
84 return sort_by_keys_impl.get_current_config();
92 shamlog_info_ln(
"algs",
"setting sort by keys implementation to impl :",
impl);
93 sort_by_keys_impl.set(
impl);
98 sort_by_keys_impl.autoselect(dev_sched);
101 "defaulting sort by keys implementation to impl :",
107 template<
class Tkey,
class Tval>
111 if (!impl::sort_by_keys_impl.is_set()) {
128 impl::sort_by_keys_impl.get());
Generic std::variant-based implementation selector.
std::uint32_t u32
32 bit unsigned integer
Batcher odd-even mergesort, native for any length.
A buffer allocated in USM (Unified Shared Memory).
void copy_from_stdvec(const std::vector< T > &vec)
Copy the content of a std::vector into the buffer.
std::shared_ptr< DeviceScheduler > & get_dev_scheduler_ptr()
Gets the Device scheduler pointer corresponding to the held allocation.
std::vector< T > copy_to_stdvec() const
Copy the content of the buffer to a std::vector.
Drop-in replacement for the hand-rolled "global variable + enum + name mapping.
This header file contains utility functions related to exception handling in the code.
void sort_by_key_batcher_odd_even_host_reference(std::vector< Tkey > &keys, std::vector< Tval > &values)
Host reference of sort_by_key_batcher_odd_even.
void sort_by_key_batcher_odd_even(const sham::DeviceScheduler_ptr &sched, sham::DeviceBuffer< Tkey > &buf_key, sham::DeviceBuffer< Tval > &buf_values, u32 len)
Sort key-value pairs of any length using a Batcher odd-even merge network.
namespace to control implementation behavior
std::vector< std::string > get_default_impl_list_sort_by_keys()
Get list of available sort by keys implementations, as config json strings.
std::string get_current_impl_sort_by_keys()
Get the current implementation for sort by keys, as a config json string.
void autoselect_impl_sort_by_keys(const sham::DeviceScheduler_ptr &dev_sched)
Select the default implementation for sort by keys.
void set_impl_sort_by_keys(const std::string &impl)
Set the implementation for sort by keys, from a config json string.
bool is_impl_set_sort_by_keys()
Check if an implementation has been selected for sort by keys.
namespace for primitive algorithm (e.g. sort, scan, reductions, ...)
void sort_by_keys(sham::DeviceBuffer< Tkey > &buf_key, sham::DeviceBuffer< Tval > &buf_values, u32 len)
Sort key-value pairs using USM buffers (general length).
void sort_by_keys_batcher_odd_even_host_serial(sham::DeviceBuffer< Tkey > &buf_key, sham::DeviceBuffer< Tval > &buf_values, u32 len)
std::sort based sort by keys implementation, shared by the sort by keys primitives
void sort_by_keys_std_sort(sham::DeviceBuffer< Tkey > &buf_key, sham::DeviceBuffer< Tval > &buf_values, u32 len)
Copy both buffers to host, std::sort the zipped key/value pairs, and copy back.
Copy the buffers to host, sort with Batcher's odd-even merge sort, and copy back.
Copy the buffers to host, sort with Batcher's odd-even merge sort, and copy back.
Copy the buffers to host, std::sort the zipped key/value pairs, and copy back.
Build an overload set out of several callables, for use with std::visit.