/
vuron
/
adept
Обзор
Документация
Войти
/
vuron
/
adept
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/backends/cpu/arithmetics.hpp
109 строк
3 KB
kolkir
Refactor simd algos to use map reduce
16 мар 2025, 23:09
16 мар 2025, 23:09
5f536e1
Код
Авторство
О чём код?
// should be included in only ones section after arithmetics-inl.hpp #pragma once #include <hwy/highway.h> #include <adept/types.hpp> #if HWY_ONCE namespace adept::detail { // callers for SIMD function platforms overloads struct add { template <typename DataType> static void apply(DataType* x_array, const DataType* y_array, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(add_vectors<DataType>) (x_array, y_array, size, aligned); } template <typename DataType> static void apply(DataType* x_array, float scalar, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(add_vector_scalar<DataType>) (x_array, scalar, size, aligned); } }; struct sub { template <typename DataType> static void apply(DataType* x_array, const DataType* y_array, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(sub_vectors<DataType>) (x_array, y_array, size, aligned); } template <typename DataType> static void apply(DataType* x_array, float32_t scalar, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(sub_vector_scalar<DataType>) (x_array, scalar, size, aligned); } }; struct mul { template <typename DataType> static void apply(DataType* x_array, const DataType* y_array, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(mul_vectors<DataType>) (x_array, y_array, size, aligned); } template <typename DataType> static void apply(DataType* x_array, float32_t scalar, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(mul_vector_scalar<DataType>) (x_array, scalar, size, aligned); } }; struct div { template <typename DataType> static void apply(DataType* x_array, const DataType* y_array, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(div_vectors<DataType>) (x_array, y_array, size, aligned); } template <typename DataType> static void apply(DataType* x_array, float32_t scalar, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(div_vector_scalar<DataType>) (x_array, scalar, size, aligned); } }; struct neg { template <typename DataType> static void apply(DataType* x_array, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(vector_neg<DataType>) (x_array, size, aligned); } }; struct exp { template <typename DataType> static void apply(DataType* x_array, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(vector_exp<DataType>) (x_array, size, aligned); } }; struct sqrt { template <typename DataType> static void apply(DataType* x_array, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(vector_sqrt<DataType>) (x_array, size, aligned); } }; struct max { template <typename DataType> static void apply(const DataType* x_array, DataType& out, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(vector_max<DataType>) (x_array, out, size, aligned); } }; struct sum { template <typename DataType> static void apply(const DataType* x_array, DataType& out, index_t size, bool aligned) { HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(vector_sum<DataType>) (x_array, out, size, aligned); } }; } // namespace adept::detail #endif // HWY_ONCE