7#ifndef _MINISKETCH_FIELDS_CLMUL_COMMON_IMPL_H_
8#define _MINISKETCH_FIELDS_CLMUL_COMMON_IMPL_H_ 1
20#if defined(__clang__) && (__clang_major__ < 11)
21# if defined(__has_feature)
22# if __has_feature(memory_sanitizer)
23# define NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
27#ifndef NO_SANITIZE_MEMORY
28# define NO_SANITIZE_MEMORY
43 }
else if (BITS == 64) {
47 }
else if ((BITS % 8) == 0) {
85 if (BITS +
POS <= 66) {
89 }
else if (BITS +
POS <= 66) {
105template<
typename I,
int B, I MOD, I (*MUL)(I, I),
typename F, const F* SQR, const F* SQR2, const F* SQR4, const F* SQR8, const F* SQR16, const F* QRT,
typename T, const T* LOAD, const T* SAVE>
struct GenField
110 static inline constexpr I
Sqr1(I
a) {
return SQR->template
Map<O>(
a); }
119 inline constexpr int Bits()
const {
return B; }
121 inline constexpr Elem
Mul2(Elem val)
const {
return L::Call(val); }
123 inline Elem Mul(Elem
a, Elem b)
const {
return MUL(
a, b); }
129 inline constexpr explicit Multiplier(
const GenField&, Elem
a) : m_val(
a) {}
130 constexpr Elem operator()(Elem
a)
const {
return MUL(m_val,
a); }
134 inline constexpr Elem
Sqr(Elem val)
const {
return SQR->template
Map<O>(val); }
137 inline constexpr Elem
Qrt(Elem val)
const {
return QRT->template
Map<O>(val); }
162template<
typename I,
int B, I MOD,
typename F, const F* SQR, const F* SQR2, const F* SQR4, const F* SQR8, const F* SQR16, const F* QRT,
typename T, const T* LOAD, const T* SAVE>
163using Field = GenField<I, B, MOD, MulWithClMulReduce<I, B, MOD>,
F,
SQR,
SQR2,
SQR4,
SQR8,
SQR16,
QRT,
T,
LOAD,
SAVE>;
165template<
typename I,
int B,
int POS,
typename F, const F* SQR, const F* SQR2, const F* SQR4, const F* SQR8, const F* SQR16, const F* QRT,
typename T, const T* LOAD, const T* SAVE>
166using FieldTri = GenField<I,
B, I(1) + (I(1) <<
POS),
MulTrinomial<I, B, POS>,
F,
SQR,
SQR2,
SQR4,
SQR8,
SQR16,
QRT,
T,
LOAD,
SAVE>;
static constexpr I Mask(I val)
#define NO_SANITIZE_MEMORY
#define T(expected, seed, data)
uint64_t SipHash(uint64_t k0, uint64_t k1, uint64_t data)
void Serialize(Stream &, V)=delete
void Sqr(std::vector< typename F::Elem > &poly, const F &field)
Square a polynomial.
Class which implements a stateless LFSR for generic moduli.
static constexpr I Call(const I &a)
Shift a value a up once, treating it as an N-bit LFSR, with pattern MOD.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.