-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
359 lines (300 loc) · 14.4 KB
/
build.gradle
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
//#######################################
//# Copyright (C) 2019-2020 Otmar Ertl. #
//# All rights reserved. #
//#######################################
import java.security.MessageDigest
plugins {
id "de.undercouch.download" version "3.4.3" // used for Download task
}
ext {
paperDir = 'paper'
pythonDir = 'python'
cppDir = 'c++'
wyhashDir = "wyhash"
dataDir = 'data'
wyhashZipFile = "wyhash_v4.zip"
wyhashCppDir = "${cppDir}/${wyhashDir}"
wyhashSourceDir = "${wyhashCppDir}/wyhash-wyhash_v4"
wyhashHeaderFile = "wyhash.h"
}
//#########################
// wyHash
//#########################
task downloadWyhash(type: Download) {
src "https://github.com/wangyi-fudan/wyhash/archive/wyhash_v4.zip"
dest "${wyhashCppDir}"
overwrite true
onlyIfModified true
}
task unzipWyhash(type: Copy) {
inputs.files "${wyhashCppDir}/${wyhashZipFile}"
def zipFile = file("${wyhashCppDir}/${wyhashZipFile}")
def outputDir = file("${wyhashCppDir}")
from zipTree(zipFile)
into outputDir
dependsOn downloadWyhash
}
task copyWyhashFiles(type: Copy) {
from "${wyhashSourceDir}/${wyhashHeaderFile}"
into "${wyhashCppDir}"
dependsOn unzipWyhash
}
task getWyhash {
group 'ProbMinHash'
dependsOn copyWyhashFiles
}
//#########################
// tests
//#########################
task buildBitstreamTestExecutable(type: Exec) {
inputs.files "${cppDir}/bitstream_test.cpp", "${cppDir}/bitstream_random.hpp"
outputs.files "${cppDir}/bitstream_test.out"
standardOutput = new ByteArrayOutputStream()
commandLine 'g++','-O3','-std=c++17','-Wall',"${cppDir}/bitstream_test.cpp",'-o',"${cppDir}/bitstream_test.out"
}
task executeBitstreamTest (type: Exec) {
inputs.files "${cppDir}/bitstream_test.out"
commandLine "${cppDir}/bitstream_test.out","${dataDir}"
dependsOn buildBitstreamTestExecutable
}
task buildRandomTestExecutable(type: Exec) {
inputs.files "${cppDir}/random_test.cpp", "${cppDir}/bitstream_random.hpp","${cppDir}/exponential_distribution.hpp","${wyhashCppDir}/${wyhashHeaderFile}"
outputs.files "${cppDir}/random_test.out"
standardOutput = new ByteArrayOutputStream()
commandLine 'g++','-O3','-std=c++17','-Wall','-DNDEBUG',"${cppDir}/random_test.cpp",'-o',"${cppDir}/random_test.out"
//commandLine 'g++','-O3','-std=c++17','-Wall',"${cppDir}/random_test.cpp",'-o',"${cppDir}/random_test.out"
}
def randomTestFiles = [ \
"${dataDir}/boolean.txt", \
"${dataDir}/uniformLemire3.txt", \
"${dataDir}/uniformLemire11.txt", \
"${dataDir}/uniformLemire29.txt", \
"${dataDir}/uniformLemire256.txt", \
"${dataDir}/uniformLumbroso3.txt", \
"${dataDir}/uniformLumbroso11.txt", \
"${dataDir}/uniformLumbroso29.txt", \
"${dataDir}/uniformLumbroso256.txt", \
"${dataDir}/intPow3.txt", \
"${dataDir}/intPow8.txt", \
"${dataDir}/expZiggurat.txt", \
"${dataDir}/expStandard.txt", \
"${dataDir}/uniformDouble.txt", \
"${dataDir}/uniformDoubleHalf.txt", \
"${dataDir}/bernoulliReal0_2.txt", \
"${dataDir}/bernoulliRatio1_3.txt", \
"${dataDir}/truncatedExp0.txt", \
"${dataDir}/truncatedExp0_1.txt", \
"${dataDir}/truncatedExp0_5.txt", \
"${dataDir}/truncatedExp1.txt", \
"${dataDir}/truncatedExp2.txt" ]
def executeRandomTestOutput = "${dataDir}/random_test_calculation_times.txt"
task buildOrderMinhashTestExecutable(type: Exec) {
inputs.files "${cppDir}/order_minhash_equivalence_test.cpp", "${cppDir}/minhash.hpp","${cppDir}/bitstream_random.hpp","${cppDir}/data_generation.hpp","${cppDir}/exponential_distribution.hpp","${wyhashCppDir}/${wyhashHeaderFile}"
outputs.files "${cppDir}/order_minhash_equivalence_test.out"
standardOutput = new ByteArrayOutputStream()
commandLine 'g++','-O3','-std=c++17','-Wall', "${cppDir}/order_minhash_equivalence_test.cpp",'-o',"${cppDir}/order_minhash_equivalence_test.out"
}
task executeRandomTest (type: Exec) {
inputs.files "${cppDir}/random_test.out"
outputs.files randomTestFiles
doFirst {
standardOutput = new FileOutputStream(executeRandomTestOutput)
}
commandLine "${cppDir}/random_test.out","${dataDir}"
dependsOn buildRandomTestExecutable
}
task performRandomTest (type: Exec) {
inputs.files randomTestFiles, "${pythonDir}/random_test.py"
outputs.files
standardOutput = new ByteArrayOutputStream()
commandLine 'python3', "${pythonDir}/random_test.py"
dependsOn executeRandomTest
}
def executeOrderMinhashEquivalenceTestOutput = "${dataDir}/orderMinhashEquivalenceTest.txt"
task executeOrderMinhashEquivalenceTest (type: Exec) {
inputs.files "${cppDir}/order_minhash_equivalence_test.out"
outputs.files executeOrderMinhashEquivalenceTestOutput
doFirst {
standardOutput = new FileOutputStream(executeOrderMinhashEquivalenceTestOutput)
}
commandLine "${cppDir}/order_minhash_equivalence_test.out"
dependsOn buildOrderMinhashTestExecutable
}
task performOrderMinhashEquivalenceTest (type: Exec) {
inputs.files executeOrderMinhashEquivalenceTestOutput, "${pythonDir}/order_minhash_equivalence_test.py"
standardOutput = new ByteArrayOutputStream()
commandLine 'python3', "${pythonDir}/order_minhash_equivalence_test.py"
dependsOn executeOrderMinhashEquivalenceTest
}
task performComplexityInequalityTest (type: Exec) {
inputs.files "${pythonDir}/complexity_inequality_test.py"
standardOutput = new ByteArrayOutputStream()
commandLine 'python3', "${pythonDir}/complexity_inequality_test.py"
}
task performTests {
group 'ProbMinHash'
dependsOn performRandomTest, executeBitstreamTest, performOrderMinhashEquivalenceTest, performComplexityInequalityTest
}
task buildErrorTestExecutable(type: Exec) {
inputs.files "${cppDir}/error_test.cpp", "${cppDir}/minhash.hpp","${cppDir}/bitstream_random.hpp","${cppDir}/data_generation.hpp","${cppDir}/exponential_distribution.hpp","${wyhashCppDir}/${wyhashHeaderFile}"
outputs.files "${cppDir}/error_test.out"
standardOutput = new ByteArrayOutputStream()
commandLine 'g++','-O3','-std=c++17','-fopenmp','-Wall',"${cppDir}/error_test.cpp",'-o',"${cppDir}/error_test.out"
}
task buildBufferSizeTestExecutable(type: Exec) {
inputs.files "${cppDir}/buffer_size_test.cpp", "${cppDir}/minhash.hpp","${cppDir}/bitstream_random.hpp","${cppDir}/data_generation.hpp","${cppDir}/exponential_distribution.hpp","${wyhashCppDir}/${wyhashHeaderFile}"
outputs.files "${cppDir}/buffer_size_test.out"
standardOutput = new ByteArrayOutputStream()
commandLine 'g++','-O3','-std=c++17','-fopenmp','-Wall',"${cppDir}/buffer_size_test.cpp",'-o',"${cppDir}/buffer_size_test.out"
}
task buildPerformanceTestExecutable(type: Exec) {
inputs.files "${cppDir}/performance_test.cpp", "${cppDir}/minhash.hpp","${cppDir}/bitstream_random.hpp","${cppDir}/exponential_distribution.hpp","${wyhashCppDir}/${wyhashHeaderFile}"
outputs.files "${cppDir}/performance_test.out"
standardOutput = new ByteArrayOutputStream()
commandLine 'g++','-O3','-DNDEBUG','-std=c++17','-Wall',"${cppDir}/performance_test.cpp",'-o',"${cppDir}/performance_test.out"
// commandLine 'g++','-O3','-std=c++17','-Wall',"${cppDir}/performance_test.cpp",'-o',"${cppDir}/performance_test.out"
}
task buildOrderMinhashPerformanceTestExecutable(type: Exec) {
inputs.files "${cppDir}/order_minhash_performance_test.cpp", "${cppDir}/minhash.hpp","${cppDir}/bitstream_random.hpp","${cppDir}/exponential_distribution.hpp","${wyhashCppDir}/${wyhashHeaderFile}"
outputs.files "${cppDir}/order_minhash_performance_test.out"
standardOutput = new ByteArrayOutputStream()
commandLine 'g++','-O3','-DNDEBUG','-std=c++17','-Wall',"${cppDir}/order_minhash_performance_test.cpp",'-o',"${cppDir}/order_minhash_performance_test.out"
// commandLine 'g++','-O3','-std=c++17','-Wall',"${cppDir}/order_minhash_performance_test.cpp",'-o',"${cppDir}/order_minhash_performance_test.out"
}
def executeErrorTestOutput = "${dataDir}/error_test.csv"
task executeErrorTest (type: Exec) {
inputs.files "${cppDir}/error_test.out"
outputs.files executeErrorTestOutput
doFirst {
standardOutput = new FileOutputStream(executeErrorTestOutput)
}
commandLine "${cppDir}/error_test.out"
dependsOn buildErrorTestExecutable
}
def errorChartsFig = "${paperDir}/error_charts.pdf"
task makeErrorFigures (type: Exec) {
inputs.files executeErrorTestOutput, "${pythonDir}/error_charts.py","${pythonDir}/color_defs.py"
outputs.files errorChartsFig
doFirst {
standardOutput = new ByteArrayOutputStream()
}
commandLine 'python3', "${pythonDir}/error_charts.py"
}
def generateMD5(String s) {
MessageDigest digest = MessageDigest.getInstance("MD5")
digest.update(s.bytes)
new BigInteger(1, digest.digest()).longValue()
}
def dataSizes = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000]
def performanceTestHashSizes = [256, 1024, 4096]
def performanceTestDatFiles = []
def performanceTestTasks = []
for(hashSize in performanceTestHashSizes) {
for(dataSize in dataSizes) {
def performanceTestTaskName = "doPerformanceTest_${hashSize}_${dataSize}"
def performanceTestDatFile = "${dataDir}/performance_test_result_${hashSize}_${dataSize}.dat"
def seed = generateMD5(performanceTestTaskName)
task "${performanceTestTaskName}" (type: Exec) {
inputs.files "${cppDir}/performance_test.out"
outputs.files performanceTestDatFile
doFirst {
standardOutput = new FileOutputStream(performanceTestDatFile)
}
commandLine "${cppDir}/performance_test.out", seed, hashSize, dataSize
dependsOn buildPerformanceTestExecutable
}
performanceTestDatFiles.add performanceTestDatFile
performanceTestTasks.add performanceTestTaskName
}
}
def orderMinHashDataSizes = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000]
def orderMinhashL = [2, 5]
def orderMinhashPerformanceTestDatFiles = []
def orderMinhashPerformanceTestTasks = []
for(hashSize in performanceTestHashSizes) {
for(dataSize in orderMinHashDataSizes) {
for(l in orderMinhashL) {
if(dataSize < l) continue
def orderMinhashPerformanceTestTaskName = "doOrderMinhashPerformanceTest_${hashSize}_${dataSize}_${l}"
def orderMinhashPerformanceTestDatFile = "${dataDir}/order_minhash_performance_test_result_${hashSize}_${dataSize}_${l}.dat"
def seed = generateMD5(orderMinhashPerformanceTestTaskName)
task "${orderMinhashPerformanceTestTaskName}" (type: Exec) {
inputs.files "${cppDir}/order_minhash_performance_test.out"
outputs.files orderMinhashPerformanceTestDatFile
doFirst {
standardOutput = new FileOutputStream(orderMinhashPerformanceTestDatFile)
}
commandLine "${cppDir}/order_minhash_performance_test.out", seed, hashSize, dataSize, l
dependsOn buildOrderMinhashPerformanceTestExecutable
}
orderMinhashPerformanceTestDatFiles.add orderMinhashPerformanceTestDatFile
orderMinhashPerformanceTestTasks.add orderMinhashPerformanceTestTaskName
}
}
}
def bufferSizeTestDatFiles = []
def bufferSizeTestTasks = []
def bufferSizeTestHashSizes = [256, 1024, 4096]
def bufferSizeTestDataSizes = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000]
for(hashSize in bufferSizeTestHashSizes) {
for(dataSize in bufferSizeTestDataSizes) {
def bufferSizeTestTaskName = "doBufferSizeTest_${hashSize}_${dataSize}"
def bufferSizeTestDatFile = "${dataDir}/buffer_size_test_result_${hashSize}_${dataSize}.dat"
def seed = generateMD5(bufferSizeTestTaskName)
task "${bufferSizeTestTaskName}" (type: Exec) {
inputs.files "${cppDir}/buffer_size_test.out"
outputs.files bufferSizeTestDatFile
doFirst {
standardOutput = new FileOutputStream(bufferSizeTestDatFile)
}
commandLine "${cppDir}/buffer_size_test.out", seed, hashSize, dataSize
dependsOn buildBufferSizeTestExecutable
}
bufferSizeTestDatFiles.add bufferSizeTestDatFile
bufferSizeTestTasks.add bufferSizeTestTaskName
}
}
task makeBufferSizeTestFigures (type: Exec) {
inputs.files bufferSizeTestDatFiles, "${pythonDir}/buffer_size_charts.py","${pythonDir}/color_defs.py"
outputs.files "${paperDir}/buffer_size_charts.pdf"
commandLine 'python3', "${pythonDir}/buffer_size_charts.py"
}
def orderMinhashSpeedChartsFig = "${paperDir}/order_minhash_speed_charts.pdf"
def speedChartsFig = "${paperDir}/speed_charts.pdf"
def figFiles = [orderMinhashSpeedChartsFig, speedChartsFig, errorChartsFig, "${paperDir}/buffer_size_charts.pdf","${paperDir}/alpha.pdf","${paperDir}/exp_truncated_sampling.pdf"]
task makeSpeedTestFigures (type: Exec) {
inputs.files performanceTestDatFiles, "${pythonDir}/speed_charts.py","${pythonDir}/color_defs.py"
outputs.files speedChartsFig
commandLine 'python3', "${pythonDir}/speed_charts.py"
}
task makeOrderMinhashPerformanceTestFigures (type: Exec) {
inputs.files orderMinhashPerformanceTestDatFiles, "${pythonDir}/order_minhash_speed_charts.py","${pythonDir}/color_defs.py"
outputs.files orderMinhashSpeedChartsFig
commandLine 'python3', "${pythonDir}/order_minhash_speed_charts.py"
}
task makeAlphaFigure (type: Exec) {
inputs.files "${pythonDir}/alpha.py","${pythonDir}/color_defs.py"
outputs.files "${paperDir}/alpha.pdf"
commandLine 'python3', "${pythonDir}/alpha.py"
}
task makeExpTruncatedSamplingFigure (type: Exec) {
inputs.files "${pythonDir}/exp_truncated_sampling.py","${pythonDir}/color_defs.py"
outputs.files "${paperDir}/exp_truncated_sampling.pdf"
commandLine 'python3', "${pythonDir}/exp_truncated_sampling.py"
}
task pdfFigures {
dependsOn makeSpeedTestFigures, makeAlphaFigure, makeErrorFigures, makeBufferSizeTestFigures, makeOrderMinhashPerformanceTestFigures, makeExpTruncatedSamplingFigure
}
task executePerformanceTests {
dependsOn performanceTestTasks
}
task executeOrderMinhashPerformanceTests {
dependsOn orderMinhashPerformanceTestTasks
}
task executeBufferSizeTests {
dependsOn bufferSizeTestTasks
}
task execute {
group 'ProbMinHash'
dependsOn executeErrorTest, executePerformanceTests, executeBufferSizeTests, executeOrderMinhashPerformanceTests
}