-
Notifications
You must be signed in to change notification settings - Fork 0
/
simplex_runtime_benchmark.jl
133 lines (119 loc) · 4.83 KB
/
simplex_runtime_benchmark.jl
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
#simplex_runtime_benchmark
using BenchmarkTools, Random, Distributions
BenchmarkTools.DEFAULT_PARAMETERS.gcsample = true
BenchmarkTools.DEFAULT_PARAMETERS.samples = 100
BenchmarkTools.DEFAULT_PARAMETERS.seconds = 20
include("simplex_and_l1ball/simplex_wrap.jl")
println("You are using ", nthreads(), " threads for parallel computing")
println("Warning: following experiments are for 80 threads!")
#=
Following code is for our paper experiments, 80 threads and testing results for
1, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80 threads
=#
function standard_normal_test_condat(n::Int)
println("results for condat:")
Random.seed!(12345); res = @benchmark condat_s($(rand(Normal(0, 1), n)), 1)
println("serial : ", median(res))
for i in 1:10
Random.seed!(12345); res = @benchmark condat_p($(rand(Normal(0, 1), n)), 1, $(i*8), 0.01)
println(i*8, " : ", median(res))
end
end
function uniform_test_condat(n::Int)
println("results for condat:")
Random.seed!(12345); res = @benchmark condat_s($(rand(n)), 1)
println("serial : ", median(res))
for i in 1:10
Random.seed!(12345); res = @benchmark condat_p($(rand(n)), 1, $(i*8), 0.00001)
println(i*8, " : ", median(res))
end
end
function small_variance_normal_test_condat(n::Int)
println("results for condat:")
Random.seed!(12345); res = @benchmark condat_s($(rand(Normal(0, 0.001), n)), 1)
println("serial : ", median(res))
for i in 1:10
Random.seed!(12345); res = @benchmark condat_p($(rand(Normal(0, 0.001), n)), 1, $(i*8), 0.00001)
println(i*8, " : ", median(res))
end
end
function standard_normal_test_michelot(n::Int)
println("results for michelot:")
Random.seed!(12345); res = @benchmark michelot_s($(rand(Normal(0, 1), n)), 1)
println("serial : ", median(res))
for i in 1:10
Random.seed!(12345); res = @benchmark michelot_p($(rand(Normal(0, 1), n)), 1, $(i*8), 0.0)
println(i*8, " : ", median(res))
end
end
function uniform_test_michelot(n::Int)
println("results for michelot:")
Random.seed!(12345); res = @benchmark michelot_s($(rand(n)), 1)
println("serial : ", median(res))
for i in 1:10
Random.seed!(12345); res = @benchmark michelot_p($(rand(n)), 1, $(i*8), 0.0)
println(i*8, " : ", median(res))
end
end
function small_variance_normal_test_michelot(n::Int)
println("results for michelot:")
Random.seed!(12345); res = @benchmark michelot_s($(rand(Normal(0, 0.001), n)), 1)
println("serial : ", median(res))
for i in 1:10
Random.seed!(12345); res = @benchmark michelot_p($(rand(Normal(0, 0.001), n)), 1, $(i*8), 0.00001)
println(i*8, " : ", median(res))
end
end
function standard_normal_test_sortscan(n::Int)
println("results for sortscan:")
Random.seed!(12345); res = @benchmark sortscan_s($(rand(Normal(0, 1), n)), 1)
println("serial : ", median(res))
for i in 1:10
Random.seed!(12345); res = @benchmark sortscan_p($(rand(Normal(0, 1), n)), 1, $(i*8))
println(i*8, " sortscan : ", median(res))
Random.seed!(12345); res = @benchmark sortPscan_p($(rand(Normal(0, 1), n)), 1, $(i*8))
println(i*8, " sortPscan: ", median(res))
end
end
function uniform_test_sortscan(n::Int)
println("results for sortscan:")
Random.seed!(12345); res = @benchmark sortscan_s($(rand(n)), 1)
println("serial : ", median(res))
for i in 1:10
Random.seed!(12345); res = @benchmark sortscan_p($(rand(n)), 1, $(i*8))
println(i*8, " sortscan : ", median(res))
Random.seed!(12345); res = @benchmark sortPscan_p($(rand(n)), 1, $(i*8))
println(i*8, " sortPscan: ", median(res))
end
end
function small_variance_normal_test_sortscan(n::Int)
println("results for sortscan:")
Random.seed!(12345); res = @benchmark sortscan_s($(rand(Normal(0, 0.001), n)), 1)
println("serial : ", median(res))
for i in 1:10
Random.seed!(12345); res = @benchmark sortscan_p($(rand(Normal(0, 0.001), n)), 1, $(i*8))
println(i*8, " sortscan : ", median(res))
Random.seed!(12345); res = @benchmark sortPscan_p($(rand(Normal(0, 0.001), n)), 1, $(i*8))
println(i*8, " sortPscan: ", median(res))
end
end
# for n = 10^8
uniform_test_sortscan(10^8)
standard_normal_test_sortscan(10^8)
small_variance_normal_test_sortscan(10^8)
uniform_test_michelot(10^8)
standard_normal_test_michelot(10^8)
small_variance_normal_test_michelot(10^8)
uniform_test_condat(10^8)
standard_normal_test_condat(10^8)
small_variance_normal_test_condat(10^8)
# for n = 10^7, 10^8, 10^9
standard_normal_test_sortscan(10^7)
standard_normal_test_michelot(10^7)
standard_normal_test_condat(10^7)
standard_normal_test_sortscan(10^8)
standard_normal_test_michelot(10^8)
standard_normal_test_condat(10^8)
standard_normal_test_sortscan(10^9)
standard_normal_test_michelot(10^9)
standard_normal_test_condat(10^9)