FK20 CUDA
fk20_msm.cu
Go to the documentation of this file.
1 // bls12_381: Arithmetic for BLS12-381
2 // Copyright 2022-2023 Dag Arne Osvik
3 // Copyright 2022-2023 Luan Cardoso dos Santos
4 
5 #include "fr.cuh"
6 #include "g1.cuh"
7 #include "fk20.cuh"
8 
20 __global__ void fk20_msm(g1p_t *he_fft, const fr_t *tc_fft, const g1p_t *xe_fft) {
21  if (gridDim.y != 1) return;
22  if (gridDim.z != 1) return;
23  if (blockDim.x != 256) return; // k
24  if (blockDim.y != 1) return;
25  if (blockDim.z != 1) return;
26 
27  unsigned tid = threadIdx.x; // Thread number
28  unsigned bid = blockIdx.x; // Block number
29 
30  g1p_t a0, a1, t;
31 
32  g1p_inf(a0);
33  g1p_inf(a1);
34 
35  // Move pointer for blocks
36  he_fft += 512*bid;
37  tc_fft += 16*512*bid;
38 
39  // MSM Loop
40  for (int i=0; i<16; i++) {
41 
42  // Multiply and accumulate
43 
44  g1p_cpy(t, xe_fft[512*i+tid+0]);
45  g1p_mul(t, tc_fft[512*i+tid+0]);
46  g1p_add(a0, t);
47 
48  g1p_cpy(t, xe_fft[512*i+tid+256]);
49  g1p_mul(t, tc_fft[512*i+tid+256]);
50  g1p_add(a1, t);
51  }
52 
53  // hext_fft = a0||a1
54  // Store accumulators
55  g1p_cpy(he_fft[tid+ 0], a0);
56  g1p_cpy(he_fft[tid+256], a1);
57 }
58 
59 // vim: ts=4 et sw=4 si
__global__ void fk20_msm(g1p_t *he_fft, const fr_t *tc_fft, const g1p_t *xe_fft)
toeplitz_coefficients_fft + xext_fft -> hext_fft
Definition: fk20_msm.cu:20
uint64_t fr_t[4]
Subgroup element stored as a 256-bit array (a 4-element little-endian array of uint64_t)....
Definition: fr.cuh:24
__device__ __host__ void g1p_inf(g1p_t &p)
Set p to the point-at-infinity (0,1,0)
Definition: g1p.cu:93
__device__ void g1p_add(g1p_t &p, const g1p_t &q)
Computes the sum of two points q into p, using projective coordinates. and stores in p.
Definition: g1p_add.cu:29
__device__ void g1p_mul(g1p_t &p, const fr_t &x)
p ← k·p Point multiplication by scalar, in projective coordinates. That result is stored back into p.
Definition: g1p_mul.cu:19
__device__ __host__ void g1p_cpy(g1p_t &p, const g1p_t &q)
Copy from q into p.
Definition: g1p.cu:67
G1 point in projective coordinates.
Definition: g1.cuh:27