Skip to content

Commit

Permalink
multiprocs performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomino committed Dec 6, 2017
1 parent 69345ad commit e7493f3
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 3 deletions.
3 changes: 2 additions & 1 deletion test/comptimes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using JLD
using ArgParse
using CumulantsUpdates
using SymmetricTensors
using Combinatorics
import CumulantsUpdates: cumulants, moment

"""
Expand Down Expand Up @@ -60,7 +61,7 @@ function savecomptime(m::Int, n::Vector{Int}, t::Int, tup::Vector{Int}, b::Int,
cumtime = cumspeedups(m, n, t, tup, b)
push!(compt, "cumulants" => cumtime[1])
push!(compt, "cumulants updat" => cumtime[2])
push!(compt, "tm" => t./(2*tup))
push!(compt, "tm" => t./(2*tup+bellnum(m)))
push!(compt, "t" => t)
push!(compt, "n" => n)
push!(compt, "m" => m)
Expand Down
83 changes: 83 additions & 0 deletions test/comptimesprocs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env julia

using Cumulants
using SymmetricTensors
using CumulantsUpdates
using JLD
using ArgParse


function comptime(c, data::Matrix{Float64}, datup::Matrix{Float64})
t = time_ns()
updat(c, data, datup)
Float64(time_ns()-t)/1.0e9
end

precomp(m::Int, data::Matrix{Float64}) =
updat(momentarray(data[1:10, 1:10], m), data[1:10, 1:10], data[1:5, 1:10])

function savect(u::Vector{Int}, p::Int, n::Int, m::Int, b::Int)
comptimes = zeros(p, length(u))
data = randn(maximum(u)+10, n)
precomp(m, data)
M = momentarray(data, m, b)
for i in 1:p
rmprocs(procs()[2:end])
addprocs(i)
eval(Expr(:toplevel, :(@everywhere using CumulantsUpdates)))
println("number of workers = ", nworkers())
for k in 1:length(u)
datup = randn(u[k], n)
comptimes[i, k] = comptime(M, data, datup)
println("u = ", u[k])
end
end
filename = replace("res/$(m)_$(u)_$(n)_$(p)_nprocs.jld", "[", "")
filename = replace(filename, "]", "")
filename = replace(filename, " ", "")
compt = Dict{String, Any}("cumulants"=> comptimes)
push!(compt, "t" => u)
push!(compt, "n" => n)
push!(compt, "m" => m)
push!(compt, "x" => "number of procs")
push!(compt, "number of procs" => [collect(1:p)...])
push!(compt, "functions" => [["cumulants"]])
save(filename, compt)
end


function main(args)
s = ArgParseSettings("description")
@add_arg_table s begin
"--order", "-m"
help = "m, the order of cumulant, ndims of cumulant's tensor"
default = 4
arg_type = Int
"--nvar", "-n"
default = 48
help = "n, numbers of marginal variables"
arg_type = Int
"--tup", "-u"
help = "u, numbers of data updates"
nargs = '*'
default = [10000, 20000]
arg_type = Int
"--blocksize", "-b"
help = "the size of blocks of the block structure"
default = 4
arg_type = Int
"--nprocs", "-p"
help = "number of processes"
default = 6
arg_type = Int
end
parsed_args = parse_args(s)
m = parsed_args["order"]
n = parsed_args["nvar"]
u = parsed_args["tup"]
p = parsed_args["nprocs"]
b = parsed_args["blocksize"]
savect(u, p, n, m, b)
end

main(ARGS)
8 changes: 6 additions & 2 deletions test/res/plotcomptimes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function singleplot(filename::String, name::String, compare::String = "")
str = replace(@sprintf("%.0e", t[i]), "0", "")
tt = "\$"*replace(str, "e+", "\\times 10^{")*"}\$"
ax[:plot](d[x], comptimes[:,i], marker[i], label= "\$ t_{up} \$ = $tt", color = col[i], markersize=2.5, linewidth = 1)
elseif contains(filename, "nprocs")
str = replace(@sprintf("%.0e", t[i]), "0", "")
tt = "\$"*replace(str, "e+", "\\times 10^{")*"}\$"
ax[:plot](d[x], comptimes[:,i], marker[i], label= "\$ t_{up} \$ = $tt", color = col[i], markersize=2.5, linewidth = 1)
else
tt = n[i]
ax[:plot](d[x][o:end], comptimes[o:end,i], marker[i], label= "n = $tt", color = col[i], markersize=2.5, linewidth = 1)
Expand All @@ -41,11 +45,11 @@ function singleplot(filename::String, name::String, compare::String = "")
fx = matplotlib[:ticker][:ScalarFormatter]()
fx[:set_powerlimits]((-1, 4))
ax[:xaxis][:set_major_formatter](fx)
if contains(filename, "nblocks")
if contains(filename, "nblocks") | contains(filename, "nprocs")
subplots_adjust(left = 0.15)
PyPlot.ylabel(ylab, labelpad = 0.6)
PyPlot.xlabel(x, labelpad = 0.6)
ax[:legend](fontsize = 5, loc = 2, ncol = 1)
ax[:legend](fontsize = 5, loc = 9, ncol = 1)
else
PyPlot.ylabel(ylab, labelpad = -1.0)
PyPlot.xlabel("\$ t_{up} \$", labelpad = 0.6)
Expand Down

0 comments on commit e7493f3

Please sign in to comment.