Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pyShamalgs.cpp File Reference
Include dependency graph for pyShamalgs.cpp:

Go to the source code of this file.

Functions

 py::class_< std::mt19937 > (shamalgs_module, "rng")
py::class_< shamalgs::impl_param >(shamalgs_module, "impl_param") .def(py shamalgs_module def ("gen_seed", [](u64 seed) { return std::mt19937(seed);})
shamalgs_module def ("mock_gaussian", [](std::mt19937 &eng) { return shamalgs::random::mock_gaussian< f64 >(eng);})
shamalgs_module def ("mock_gaussian_f64_2", [](std::mt19937 &eng) { return shamalgs::random::mock_gaussian_multidim< f64_2 >(eng);})
shamalgs_module def ("mock_gaussian_f64_3", [](std::mt19937 &eng) { return shamalgs::random::mock_gaussian_multidim< f64_3 >(eng);})
shamalgs_module def ("mock_unit_vector_f64_3", [](std::mt19937 &eng) { return shamalgs::random::mock_unit_vector< f64_3 >(eng);})
shamalgs_module def ("mock_buffer_f64", [](u64 seed, u32 len, f64 min_bound, f64 max_bound) { return shamalgs::random::mock_buffer_usm< f64 >(shamsys::instance::get_compute_scheduler_ptr(), seed, len, min_bound, max_bound);})
shamalgs_module def ("mock_buffer_u8", [](u64 seed, u32 len, u8 min_bound, u8 max_bound) { return shamalgs::random::mock_buffer_usm< u8 >(shamsys::instance::get_compute_scheduler_ptr(), seed, len, min_bound, max_bound);})
shamalgs_module def ("mock_buffer_u32", [](u64 seed, u32 len, u32 min_bound, u32 max_bound) { return shamalgs::random::mock_buffer_usm< u32 >(shamsys::instance::get_compute_scheduler_ptr(), seed, len, min_bound, max_bound);})
shamalgs_module def ("mock_buffer_f64_2", [](u64 seed, u32 len, f64_2 min_bound, f64_2 max_bound) { return shamalgs::random::mock_buffer_usm< f64_2 >(shamsys::instance::get_compute_scheduler_ptr(), seed, len, min_bound, max_bound);})
shamalgs_module def ("mock_buffer_f64_3", [](u64 seed, u32 len, f64_3 min_bound, f64_3 max_bound) { return shamalgs::random::mock_buffer_usm< f64_3 >(shamsys::instance::get_compute_scheduler_ptr(), seed, len, min_bound, max_bound);})
shamalgs_module def ("benchmark_is_all_true", [](sham::DeviceBuffer< u8 > &buf, u32 len) { buf.synchronize();shambase::Timer timer;timer.start();bool result=shamalgs::primitives::is_all_true(buf, len);buf.synchronize();timer.stop();return timer.elapsed_sec();})
shamalgs_module def ("set_impl_is_all_true", [](const std::string &impl, const std::string &param="") { shamalgs::primitives::impl::set_impl_is_all_true(impl, param);})
shamalgs_module def ("get_current_impl_is_all_true", []() { return shamalgs::primitives::impl::get_current_impl_is_all_true();})
shamalgs_module def ("get_default_impl_list_is_all_true", []() { return shamalgs::primitives::impl::get_default_impl_list_is_all_true();})
shamalgs_module def ("benchmark_reduction_sum", [](sham::DeviceBuffer< f64 > &buf, u32 len) { buf.synchronize();shambase::Timer timer;timer.start();f64 result=shamalgs::primitives::sum(shamsys::instance::get_compute_scheduler_ptr(), buf, 0, len);timer.stop();return timer.elapsed_sec();})
shamalgs_module def ("benchmark_reduction_sum", [](sham::DeviceBuffer< f32 > &buf, u32 len) { buf.synchronize();shambase::Timer timer;timer.start();f32 result=shamalgs::primitives::sum(shamsys::instance::get_compute_scheduler_ptr(), buf, 0, len);timer.stop();return timer.elapsed_sec();})
shamalgs_module def ("set_impl_reduction", [](const std::string &impl, const std::string &param="") { shamalgs::primitives::impl::set_impl_reduction(impl, param);})
shamalgs_module def ("get_current_impl_reduction", []() { return shamalgs::primitives::impl::get_current_impl_reduction();})
shamalgs_module def ("get_default_impl_list_reduction", []() { return shamalgs::primitives::impl::get_default_impl_list_reduction();})
shamalgs_module def ("benchmark_scan_exclusive_sum_in_place", [](sham::DeviceBuffer< u32 > &buf, u32 len) { buf.synchronize();shambase::Timer timer;timer.start();shamalgs::primitives::scan_exclusive_sum_in_place(buf, len);buf.synchronize();timer.stop();return timer.elapsed_sec();})
shamalgs_module def ("set_impl_scan_exclusive_sum_in_place", [](const std::string &impl, const std::string &param="") { shamalgs::primitives::impl::set_impl_scan_exclusive_sum_in_place(impl, param);})
shamalgs_module def ("get_current_impl_scan_exclusive_sum_in_place", []() { return shamalgs::primitives::impl::get_current_impl_scan_exclusive_sum_in_place();})
shamalgs_module def ("get_default_impl_list_scan_exclusive_sum_in_place", []() { return shamalgs::primitives::impl::get_default_impl_list_scan_exclusive_sum_in_place();})
shamalgs_module def ("benchmark_segmented_sort_in_place", [](sham::DeviceBuffer< u32 > &buf, const sham::DeviceBuffer< u32 > &offsets) { auto buf_copy=buf.copy();auto offsets_copy=offsets.copy();buf_copy.synchronize();offsets_copy.synchronize();shambase::Timer timer;timer.start();shamalgs::primitives::segmented_sort_in_place(buf_copy, offsets_copy);buf_copy.synchronize();offsets_copy.synchronize();timer.stop();return timer.elapsed_sec();})
shamalgs_module def ("set_impl_segmented_sort_in_place", [](const std::string &impl, const std::string &param="") { shamalgs::primitives::impl::set_impl_segmented_sort_in_place(impl, param);})
shamalgs_module def ("get_current_impl_segmented_sort_in_place", []() { return shamalgs::primitives::impl::get_current_impl_segmented_sort_in_place();})
shamalgs_module def ("get_default_impl_list_segmented_sort_in_place", []() { return shamalgs::primitives::impl::get_default_impl_list_segmented_sort_in_place();})
 py::class_< shamalgs::primitives::ImplControl > (shamalgs_module, "ImplControl") .def("get_alg_name"
 def ("was_configured", [](shamalgs::primitives::ImplControl &impl_control) { return impl_control.was_configured(shamsys::instance::get_compute_scheduler_ptr());}) .def("get_config"
 def ("set_config", [](shamalgs::primitives::ImplControl &impl_control, const std::string &config) { impl_control.set_config(shamsys::instance::get_compute_scheduler_ptr(), config);}) .def("get_default_config"
 def ("get_avail_configs", [](shamalgs::primitives::ImplControl &impl_control) { return impl_control.get_avail_configs(shamsys::instance::get_compute_scheduler_ptr());})
shamalgs_module def ("compute_histogram_impl", []() -> shamalgs::primitives::ImplControl &{ return shamalgs::primitives::impl::compute_histogram_impl_control;}, py::return_value_policy::reference)
shamalgs_module def ("compute_histogram_basic_f64", [](sham::DeviceBuffer< f64 > &bin_edge_inf, sham::DeviceBuffer< f64 > &bin_edge_sup, sham::DeviceBuffer< f64 > &positions) { return shamalgs::primitives::compute_histogram_basic< f64 >(shamsys::instance::get_compute_scheduler_ptr(), bin_edge_inf, bin_edge_sup, positions);})
shamalgs_module def ("compute_histogram_basic_f32", [](sham::DeviceBuffer< f32 > &bin_edge_inf, sham::DeviceBuffer< f32 > &bin_edge_sup, sham::DeviceBuffer< f32 > &positions) { return shamalgs::primitives::compute_histogram_basic< f32 >(shamsys::instance::get_compute_scheduler_ptr(), bin_edge_inf, bin_edge_sup, positions);})
shamalgs_module def ("benchmark_compute_histogram_basic_f64", [](sham::DeviceBuffer< f64 > &bin_edge_inf, sham::DeviceBuffer< f64 > &bin_edge_sup, sham::DeviceBuffer< f64 > &positions) { bin_edge_inf.synchronize();bin_edge_sup.synchronize();positions.synchronize();auto run=[&]() { auto result=shamalgs::primitives::compute_histogram_basic< f64 >(shamsys::instance::get_compute_scheduler_ptr(), bin_edge_inf, bin_edge_sup, positions);result.synchronize();};run();return shambase::timeitfor(run);})
shamalgs_module def ("benchmark_compute_histogram_basic_f32", [](sham::DeviceBuffer< f32 > &bin_edge_inf, sham::DeviceBuffer< f32 > &bin_edge_sup, sham::DeviceBuffer< f32 > &positions) { bin_edge_inf.synchronize();bin_edge_sup.synchronize();positions.synchronize();auto run=[&]() { auto result=shamalgs::primitives::compute_histogram_basic< f32 >(shamsys::instance::get_compute_scheduler_ptr(), bin_edge_inf, bin_edge_sup, positions);result.synchronize();};run();return shambase::timeitfor(run);})
shamalgs_module def ("string_histogram", [](const std::vector< std::string > &inputs, std::string delimiter, bool hash_based) { return shamalgs::collective::string_histogram(inputs, std::move(delimiter), hash_based);}, py::arg("inputs"), py::arg("delimiter")="\n", py::arg("hash_based")=false)
shamalgs_module def ("all_string_histogram", [](const std::vector< std::string > &inputs, std::string delimiter, bool hash_based) { return shamalgs::collective::all_string_histogram(inputs, std::move(delimiter), hash_based);}, py::arg("inputs"), py::arg("delimiter")="\n", py::arg("hash_based")=false)

Variables

 ON_PYTHON_INIT
py::module shamalgs_module = m.def_submodule("algs", "algorithmic library")
shamalgs::primitives::ImplControlimpl_control

Detailed Description

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Definition in file pyShamalgs.cpp.

Variable Documentation

◆ impl_control

Initial value:
{
return impl_control.get_alg_name()

Definition at line 255 of file pyShamalgs.cpp.

◆ ON_PYTHON_INIT

ON_PYTHON_INIT
Initial value:
{
auto &m = root_module

Definition at line 35 of file pyShamalgs.cpp.

◆ shamalgs_module

py::module shamalgs_module = m.def_submodule("algs", "algorithmic library")

Definition at line 38 of file pyShamalgs.cpp.