Grok 10.0.5
Classes | Namespaces | Macros | Typedefs | Functions | Variables
base.h File Reference
#include <stddef.h>
#include <stdint.h>
#include "hwy/detect_compiler_arch.h"
#include "hwy/highway_export.h"

Go to the source code of this file.

Classes

struct  hwy::float16_t
 
struct  hwy::bfloat16_t
 
struct  hwy::uint128_t
 
struct  hwy::K64V64
 
struct  hwy::K32V32
 
struct  hwy::EnableIfT< Condition >
 
struct  hwy::EnableIfT< true >
 
struct  hwy::IsSameT< T, U >
 
struct  hwy::IsSameT< T, T >
 
struct  hwy::SizeTag< N >
 
struct  hwy::RemoveConstT< T >
 
struct  hwy::RemoveConstT< const T >
 
struct  hwy::detail::Relations< uint8_t >
 
struct  hwy::detail::Relations< int8_t >
 
struct  hwy::detail::Relations< uint16_t >
 
struct  hwy::detail::Relations< int16_t >
 
struct  hwy::detail::Relations< uint32_t >
 
struct  hwy::detail::Relations< int32_t >
 
struct  hwy::detail::Relations< uint64_t >
 
struct  hwy::detail::Relations< int64_t >
 
struct  hwy::detail::Relations< uint128_t >
 
struct  hwy::detail::Relations< float16_t >
 
struct  hwy::detail::Relations< bfloat16_t >
 
struct  hwy::detail::Relations< float >
 
struct  hwy::detail::Relations< double >
 
struct  hwy::detail::TypeFromSize< 1 >
 
struct  hwy::detail::TypeFromSize< 2 >
 
struct  hwy::detail::TypeFromSize< 4 >
 
struct  hwy::detail::TypeFromSize< 8 >
 
struct  hwy::detail::TypeFromSize< 16 >
 

Namespaces

namespace  hwy
 
namespace  hwy::detail
 

Macros

#define HWY_STR_IMPL(macro)   #macro
 
#define HWY_STR(macro)   HWY_STR_IMPL(macro)
 
#define HWY_RESTRICT   __restrict__
 
#define HWY_INLINE   inline
 
#define HWY_NOINLINE   __attribute__((noinline))
 
#define HWY_FLATTEN   __attribute__((flatten))
 
#define HWY_NORETURN   __attribute__((noreturn))
 
#define HWY_LIKELY(expr)   __builtin_expect(!!(expr), 1)
 
#define HWY_UNLIKELY(expr)   __builtin_expect(!!(expr), 0)
 
#define HWY_PRAGMA(tokens)   _Pragma(#tokens)
 
#define HWY_DIAGNOSTICS(tokens)   HWY_PRAGMA(GCC diagnostic tokens)
 
#define HWY_DIAGNOSTICS_OFF(msc, gcc)   HWY_DIAGNOSTICS(gcc)
 
#define HWY_MAYBE_UNUSED   __attribute__((unused))
 
#define HWY_MUST_USE_RESULT   __attribute__((warn_unused_result))
 
#define HWY_FORMAT(idx_fmt, idx_arg)
 
#define HWY_ASSUME_ALIGNED(ptr, align)   (ptr) /* not supported */
 
#define HWY_PUSH_ATTRIBUTES(targets_str)
 
#define HWY_POP_ATTRIBUTES
 
#define HWY_API   static HWY_INLINE HWY_FLATTEN HWY_MAYBE_UNUSED
 
#define HWY_CONCAT_IMPL(a, b)   a##b
 
#define HWY_CONCAT(a, b)   HWY_CONCAT_IMPL(a, b)
 
#define HWY_MIN(a, b)   ((a) < (b) ? (a) : (b))
 
#define HWY_MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define HWY_UNROLL(factor)
 
#define HWY_DEFAULT_UNROLL
 
#define HWY_ASSUME(expr)   static_cast<void>(0)
 
#define HWY_FENCE
 
#define HWY_REP4(literal)   literal, literal, literal, literal
 
#define HWY_ABORT(format, ...)    ::hwy::Abort(__FILE__, __LINE__, format, ##__VA_ARGS__)
 
#define HWY_ASSERT(condition)
 
#define HWY_IS_MSAN   0
 
#define HWY_IS_ASAN   0
 
#define HWY_IS_TSAN   0
 
#define HWY_ATTR_NO_MSAN
 
#define HWY_IS_DEBUG_BUILD   1
 
#define HWY_DASSERT(condition)   HWY_ASSERT(condition)
 
#define HWY_ALIGN_MAX   alignas(16)
 
#define HWY_IF_LE128(T, N)   hwy::EnableIf<N * sizeof(T) <= 16>* = nullptr
 
#define HWY_IF_LE64(T, N)   hwy::EnableIf<N * sizeof(T) <= 8>* = nullptr
 
#define HWY_IF_LE32(T, N)   hwy::EnableIf<N * sizeof(T) <= 4>* = nullptr
 
#define HWY_IF_GE32(T, N)   hwy::EnableIf<N * sizeof(T) >= 4>* = nullptr
 
#define HWY_IF_GE64(T, N)   hwy::EnableIf<N * sizeof(T) >= 8>* = nullptr
 
#define HWY_IF_GE128(T, N)   hwy::EnableIf<N * sizeof(T) >= 16>* = nullptr
 
#define HWY_IF_GT128(T, N)   hwy::EnableIf<(N * sizeof(T) > 16)>* = nullptr
 
#define HWY_IF_UNSIGNED(T)   hwy::EnableIf<!IsSigned<T>()>* = nullptr
 
#define HWY_IF_SIGNED(T)    hwy::EnableIf<IsSigned<T>() && !IsFloat<T>()>* = nullptr
 
#define HWY_IF_FLOAT(T)   hwy::EnableIf<hwy::IsFloat<T>()>* = nullptr
 
#define HWY_IF_NOT_FLOAT(T)   hwy::EnableIf<!hwy::IsFloat<T>()>* = nullptr
 
#define HWY_IF_LANE_SIZE(T, bytes)    hwy::EnableIf<sizeof(T) == (bytes)>* = nullptr
 
#define HWY_IF_NOT_LANE_SIZE(T, bytes)    hwy::EnableIf<sizeof(T) != (bytes)>* = nullptr
 
#define HWY_IF_LANE_SIZE_ONE_OF(T, bit_array)    hwy::EnableIf<((size_t{1} << sizeof(T)) & (bit_array)) != 0>* = nullptr
 
#define HWY_IF_LANES_PER_BLOCK(T, N, LANES)    hwy::EnableIf<HWY_MIN(sizeof(T) * N, 16) / sizeof(T) == (LANES)>* = nullptr
 

Typedefs

using hwy::float32_t = float
 
using hwy::float64_t = double
 
template<bool Condition>
using hwy::EnableIf = typename EnableIfT< Condition >::type
 
template<class T >
using hwy::RemoveConst = typename RemoveConstT< T >::type
 
template<typename T >
using hwy::MakeUnsigned = typename detail::Relations< T >::Unsigned
 
template<typename T >
using hwy::MakeSigned = typename detail::Relations< T >::Signed
 
template<typename T >
using hwy::MakeFloat = typename detail::Relations< T >::Float
 
template<typename T >
using hwy::MakeWide = typename detail::Relations< T >::Wide
 
template<typename T >
using hwy::MakeNarrow = typename detail::Relations< T >::Narrow
 
template<size_t N>
using hwy::UnsignedFromSize = typename detail::TypeFromSize< N >::Unsigned
 
template<size_t N>
using hwy::SignedFromSize = typename detail::TypeFromSize< N >::Signed
 
template<size_t N>
using hwy::FloatFromSize = typename detail::TypeFromSize< N >::Float
 
using hwy::UnsignedTag = SizeTag< 0 >
 
using hwy::SignedTag = SizeTag< 0x100 >
 
using hwy::FloatTag = SizeTag< 0x200 >
 
using hwy::NonFloatTag = SizeTag< 0x400 >
 

Functions

static HWY_MAYBE_UNUSED bool hwy::operator< (const uint128_t &a, const uint128_t &b)
 
static HWY_MAYBE_UNUSED bool hwy::operator> (const uint128_t &a, const uint128_t &b)
 
static HWY_MAYBE_UNUSED bool hwy::operator== (const uint128_t &a, const uint128_t &b)
 
static HWY_MAYBE_UNUSED bool hwy::operator< (const K64V64 &a, const K64V64 &b)
 
static HWY_MAYBE_UNUSED bool hwy::operator> (const K64V64 &a, const K64V64 &b)
 
static HWY_MAYBE_UNUSED bool hwy::operator== (const K64V64 &a, const K64V64 &b)
 
static HWY_MAYBE_UNUSED bool hwy::operator< (const K32V32 &a, const K32V32 &b)
 
static HWY_MAYBE_UNUSED bool hwy::operator> (const K32V32 &a, const K32V32 &b)
 
static HWY_MAYBE_UNUSED bool hwy::operator== (const K32V32 &a, const K32V32 &b)
 
template<typename T , typename U >
HWY_API constexpr bool hwy::IsSame ()
 
template<typename T , class R = detail::Relations<T>>
constexpr auto hwy::TypeTag () -> hwy::SizeTag<((R::is_signed+R::is_float)<< 8)>
 
template<typename T , class R = detail::Relations<T>>
constexpr auto hwy::IsFloatTag () -> hwy::SizeTag<(R::is_float ? 0x200 :0x400)>
 
template<typename T >
HWY_API constexpr bool hwy::IsFloat ()
 
template<typename T >
HWY_API constexpr bool hwy::IsSigned ()
 
template<>
constexpr bool hwy::IsSigned< float16_t > ()
 
template<>
constexpr bool hwy::IsSigned< bfloat16_t > ()
 
template<typename T >
HWY_API constexpr T hwy::LimitsMax ()
 
template<typename T >
HWY_API constexpr T hwy::LimitsMin ()
 
template<typename T >
HWY_API constexpr T hwy::LowestValue ()
 
template<>
constexpr float hwy::LowestValue< float > ()
 
template<>
constexpr double hwy::LowestValue< double > ()
 
template<typename T >
HWY_API constexpr T hwy::HighestValue ()
 
template<>
constexpr float hwy::HighestValue< float > ()
 
template<>
constexpr double hwy::HighestValue< double > ()
 
template<typename T >
HWY_API constexpr T hwy::Epsilon ()
 
template<>
constexpr float hwy::Epsilon< float > ()
 
template<>
constexpr double hwy::Epsilon< double > ()
 
template<typename T >
constexpr int hwy::MantissaBits ()
 
template<>
constexpr int hwy::MantissaBits< float > ()
 
template<>
constexpr int hwy::MantissaBits< double > ()
 
template<typename T >
constexpr MakeSigned< T > hwy::MaxExponentTimes2 ()
 
template<typename T >
constexpr MakeUnsigned< T > hwy::SignMask ()
 
template<typename T >
constexpr MakeUnsigned< T > hwy::ExponentMask ()
 
template<typename T >
constexpr MakeUnsigned< T > hwy::MantissaMask ()
 
template<typename T >
constexpr T hwy::MantissaEnd ()
 
template<>
constexpr float hwy::MantissaEnd< float > ()
 
template<>
constexpr double hwy::MantissaEnd< double > ()
 
template<typename T >
constexpr int hwy::ExponentBits ()
 
template<typename T >
constexpr MakeSigned< T > hwy::MaxExponentField ()
 
template<typename T1 , typename T2 >
constexpr T1 hwy::DivCeil (T1 a, T2 b)
 
constexpr size_t hwy::RoundUpTo (size_t what, size_t align)
 
HWY_API size_t hwy::Num0BitsBelowLS1Bit_Nonzero32 (const uint32_t x)
 
HWY_API size_t hwy::Num0BitsBelowLS1Bit_Nonzero64 (const uint64_t x)
 
HWY_API size_t hwy::Num0BitsAboveMS1Bit_Nonzero32 (const uint32_t x)
 
HWY_API size_t hwy::Num0BitsAboveMS1Bit_Nonzero64 (const uint64_t x)
 
HWY_API size_t hwy::PopCount (uint64_t x)
 
template<typename TI >
constexpr size_t hwy::FloorLog2 (TI x)
 
template<typename TI >
constexpr size_t hwy::CeilLog2 (TI x)
 
template<typename T >
HWY_INLINE constexpr T hwy::AddWithWraparound (hwy::FloatTag, T t, size_t n)
 
template<typename T >
HWY_INLINE constexpr T hwy::AddWithWraparound (hwy::NonFloatTag, T t, size_t n)
 
HWY_API uint64_t hwy::Mul128 (uint64_t a, uint64_t b, uint64_t *HWY_RESTRICT upper)
 
template<size_t kBytes, typename From , typename To >
HWY_API void hwy::CopyBytes (const From *from, To *to)
 
template<typename From , typename To >
HWY_API void hwy::CopySameSize (const From *HWY_RESTRICT from, To *HWY_RESTRICT to)
 
template<size_t kBytes, typename To >
HWY_API void hwy::ZeroBytes (To *to)
 
HWY_API float hwy::F32FromBF16 (bfloat16_t bf)
 
HWY_API bfloat16_t hwy::BF16FromF32 (float f)
 
HWY_DLLEXPORT HWY_NORETURN void hwy::HWY_FORMAT (3, 4) Abort(const char *file
 

Variables

static constexpr HWY_MAYBE_UNUSED size_t hwy::kMaxVectorSize = 16
 
HWY_DLLEXPORT HWY_NORETURN void int hwy::line
 
HWY_DLLEXPORT HWY_NORETURN void int const char * hwy::format
 

Macro Definition Documentation

◆ HWY_ABORT

#define HWY_ABORT (   format,
  ... 
)     ::hwy::Abort(__FILE__, __LINE__, format, ##__VA_ARGS__)

◆ HWY_ALIGN_MAX

#define HWY_ALIGN_MAX   alignas(16)

◆ HWY_API

#define HWY_API   static HWY_INLINE HWY_FLATTEN HWY_MAYBE_UNUSED

◆ HWY_ASSERT

#define HWY_ASSERT (   condition)
Value:
do { \
if (!(condition)) { \
HWY_ABORT("Assert %s", #condition); \
} \
} while (0)

◆ HWY_ASSUME

#define HWY_ASSUME (   expr)    static_cast<void>(0)

◆ HWY_ASSUME_ALIGNED

#define HWY_ASSUME_ALIGNED (   ptr,
  align 
)    (ptr) /* not supported */

◆ HWY_ATTR_NO_MSAN

#define HWY_ATTR_NO_MSAN

◆ HWY_CONCAT

#define HWY_CONCAT (   a,
 
)    HWY_CONCAT_IMPL(a, b)

◆ HWY_CONCAT_IMPL

#define HWY_CONCAT_IMPL (   a,
 
)    a##b

◆ HWY_DASSERT

#define HWY_DASSERT (   condition)    HWY_ASSERT(condition)

◆ HWY_DEFAULT_UNROLL

#define HWY_DEFAULT_UNROLL

◆ HWY_DIAGNOSTICS

#define HWY_DIAGNOSTICS (   tokens)    HWY_PRAGMA(GCC diagnostic tokens)

◆ HWY_DIAGNOSTICS_OFF

#define HWY_DIAGNOSTICS_OFF (   msc,
  gcc 
)    HWY_DIAGNOSTICS(gcc)

◆ HWY_FENCE

#define HWY_FENCE

◆ HWY_FLATTEN

#define HWY_FLATTEN   __attribute__((flatten))

◆ HWY_FORMAT

#define HWY_FORMAT (   idx_fmt,
  idx_arg 
)

◆ HWY_IF_FLOAT

#define HWY_IF_FLOAT (   T)    hwy::EnableIf<hwy::IsFloat<T>()>* = nullptr

◆ HWY_IF_GE128

#define HWY_IF_GE128 (   T,
 
)    hwy::EnableIf<N * sizeof(T) >= 16>* = nullptr

◆ HWY_IF_GE32

#define HWY_IF_GE32 (   T,
 
)    hwy::EnableIf<N * sizeof(T) >= 4>* = nullptr

◆ HWY_IF_GE64

#define HWY_IF_GE64 (   T,
 
)    hwy::EnableIf<N * sizeof(T) >= 8>* = nullptr

◆ HWY_IF_GT128

#define HWY_IF_GT128 (   T,
 
)    hwy::EnableIf<(N * sizeof(T) > 16)>* = nullptr

◆ HWY_IF_LANE_SIZE

#define HWY_IF_LANE_SIZE (   T,
  bytes 
)     hwy::EnableIf<sizeof(T) == (bytes)>* = nullptr

◆ HWY_IF_LANE_SIZE_ONE_OF

#define HWY_IF_LANE_SIZE_ONE_OF (   T,
  bit_array 
)     hwy::EnableIf<((size_t{1} << sizeof(T)) & (bit_array)) != 0>* = nullptr

◆ HWY_IF_LANES_PER_BLOCK

#define HWY_IF_LANES_PER_BLOCK (   T,
  N,
  LANES 
)     hwy::EnableIf<HWY_MIN(sizeof(T) * N, 16) / sizeof(T) == (LANES)>* = nullptr

◆ HWY_IF_LE128

#define HWY_IF_LE128 (   T,
 
)    hwy::EnableIf<N * sizeof(T) <= 16>* = nullptr

◆ HWY_IF_LE32

#define HWY_IF_LE32 (   T,
 
)    hwy::EnableIf<N * sizeof(T) <= 4>* = nullptr

◆ HWY_IF_LE64

#define HWY_IF_LE64 (   T,
 
)    hwy::EnableIf<N * sizeof(T) <= 8>* = nullptr

◆ HWY_IF_NOT_FLOAT

#define HWY_IF_NOT_FLOAT (   T)    hwy::EnableIf<!hwy::IsFloat<T>()>* = nullptr

◆ HWY_IF_NOT_LANE_SIZE

#define HWY_IF_NOT_LANE_SIZE (   T,
  bytes 
)     hwy::EnableIf<sizeof(T) != (bytes)>* = nullptr

◆ HWY_IF_SIGNED

#define HWY_IF_SIGNED (   T)     hwy::EnableIf<IsSigned<T>() && !IsFloat<T>()>* = nullptr

◆ HWY_IF_UNSIGNED

#define HWY_IF_UNSIGNED (   T)    hwy::EnableIf<!IsSigned<T>()>* = nullptr

◆ HWY_INLINE

#define HWY_INLINE   inline

◆ HWY_IS_ASAN

#define HWY_IS_ASAN   0

◆ HWY_IS_DEBUG_BUILD

#define HWY_IS_DEBUG_BUILD   1

◆ HWY_IS_MSAN

#define HWY_IS_MSAN   0

◆ HWY_IS_TSAN

#define HWY_IS_TSAN   0

◆ HWY_LIKELY

#define HWY_LIKELY (   expr)    __builtin_expect(!!(expr), 1)

◆ HWY_MAX

#define HWY_MAX (   a,
 
)    ((a) > (b) ? (a) : (b))

◆ HWY_MAYBE_UNUSED

#define HWY_MAYBE_UNUSED   __attribute__((unused))

◆ HWY_MIN

#define HWY_MIN (   a,
 
)    ((a) < (b) ? (a) : (b))

◆ HWY_MUST_USE_RESULT

#define HWY_MUST_USE_RESULT   __attribute__((warn_unused_result))

◆ HWY_NOINLINE

#define HWY_NOINLINE   __attribute__((noinline))

◆ HWY_NORETURN

#define HWY_NORETURN   __attribute__((noreturn))

◆ HWY_POP_ATTRIBUTES

#define HWY_POP_ATTRIBUTES

◆ HWY_PRAGMA

#define HWY_PRAGMA (   tokens)    _Pragma(#tokens)

◆ HWY_PUSH_ATTRIBUTES

#define HWY_PUSH_ATTRIBUTES (   targets_str)

◆ HWY_REP4

#define HWY_REP4 (   literal)    literal, literal, literal, literal

◆ HWY_RESTRICT

#define HWY_RESTRICT   __restrict__

◆ HWY_STR

#define HWY_STR (   macro)    HWY_STR_IMPL(macro)

◆ HWY_STR_IMPL

#define HWY_STR_IMPL (   macro)    #macro

◆ HWY_UNLIKELY

#define HWY_UNLIKELY (   expr)    __builtin_expect(!!(expr), 0)

◆ HWY_UNROLL

#define HWY_UNROLL (   factor)