MLX
 
Loading...
Searching...
No Matches
accelerate_simd.h File Reference
#include <simd/math.h>
#include <simd/vector.h>
#include <stdint.h>
#include <cmath>
#include <complex>
#include "mlx/backend/cpu/simd/base_simd.h"

Go to the source code of this file.

Classes

struct  mlx::core::simd::ScalarT< T, N >
 
struct  mlx::core::simd::ScalarT< bool, N >
 
struct  mlx::core::simd::ScalarT< int8_t, N >
 
struct  mlx::core::simd::ScalarT< uint64_t, N >
 
struct  mlx::core::simd::ScalarT< int64_t, N >
 
struct  mlx::core::simd::Simd< T, N >
 

Namespaces

namespace  mlx
 
namespace  mlx::core
 
namespace  mlx::core::simd
 

Macros

#define MLX_SIMD_LIBRARY_VERSION   5
 
#define SIMD_DEFAULT_UNARY(name, op)
 
#define SIMD_DEFAULT_BINARY(OP)
 
#define SIMD_DEFAULT_COMPARISONS(OP)
 

Functions

template<typename T, int N>
Simd< T, Nmlx::core::simd::abs (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::floor (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::acos (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::acosh (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::asin (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::asinh (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::atan (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::atanh (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::ceil (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::cosh (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::expm1 (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::log (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::log2 (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::log10 (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::log1p (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::rint (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::sinh (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::sqrt (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::rsqrt (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::recip (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::tan (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::tanh (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::operator- (Simd< T, N > v)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::operator~ (Simd< T, N > v)
 
template<typename T, int N>
Simd< bool, Nmlx::core::simd::isnan (Simd< T, N > v)
 
template<typename T, int N>
Simd< bool, Nmlx::core::simd::operator! (Simd< T, N > v)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator+ (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator+ (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator+ (Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator- (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator- (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator- (Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator/ (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator/ (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator/ (Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator* (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator* (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator* (Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator<< (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator<< (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator<< (Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator>> (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator>> (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator>> (Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator| (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator| (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator| (Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator^ (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator^ (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator^ (Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator& (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator& (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator& (Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator&& (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator&& (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator&& (Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::operator|| (Simd< T, N > x, U y)
 
template<typename T1, typename T2, int N>
Simd< T2, Nmlx::core::simd::operator|| (T1 x, Simd< T2, N > y)
 
template<typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::operator|| (Simd< T1, N > x, Simd< T2, N > y)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator> (Simd< T, N > a, U b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator> (T a, Simd< U, N > b)
 
template<int N, typename T1, typename T2>
Simd< bool, Nmlx::core::simd::operator> (Simd< T1, N > a, Simd< T2, N > b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator< (Simd< T, N > a, U b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator< (T a, Simd< U, N > b)
 
template<int N, typename T1, typename T2>
Simd< bool, Nmlx::core::simd::operator< (Simd< T1, N > a, Simd< T2, N > b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator>= (Simd< T, N > a, U b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator>= (T a, Simd< U, N > b)
 
template<int N, typename T1, typename T2>
Simd< bool, Nmlx::core::simd::operator>= (Simd< T1, N > a, Simd< T2, N > b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator<= (Simd< T, N > a, U b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator<= (T a, Simd< U, N > b)
 
template<int N, typename T1, typename T2>
Simd< bool, Nmlx::core::simd::operator<= (Simd< T1, N > a, Simd< T2, N > b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator== (Simd< T, N > a, U b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator== (T a, Simd< U, N > b)
 
template<int N, typename T1, typename T2>
Simd< bool, Nmlx::core::simd::operator== (Simd< T1, N > a, Simd< T2, N > b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator!= (Simd< T, N > a, U b)
 
template<int N, typename T, typename U>
Simd< bool, Nmlx::core::simd::operator!= (T a, Simd< U, N > b)
 
template<int N, typename T1, typename T2>
Simd< bool, Nmlx::core::simd::operator!= (Simd< T1, N > a, Simd< T2, N > b)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::atan2 (Simd< T, N > a, Simd< T, N > b)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::maximum (Simd< T, N > a, Simd< T, N > b)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::minimum (Simd< T, N > a, Simd< T, N > b)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::remainder (Simd< T, N > a, Simd< T, N > b)
 
template<typename MaskT, typename T1, typename T2, int N>
Simd< T1, Nmlx::core::simd::select (Simd< MaskT, N > mask, Simd< T1, N > x, Simd< T2, N > y)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::pow (Simd< T, N > base, Simd< T, N > exp)
 
template<typename T, int N>
Simd< T, Nmlx::core::simd::clamp (Simd< T, N > v, Simd< T, N > min, Simd< T, N > max)
 
template<typename T, typename U, int N>
Simd< T, Nmlx::core::simd::fma (Simd< T, N > x, Simd< T, N > y, U z)
 
template<typename T, int N>
bool mlx::core::simd::all (Simd< T, N > x)
 
template<typename T, int N>
bool mlx::core::simd::any (Simd< T, N > x)
 
template<typename T, int N>
mlx::core::simd::sum (Simd< T, N > x)
 
template<typename T, int N>
mlx::core::simd::max (Simd< T, N > x)
 
template<typename T, int N>
mlx::core::simd::min (Simd< T, N > x)
 
template<typename T, int N>
mlx::core::simd::prod (Simd< T, N > x)
 

Variables

template<>
static constexpr int mlx::core::simd::max_size< int8_t > = 16
 
template<>
static constexpr int mlx::core::simd::max_size< int16_t > = 16
 
template<>
static constexpr int mlx::core::simd::max_size< int > = 8
 
template<>
static constexpr int mlx::core::simd::max_size< int64_t > = 4
 
template<>
static constexpr int mlx::core::simd::max_size< uint8_t > = 16
 
template<>
static constexpr int mlx::core::simd::max_size< uint16_t > = 16
 
template<>
static constexpr int mlx::core::simd::max_size< uint32_t > = 8
 
template<>
static constexpr int mlx::core::simd::max_size< uint64_t > = 4
 
template<>
static constexpr int mlx::core::simd::max_size< float > = 8
 
template<>
static constexpr int mlx::core::simd::max_size< double > = 4
 

Macro Definition Documentation

◆ MLX_SIMD_LIBRARY_VERSION

#define MLX_SIMD_LIBRARY_VERSION   5

◆ SIMD_DEFAULT_BINARY

#define SIMD_DEFAULT_BINARY ( OP)
Value:
template <typename T, typename U, int N> \
Simd<T, N> operator OP(Simd<T, N> x, U y) { \
return asd::convert<typename Simd<T, N>::scalar_t>(x.value OP y); \
} \
template <typename T1, typename T2, int N> \
Simd<T2, N> operator OP(T1 x, Simd<T2, N> y) { \
return asd::convert<typename Simd<T2, N>::scalar_t>(x OP y.value); \
} \
template <typename T1, typename T2, int N> \
Simd<T1, N> operator OP(Simd<T1, N> x, Simd<T2, N> y) { \
return asd::convert<typename Simd<T1, N>::scalar_t>(x.value OP y.value); \
}

◆ SIMD_DEFAULT_COMPARISONS

#define SIMD_DEFAULT_COMPARISONS ( OP)
Value:
template <int N, typename T, typename U> \
Simd<bool, N> operator OP(Simd<T, N> a, U b) { \
return asd::convert<char>(a.value OP b); \
} \
template <int N, typename T, typename U> \
Simd<bool, N> operator OP(T a, Simd<U, N> b) { \
return asd::convert<char>(a OP b.value); \
} \
template <int N, typename T1, typename T2> \
Simd<bool, N> operator OP(Simd<T1, N> a, Simd<T2, N> b) { \
return asd::convert<char>(a.value OP b.value); \
}

◆ SIMD_DEFAULT_UNARY

#define SIMD_DEFAULT_UNARY ( name,
op )
Value:
template <typename T, int N> \
Simd<T, N> name(Simd<T, N> v) { \
return op(v.value); \
}