一呼百應, "one call, a hundred responses"
Loading...
Searching...
No Matches
ein Namespace Reference

Namespaces

namespace  detail
 
namespace  profiling
 

Classes

class  basic_static_string
 statically known interned strings these have O(1) comparison for equality More...
 
struct  bf16
 
struct  c_free
 std::unique_ptr Deleter that calls free() More...
 
struct  c_munmap
 std::unique_ptr Deleter for memory mapped data More...
 
struct  cpuid_t
 result from calling the CPUID instruction More...
 
struct  fp16
 
struct  imm_t
 A compile time constant passed as an empty struct. More...
 
struct  mwaitx
 waiter using MONITORX/MWAITX for AMD More...
 
struct  reify
 
struct  simd
 simd primitive definition More...
 
struct  spin
 spin waiter using PAUSE More...
 
class  static_c_string
 
struct  umwait
 waiter using UMONITOR/UMWAIT for Intel More...
 

Concepts

concept  trivially_destructible
 a type where the destructor does no work, and therefore it is safe to simply discard.
 
concept  one_of
 N is one of the candidates
 
concept  not_one_of
 N is not one of the candidates
 
concept  simd_type
 recognizes any valid simd type
 
concept  has_storage_type
 
concept  has_lifted_operations
 Does this type have operations that semantically correct when lifted to the simd_data_t level?
 
concept  has_simd_type
 ein::simd_data_t<T,N> is defined
 
concept  has_builtin_convertvector
 can we convert simd_data_t<U,N> -> simd_data_t<T,N> automatically using gcc vector extensions?
 
concept  simd_builtin
 is this type one of the types that is handed well automatically by clang/gcc vector extensions?
 
concept  has_mmask
 Do we want to use AVX512's notion of an _mmask8, _mmask16, _mmask32, or _mmask64 for masking operations.
 
concept  one_of_t
 type T is one of the candidates
 
concept  not_one_of_t
 type T is not one of the candidates
 
concept  waiter
 some way to wait for a value to change
 

Typedefs

using mmap_ptr = std::unique_ptr<void,c_munmap>
 memory mapped data, managed by std::unique_ptr. calls munmap to free.
 
template<trivially_destructible T>
using unique_c_ptr = std::unique_ptr<T, c_free>
 a unique_ptr managed c pointer, deleted by free()
 
using unique_str = unique_c_ptr<char const>
 a c string, managed by unique_ptr
 
template<typename T >
using int_t
 returns a signed integer type of the same size as T suitable for std::bitcast
 
template<typename T >
using uint_t
 returns an unsigned integer type of the same size as T suitable for std::bitcast
 
template<typename T >
using storage_type
 The type used to store T in a simd_data_t.
 
template<typename T , size_t N>
using simd_data_t = storage_type<T> __attribute__((__vector_size__(N*sizeof(storage_type<T>)),__aligned__(N*sizeof(storage_type<T>))))
 
template<typename T , size_t N>
using simd_intrinsic_t
 Returns the Intel intrinsic type associated with a simd register full of N values of type T.
 
template<size_t N>
using mmask_t
 If AVX512 is enabled returns the type of an n-bit mmask.
 
template<typename T , size_t N>
using simd_mask_t
 What type of mask should I use?
 
using static_string = basic_static_string<char>
 
using static_wstring = basic_static_string<wchar_t>
 
using static_u8string = basic_static_string<char8_t>
 
using static_u16string = basic_static_string<char16_t>
 
using static_u32string = basic_static_string<char32_t>
 

Enumerations

enum class  cpu_vendor : uint8_t {
  intel =0 ,
  amd =1 ,
  unknown =2
}
 CPU vendor id. More...
 
enum class  CMPINT : size_t {
  CMPINT::EQ = 0x0uz ,
  CMPINT::LT = 0x1uz ,
  CMPINT::LE = 0x2uz ,
  CMPINT::FALSE = 0x3uz ,
  CMPINT::NE = 0x4uz ,
  CMPINT::NLT = 0x5uz ,
  CMPINT::NLE = 0x6uz ,
  CMPINT::TRUE = 0x7uz
}
 
enum class  CMP : size_t {
  CMP::EQ_OQ = 0x00uz ,
  CMP::LT_OS = 0x01uz ,
  CMP::LE_OS = 0x02uz ,
  CMP::UNORD_Q = 0x03uz ,
  CMP::NEQ_UQ = 0x04uz ,
  CMP::NLT_US = 0x05uz ,
  CMP::NLE_US = 0x06uz ,
  CMP::ORD_Q = 0x07uz ,
  CMP::EQ_UQ = 0x08uz ,
  CMP::NGE_US = 0x09uz ,
  CMP::NGT_US = 0x0Auz ,
  CMP::FALSE_OQ = 0x0Buz ,
  CMP::NEQ_OQ = 0x0Cuz ,
  CMP::GE_OS = 0x0Duz ,
  CMP::GT_OS = 0x0Euz ,
  CMP::TRUE_UQ = 0x0Fuz ,
  CMP::EQ_OS = 0x10uz ,
  CMP::LT_OQ = 0x11uz ,
  CMP::LE_OQ = 0x12uz ,
  CMP::UNORD_S = 0x13uz ,
  CMP::NEQ_US = 0x14uz ,
  CMP::NLT_UQ = 0x15uz ,
  CMP::NLE_UQ = 0x16uz ,
  CMP::ORD_S = 0x17uz ,
  CMP::EQ_US = 0x18uz ,
  CMP::NGE_UQ = 0x19uz ,
  CMP::NGT_UQ = 0x1Auz ,
  CMP::FALSE_OS = 0x1Buz ,
  CMP::NEQ_OS = 0x1Cuz ,
  CMP::GE_OQ = 0x1Duz ,
  CMP::GT_OQ = 0x1Euz ,
  CMP::TRUE_US = 0x1Fuz
}
 

Functions

cpuid_t cpuid (int32_t eax, int32_t ecx) noexcept
 calls CPUID and returns all of the registers that it responds with.
 
mmap_ptr make_mmap_ptr (void *p, size_t size) noexcept
 construct a mmap_ptr using a base pointer and its size for munmap
 
unique_str dup (char const *str) noexcept
 duplicate a C string using strdup and manage it as a unique_str
 
template bool cmp_unord (float, float) noexcept
 
template bool cmp_unord (double, double) noexcept
 
template bool cmp_ord (float, float) noexcept
 
template bool cmp_ord (double, double) noexcept
 
X template float scalef (float, float) noexcept
 cond xmacro
 
X template double scalef (double, double) noexcept
 
template<typename T >
constexpr bool cmp_unord (T a, T b) noexcept
 Return true if either argument is NaN.
 
template<typename T >
constexpr bool cmp_ord (T a, T b) noexcept
 Return true if neither argument is NaN.
 
template<one_of_t< float, double > T>
constexpr T scalef (T x, T y) noexcept
 
template<CMPINT imm8, typename T >
requires (one_of_t<T,uint8_t,int8_t,uint16_t,int16_t,uint32_t,int32_t,uint64_t,int64_t> && (size_t(imm8) < 8uz))
constexpr bool cmpint (T a, T b) noexcept
 
template<CMP imm8, typename T >
requires (one_of_t<T,float,double> && (size_t(imm8) < 32uz))
constexpr bool cmp (T a, T b) noexcept
 perform an avx512 style floating point comparison for scalar values.
 
constexpr bf16 operator""_bf16 (long double v) noexcept
 
constexpr bf16 fast_to_bf16 (float f) noexcept
 
constexpr bf16 fast_to_bf16 (bf16 f) noexcept
 
constexpr fp16 operator""_fp16 (long double v) noexcept
 
__m128 cast_ps (__m128i a) noexcept
 
__m128 cast_ps (__m128 a) noexcept
 
__m256 cast_ps (__m256i a) noexcept
 
__m256 cast_ps (__m256 a) noexcept
 
__m128d cast_pd (__m128i a) noexcept
 
__m128d cast_pd (__m128d a) noexcept
 
__m256d cast_pd (__m256i a) noexcept
 
__m256d cast_pd (__m256d a) noexcept
 
__m128i cast_si (__m128 a) noexcept
 
__m128i cast_si (__m128d a) noexcept
 
__m128i cast_si (__m128i a) noexcept
 
__m256i cast_si (__m256 a) noexcept
 
__m256i cast_si (__m256d a) noexcept
 
__m256i cast_si (__m256i a) noexcept
 
__m512 cast_ps (__m512i a) noexcept
 
__m512d cast_pd (__m512i a) noexcept
 
__m512 cast_ps (__m512 a) noexcept
 
__m512d cast_pd (__m512d a) noexcept
 
__m512i cast_si (__m512 a) noexcept
 
__m512i cast_si (__m512d a) noexcept
 
__m512i cast_si (__m512i a) noexcept
 
template<typename CharT , typename Traits >
void to_json (nlohmann::json &j, const basic_static_string< CharT, Traits > &s)
 
template<class T , T ... xs>
consteval basic_static_string< T, std::char_traits< T > > operator""_ss () noexcept
 
template<one_of_t< char > T, T ... xs>
consteval static_c_string operator""_scs () noexcept
 
void to_json (nlohmann::json &j, static_c_string const &s)
 
const string_view type_of (auto const &t) noexcept
 returns the unmangled name of a the type of the (unused) argument passed to this function
 
template<waiter W>
ein_flatten void wait_until (volatile auto *p, auto f) noexcept ein_blocking
 Wait until a predicate holds about a given memory location.
 
auto with_waiter (auto k) noexcept
 finds an appropriate waiter for the current CPU
 
argument deduction
template<typename T , size_t N>
requires ( has_simd_type<T,N> && (N % sizeof(T) == 0) )
 simd (T __attribute((__vector_size__(N)))) -> simd< T, N/sizeof(T)>
 guidance when loading data from clang/gcc vector extensions
 
template<typename ... Args>
requires has_simd_type<std::common_type<Args...>, sizeof...(Args)>
 simd (Args &&...) -> simd< std::common_type< Args... >, sizeof...(Args)>
 guidance for loading from arguments
 
template<typename T >
requires has_simd_type<T,max_simd_size/sizeof(T)>
 simd (T) -> simd< T, has_simd_type< T, max_simd_size/sizeof(T)> >
 default to max simd size for broadcast
 
shuffles
template<size_t ... is>
auto shuffle (simd_type auto x)
 create a new simd register with contents drawn from this one
 
template<size_t ... is>
auto shuffle (simd_type auto x, simd_type auto y)
 create a new simd register with contents drawn from these two
 

Variables

enum cpu_vendor cpu_vendor
 Reports the vendor of the CPU encountered at runtime. Cached.
 
template<size_t N>
constinit imm_t< N > imm {}
 A compile time constant passed as an empty struct.
 
constexpr size_t max_fp_comparison_predicate
 AVX512 added many more floating point comparison types. Do we have them?
 
constexpr size_t max_simd_size = 64
 largest simd register width supported on this platform in bytes
 
template<typename T >
const string_view type
 returns the unmangled name of a the type T
 

Class Documentation

◆ ein::cpuid_t

struct ein::cpuid_t

result from calling the CPUID instruction

Definition at line 19 of file cpuid.hpp.

Class Members
int32_t eax
int32_t ebx
int32_t ecx
int32_t edx

Typedef Documentation

◆ mmap_ptr

using ein::mmap_ptr = std::unique_ptr<void,c_munmap>

memory mapped data, managed by std::unique_ptr. calls munmap to free.

Definition at line 39 of file memory.hpp.

◆ static_string

Definition at line 247 of file static_string.hpp.

◆ static_u16string

Definition at line 250 of file static_string.hpp.

◆ static_u32string

Definition at line 251 of file static_string.hpp.

◆ static_u8string

Definition at line 249 of file static_string.hpp.

◆ static_wstring

Definition at line 248 of file static_string.hpp.

◆ unique_c_ptr

template<trivially_destructible T>
using ein::unique_c_ptr = std::unique_ptr<T, c_free>

a unique_ptr managed c pointer, deleted by free()

Definition at line 61 of file memory.hpp.

◆ unique_str

using ein::unique_str = unique_c_ptr<char const>

a c string, managed by unique_ptr

Definition at line 66 of file memory.hpp.

Enumeration Type Documentation

◆ cpu_vendor

enum class enum cpu_vendor ein::cpu_vendor
strong

CPU vendor id.

Reports the vendor of the CPU encountered at runtime. Cached.

Enumerator
intel 

CPUID reported "GenuineIntel"

amd 

CPUID reported "AuthenticAMD"

unknown 

CPUID reported something else

Definition at line 34 of file cpuid.hpp.

34 : uint8_t {
35 intel=0,
36 amd=1,
37 unknown=2
38};
@ intel
CPUID reported "GenuineIntel"
@ amd
CPUID reported "AuthenticAMD"
@ unknown
CPUID reported something else

Function Documentation

◆ cmp_ord() [1/2]

template bool ein::cmp_ord ( double ,
double  )
noexcept

◆ cmp_ord() [2/2]

template bool ein::cmp_ord ( float ,
float  )
noexcept

Referenced by cmp().

Here is the caller graph for this function:

◆ cmp_unord() [1/2]

template bool ein::cmp_unord ( double ,
double  )
noexcept

◆ cmp_unord() [2/2]

template bool ein::cmp_unord ( float ,
float  )
noexcept

Referenced by cmp().

Here is the caller graph for this function:

◆ cpuid()

cpuid_t ein::cpuid ( int32_t eax,
int32_t ecx )
noexcept[[pure]]

calls CPUID and returns all of the registers that it responds with.

this can take a 100+ cycles and stalls everything waiting for writes, so please, do this outside of the critical path.

Definition at line 19 of file cpuid.cpp.

References ein::cpuid_t::eax, ein::cpuid_t::ebx, ein::cpuid_t::ecx, and ein::cpuid_t::edx.

◆ dup()

unique_str ein::dup ( char const * str)
noexcept[[nodiscard]][[always_inline]][[artificial]][[pure]][[nonnull( 1 )]][[noescape]]

duplicate a C string using strdup and manage it as a unique_str

Precondition
string is non-null
Postcondition
result is a null-terminated c string to be cleaned up by free

Definition at line 74 of file memory.hpp.

◆ fast_to_bf16() [1/2]

bf16 ein::fast_to_bf16 ( bf16 f)
constexprnoexcept[[nodiscard]][[always_inline]][[artificial]][[const]]

Definition at line 123 of file bf16.hpp.

123 {
124 return f;
125}

◆ fast_to_bf16() [2/2]

bf16 ein::fast_to_bf16 ( float f)
constexprnoexcept[[nodiscard]][[always_inline]][[artificial]][[const]]

Definition at line 114 of file bf16.hpp.

114 {
115 if consteval {
116 return f;
117 } else {
118 return std::bit_cast<bf16>(static_cast<uint16_t>(std::bit_cast<uint32_t>(f)>>16));
119 }
120}

◆ make_mmap_ptr()

mmap_ptr ein::make_mmap_ptr ( void * p,
size_t size )
noexcept[[always_inline]][[artificial]][[nonnull( 1 )]]

construct a mmap_ptr using a base pointer and its size for munmap

Precondition
p is non-null

Definition at line 45 of file memory.hpp.

◆ operator""_bf16()

bf16 ein::operator""_bf16 ( long double v)
constexprnoexcept[[nodiscard]][[always_inline]][[artificial]]

Definition at line 109 of file bf16.hpp.

109 {
110 return bf16(static_cast<float>(v));
111}

◆ operator""_fp16()

fp16 ein::operator""_fp16 ( long double v)
constexprnoexcept[[nodiscard]][[always_inline]][[artificial]][[const]]

Definition at line 109 of file fp16.hpp.

109 {
110 return fp16(static_cast<float>(v));
111}

◆ operator""_scs()

template<one_of_t< char > T, T ... xs>
static_c_string ein::operator""_scs ( )
constevalnoexcept

Definition at line 381 of file static_string.hpp.

381 {
382 return static_c_string(basic_static_string<T,std::char_traits<T>>(std::integer_sequence<T,xs...>{}));
383}
statically known interned strings these have O(1) comparison for equality

◆ operator""_ss()

template<class T , T ... xs>
basic_static_string< T, std::char_traits< T > > ein::operator""_ss ( )
constevalnoexcept

Definition at line 376 of file static_string.hpp.

376 {
377 return basic_static_string<T,std::char_traits<T>>(std::integer_sequence<T,xs...>{});
378}

◆ scalef() [1/2]

X template double ein::scalef ( double ,
double  )
noexcept

◆ scalef() [2/2]

X template float ein::scalef ( float ,
float  )
noexcept

cond xmacro

◆ to_json() [1/2]

template<typename CharT , typename Traits >
void ein::to_json ( nlohmann::json & j,
const basic_static_string< CharT, Traits > & s )

Definition at line 233 of file static_string.hpp.

233 {
234 j = std::string(s);
235}

◆ to_json() [2/2]

void ein::to_json ( nlohmann::json & j,
static_c_string const & s )
inline

Definition at line 389 of file static_string.hpp.

389 {
390 j = std::string(s);
391}

Variable Documentation

◆ cpu_vendor

Reports the vendor of the CPU encountered at runtime. Cached.

Definition at line 26 of file cpuid.cpp.