-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfk20test_fft_rand.cu
82 lines (65 loc) · 2.73 KB
/
fk20test_fft_rand.cu
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
79
80
81
82
// bls12_381: Arithmetic for BLS12-381
// Copyright 2022-2023 Dag Arne Osvik
// Copyright 2022-2023 Luan Cardoso dos Santos
#warning "Functionality of this file has been replaced by fk20_512."
#include <stdio.h>
#include <unistd.h>
#include "g1.cuh"
#include "fk20test.cuh"
#include "fk20.cuh"
//static __managed__ uint8_t cmp[16*512];
//static __managed__ fr_t fr_tmp[16*512];
//static __managed__ g1p_t g1p_tmp[512];
//Global correct answers, read from the instrumented fk20 python implementation
static __managed__ size_t elementsRead;
static __managed__ fr_t polynomial[4096];
static __managed__ g1p_t setup[4097];
static __managed__ g1p_t xext_fft[16][512];
static __managed__ fr_t toeplitz_coefficients[16][512];
static __managed__ fr_t toeplitz_coefficients_fft[16][512];
static __managed__ g1p_t hext_fft[512];
static __managed__ g1p_t h[512];
static __managed__ g1p_t h_fft[512];
#define readAndCheck(var) do{ \
elementsRead = fread(var, 1, sizeof(var), inputStream); \
if(elementsRead != sizeof(var)){ \
printf("NONFATAL: Unbale to read test vectors, aborting\n"); \
return; \
} else { \
printf(" Read in " #var " %ld Bytes\n", elementsRead); \
} \
}while(0)
void FK20TestFFTRand(FILE *inputStream) {
/*
* Reads from inputStream values generated by the python implementation, and test against those.
* if the inputstream is NULL, then read from stdin
*/
if (inputStream == NULL){
inputStream = stdin;
}
if (isatty(fileno(inputStream)))
return;
printf(">>>> Rand Tests\n");
readAndCheck(polynomial);
readAndCheck(setup);
readAndCheck(xext_fft);
readAndCheck(toeplitz_coefficients);
readAndCheck(toeplitz_coefficients_fft);
readAndCheck(hext_fft);
readAndCheck(h);
readAndCheck(h_fft);
toeplitz_coefficients2toeplitz_coefficients_fft(toeplitz_coefficients, toeplitz_coefficients_fft);
h2h_fft(h, h_fft);
h_fft2h(h_fft, h);
hext_fft2h(hext_fft, h);
hext_fft2h_fft(hext_fft, h_fft);
fk20_poly2toeplitz_coefficients_test(polynomial, toeplitz_coefficients);
fk20_poly2hext_fft_test(polynomial, xext_fft, hext_fft);
fk20_msmloop(hext_fft, toeplitz_coefficients_fft, xext_fft);
fk20_poly2h_fft_test(polynomial, xext_fft, h_fft);
//Null the pointer if we used STDIN
if (inputStream == stdin){
inputStream = NULL;
}
}
// vim: ts=4 et sw=4 si