7#ifndef _MINISKETCH_FIELDS_CLMUL_COMMON_IMPL_H_
8#define _MINISKETCH_FIELDS_CLMUL_COMMON_IMPL_H_ 1
13#include "../int_utils.h"
14#include "../lintrans.h"
21#if defined(__clang__) && (__clang_major__ < 11)
22# if defined(__has_feature)
23# if __has_feature(memory_sanitizer)
24# define NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
28#ifndef NO_SANITIZE_MEMORY
29# define NO_SANITIZE_MEMORY
44 }
else if (BITS == 64) {
48 }
else if ((BITS % 8) == 0) {
86 if (BITS +
POS <= 66) {
90 }
else if (BITS +
POS <= 66) {
106template<
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
111 static inline constexpr I
Sqr1(I
a) {
return SQR->template
Map<O>(
a); }
120 inline constexpr int Bits()
const {
return B; }
122 inline constexpr Elem
Mul2(Elem val)
const {
return L::Call(val); }
124 inline Elem Mul(Elem
a, Elem b)
const {
return MUL(
a, b); }
130 inline constexpr explicit Multiplier(
const GenField&, Elem
a) : m_val(
a) {}
131 constexpr Elem operator()(Elem
a)
const {
return MUL(m_val,
a); }
135 inline constexpr Elem
Sqr(Elem val)
const {
return SQR->template
Map<O>(val); }
138 inline constexpr Elem
Qrt(Elem val)
const {
return QRT->template
Map<O>(val); }
163template<
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>
164using Field =
GenField<I, B, MOD, MulWithClMulReduce<I, B, MOD>,
F,
SQR,
SQR2,
SQR4,
SQR8,
SQR16,
QRT,
T,
LOAD,
SAVE>;
166template<
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>
167using 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.