-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfp_x12.cuh
78 lines (63 loc) · 1.78 KB
/
fp_x12.cuh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// bls12_381: Arithmetic for BLS12-381
// Copyright 2022-2023 Dag Arne Osvik
// Copyright 2022-2023 Luan Cardoso dos Santos
#ifndef FP_X12
#include "ptx.cuh"
#include "fp_reduce7.cuh"
__forceinline__
__device__ void fp_x12(
uint64_t &z0, uint64_t &z1, uint64_t &z2, uint64_t &z3, uint64_t &z4, uint64_t &z5, uint64_t &z6,
uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4, uint64_t x5
)
{
uint64_t t0, t1, t2, t3, t4, t5, t6;
// t = x + x
add_cc_u64 (t0, x0, x0);
addc_cc_u64(t1, x1, x1);
addc_cc_u64(t2, x2, x2);
addc_cc_u64(t3, x3, x3);
addc_cc_u64(t4, x4, x4);
addc_cc_u64(t5, x5, x5);
addc_cc_u64(t6, 0, 0);
// t = t + x
add_cc_u64 (t0, t0, x0);
addc_cc_u64(t1, t1, x1);
addc_cc_u64(t2, t2, x2);
addc_cc_u64(t3, t3, x3);
addc_cc_u64(t4, t4, x4);
addc_cc_u64(t5, t5, x5);
addc_cc_u64(t6, t6, 0);
// t = t + t
add_cc_u64 (t0, t0, t0);
addc_cc_u64(t1, t1, t1);
addc_cc_u64(t2, t2, t2);
addc_cc_u64(t3, t3, t3);
addc_cc_u64(t4, t4, t4);
addc_cc_u64(t5, t5, t5);
addc_cc_u64(t6, t6, t6);
// z = t + t
add_cc_u64 (z0, t0, t0);
addc_cc_u64(z1, t1, t1);
addc_cc_u64(z2, t2, t2);
addc_cc_u64(z3, t3, t3);
addc_cc_u64(z4, t4, t4);
addc_cc_u64(z5, t5, t5);
addc_cc_u64(z6, t6, t6);
}
__forceinline__
__device__ void fp_x12(
uint64_t &z0, uint64_t &z1, uint64_t &z2, uint64_t &z3, uint64_t &z4, uint64_t &z5,
uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4, uint64_t x5)
{
uint64_t t0, t1, t2, t3, t4, t5, t6;
fp_x12(
t0, t1, t2, t3, t4, t5, t6,
x0, x1, x2, x3, x4, x5
);
fp_reduce7(
z0, z1, z2, z3, z4, z5,
t0, t1, t2, t3, t4, t5, t6
);
}
#endif
// vim: ts=4 et sw=4 si