forked from iden3/ffiasm-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasksfile.js
172 lines (156 loc) · 5.04 KB
/
tasksfile.js
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
const { sh, cli } = require("tasksfile");
function cleanAll() {
sh("rm -rf build");
}
function downloadGoogleTest() {
sh("mkdir -p build");
sh("wget https://github.com/google/googletest/archive/release-1.10.0.tar.gz", {cwd: "build"});
sh("tar xzf release-1.10.0.tar.gz", {cwd: "build"});
sh("rm release-1.10.0.tar.gz", {cwd: "build"});
}
function compileGoogleTest() {
sh("g++ -Igoogletest -Igoogletest/include -c googletest/src/gtest-all.cc", {cwd: "build/googletest-release-1.10.0"});
sh("ar -rv libgtest.a gtest-all.o",{cwd: "build/googletest-release-1.10.0"});
}
function createFieldSources() {
sh("node ../src/buildzqfield.js -q 21888242871839275222246405745257275088696311157297823662689037894645226208583 -n Fq", {cwd: "build"});
sh("node ../src/buildzqfield.js -q 21888242871839275222246405745257275088548364400416034343698204186575808495617 -n Fr", {cwd: "build"});
if (process.platform === "darwin") {
sh("nasm -fmacho64 --prefix _ fq.asm", {cwd: "build"});
} else if (process.platform === "linux") {
sh("nasm -felf64 fq.asm", {cwd: "build"});
} else throw("Unsupported platform");
if (process.platform === "darwin") {
sh("nasm -fmacho64 --prefix _ fr.asm", {cwd: "build"});
} else if (process.platform === "linux") {
sh("nasm -felf64 fr.asm", {cwd: "build"});
} else throw("Unsupported platform");
}
function testSplitParStr() {
sh("g++" +
" -Igoogletest-release-1.10.0/googletest/include"+
" -I."+
" -I../src"+
" ../c/splitparstr.cpp"+
" ../c/splitparstr_test.cpp"+
" googletest-release-1.10.0/libgtest.a"+
" -pthread -std=c++11 -o splitparsestr_test", {cwd: "build", nopipe: true}
);
sh("./splitparsestr_test", {cwd: "build", nopipe: true});
}
function testAltBn128() {
sh("g++" +
" -Igoogletest-release-1.10.0/googletest/include"+
" -I."+
" -I../c"+
" ../c/naf.cpp"+
" ../c/splitparstr.cpp"+
" ../c/alt_bn128.cpp"+
" ../c/alt_bn128_test.cpp"+
" ../c/misc.cpp"+
" fq.cpp"+
" fq.o"+
" fr.cpp"+
" fr.o"+
" googletest-release-1.10.0/libgtest.a"+
" -o altbn128_test" +
" -fmax-errors=5 -pthread -std=c++11 -fopenmp -lgmp -g", {cwd: "build", nopipe: true}
);
sh("./altbn128_test", {cwd: "build", nopipe: true});
}
function buildCurveAdds() {
sh("g++ -O3 -g" +
" -Igoogletest-release-1.10.0/googletest/include"+
" -I."+
" -I../c"+
" ../c/naf.cpp"+
" ../c/splitparstr.cpp"+
" ../c/alt_bn128.cpp"+
" ../c/misc.cpp"+
" ../benchmark/curve_adds.cpp"+
" fq.cpp"+
" fq.o"+
" fr.cpp"+
" fr.o"+
// " googletest-release-1.10.0/libgtest.a"+
" -o curve_adds" +
" -O3 -lgmp -pthread -std=c++11 -fopenmp" , {cwd: "build", nopipe: true}
);
}
function benchCurveAdds() {
buildCurveAdds();
sh("./curve_adds", {cwd: "build", nopipe: true});
}
function buildBatchAccumulators() {
sh("g++" +
" -Igoogletest-release-1.10.0/googletest/include"+
" -I."+
" -I../c"+
" ../c/batch_accumulators_test.cpp"+
" ../c/misc.cpp"+
" fq.cpp"+
" fq.o"+
" fr.cpp"+
" fr.o"+
" googletest-release-1.10.0/libgtest.a"+
" -o batch_accumulators_test" +
" -fmax-errors=5 -pthread -std=c++11 -fopenmp -lgmp -g", {cwd: "build", nopipe: true}
);
}
function testBatchAccumulators() {
buildBatchAccumulators();
sh("./batch_accumulators_test -v", {cwd: "build", nopipe: true});
}
function benchMultiExpG1() {
sh("g++ -O3" +
" -I."+
" -I../c"+
" ../c/naf.cpp"+
" ../c/splitparstr.cpp"+
" ../c/alt_bn128.cpp"+
" ../c/misc.cpp"+
" ../benchmark/multiexp_g1.cpp"+
" fq.cpp"+
" fq.o"+
" fr.cpp"+
" fr.o"+
// " googletest-release-1.10.0/libgtest.a"+
" -o multiexp_g1_benchmark" +
" -lgmp -pthread -std=c++17 -fopenmp -DCOUNT_OPS" , {cwd: "build", nopipe: true}
);
sh("./multiexp_g1_benchmark 1000000", {cwd: "build", nopipe: true});
}
function benchMultiExpG2() {
sh("g++" +
" -Igoogletest-release-1.10.0/googletest/include"+
" -I."+
" -I../c"+
" ../c/naf.cpp"+
" ../c/splitparstr.cpp"+
" ../c/alt_bn128.cpp"+
" ../c/misc.cpp"+
" ../benchmark/multiexp_g2.cpp"+
" fq.cpp"+
" fq.o"+
" fr.cpp"+
" fr.o"+
// " googletest-release-1.10.0/libgtest.a"+
" -o multiexp_g2_benchmark" +
" -lgmp -pthread -std=c++11 -fopenmp -DCOUNT_OPS" , {cwd: "build", nopipe: true}
);
sh("./multiexp_g2_benchmark 1000000", {cwd: "build", nopipe: true});
}
cli({
cleanAll,
downloadGoogleTest,
compileGoogleTest,
createFieldSources,
testSplitParStr,
testAltBn128,
buildBatchAccumulators,
testBatchAccumulators,
benchCurveAdds,
buildCurveAdds,
benchMultiExpG1,
benchMultiExpG2,
});