Host Functions#
The following utilities are intended to be called from host code when preparing cuPQC-NTT kernel launches.
Returns the number of bytes of shared memory required for a single-stage NTT with
Nleaves and element typePrecision.- Template Parameters:
N – Transform size (number of coefficients); must match the NTT descriptor
Size<N>.Precision – Field element type stored in the coefficient buffer.
Returns the number of bytes of shared memory required for the forward NTT first stage, with
K = N/Melements per block.- Template Parameters:
N – Total transform size.
M – Sub-block size used with
SubSize<M>()in the descriptor;K = N/Mcoefficients per block in this pass.Precision – Field element type.
Returns the number of bytes of shared memory required for the forward NTT second stage, with
Melements per block.- Template Parameters:
N – Total transform size.
M – Sub-block size; this pass uses
Mstrided coefficients per block.Precision – Field element type.
Returns the number of bytes of shared memory required for the inverse NTT first stage, with
Melements per block.- Template Parameters:
N – Total transform size.
M – Sub-block size; this pass uses
Mstrided coefficients per block.Precision – Field element type.
Returns the number of bytes of shared memory required for the inverse NTT second stage, with
K = N/Melements per block.- Template Parameters:
N – Total transform size.
M – Sub-block size;
K = N/Mconsecutive coefficients per block in this pass.Precision – Field element type.
-
template<uint32_t N, typename Precision>
Precision n_inv(Precision p)# Computes
N-1 modpusing Fermat’s little theorem. You can call this function to compute the normalisation factorN_inv, and then pass the return value as theN_invargument toexecute()(inverse) andstage_2_execute()(inverse). Note this function is supported foruint16_tanduint32_tonly.- Template Parameters:
N – Transform size whose modular inverse is required (the same
Nas the NTT).Precision – Unsigned integer type for
pand the return value; must beuint16_toruint32_t.
- Parameters:
p – Odd prime modulus
pwithgcd(N, p) = 1soN-1 modpexists.