Skip to content

Commit 8a33984

Browse files
authored
Merge pull request #15 from JuliaGraphs/sbromberger/julia1.0
julia 1.0 compat
2 parents 266c72c + ee03ab4 commit 8a33984

File tree

10 files changed

+94
-83
lines changed

10 files changed

+94
-83
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ os:
55
- linux
66

77
julia:
8-
- 0.6
9-
8+
- 1.0
9+
- nightly
1010
notifications:
1111
email: false
1212

@@ -27,10 +27,10 @@ matrix:
2727

2828
# uncomment the following lines to override the default test script
2929
script:
30-
- julia -e 'Pkg.clone(pwd()); Pkg.build("Graph500"); Pkg.test("Graph500"; coverage=true)'
30+
- julia -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("Graph500"); Pkg.test("Graph500"; coverage=true)'
3131

3232
after_success:
3333
# push coverage results to Coveralls
3434
# - julia -e 'cd(Pkg.dir("Graph500")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
3535
# push coverage results to Codecov
36-
- julia -e 'cd(Pkg.dir("Graph500")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
36+
- julia -e 'using Pkg; cd(Pkg.dir("Graph500")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'

REQUIRE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
julia 0.6
2-
LightGraphs 0.10.0
3-
StatsBase 0.8.2
1+
julia 0.7
2+
LightGraphs 1.0
3+
StatsBase
44
ProgressMeter

src/Graph500.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
__precompile__(true)
21
module Graph500
32

43
# Dependencies
54
using LightGraphs
65
using StatsBase
76
using ProgressMeter
87
import LightGraphs.sample
8+
using Distributed: @everywhere, @spawnat, @distributed, nprocs, myid
9+
using Markdown: @doc_str
10+
using Random
11+
using Statistics: std
12+
913

1014
export
1115
# kronecker_generator

src/driver.jl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ end
1010
### required for initialising Dict{Graph{T},Graph500Results}() constructor
1111
Graph500Results() = Graph500Results(0, 0, 0.0, zeros(0), zeros(0))
1212

13-
@doc_str """
13+
doc"""
1414
driver(scale, edgefactor; replicate, seed)
1515
1616
Run Graph500 benchmark(http://graph500.org/?page_id=12) on a graph with `2^scale` vertices and
@@ -29,9 +29,8 @@ function driver(
2929
ij = kronecker_generator(scale, edgefactor; replicate=replicate, seed=seed) # generate edge list
3030

3131
println("Starting Kernel 1.")
32-
tic()
33-
g = kernel_1(ij) # kernel1
34-
kernel_1_time = toq()
32+
33+
g, kernel_1_time = @timed kernel_1(ij) # kernel1
3534

3635
T = eltype(g)
3736
search_key = key_sampling(g) # sample min(nv(g),64) vertices for dfs
@@ -41,9 +40,7 @@ function driver(
4140

4241
### kernel_2
4342
@showprogress 1 "Kernel 2: " for (k, key) in enumerate(search_key)
44-
tic()
45-
parent_ = kernel_2(g, key)
46-
kernel_2_time[k] = toq()
43+
parent_, kernel_2_time[k] = @timed kernel_2(g, key)
4744
err = validate(g, parent_, ij, key)
4845
err <= 0 && error("BFS ", k, " from search key ", key, " failed to validate: ", err)
4946

src/kernel_1.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@doc_str """
1+
"""
22
get_next_type(T)
33
Return a data with a Integer Datatype twice the size of `T`
44
"""
@@ -9,7 +9,7 @@ function get_next_type(T::DataType)
99
(T== UInt64) && return (UInt128,64)
1010
end
1111

12-
@doc_str """
12+
"""
1313
kernel_1(ij)
1414
Create Graph from edge list `ij` based on kernel_1 benchmark(http://graph500.org/?page_id=12#sec-4)
1515
Return `LightGraphs.SimpleGraph` structure

src/kernel_2.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@doc_str """
1+
doc"""
22
key_sampling(g)
33
Sample `min(nv(g), 64)` keys in `[1,nv(g)]`
44
Returns a vector of randomly sampled keys
@@ -25,7 +25,7 @@ function key_sampling(
2525
return keys
2626
end
2727

28-
@doc_str """
28+
doc"""
2929
kernel_2(g, s)
3030
Perform bfs on graph `g` starting at vertex `s`
3131
Returns vector containing parent info for each vertex

src/kronecker_generator.jl

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,26 @@ function kronecker_generator(
5050
T_two = T(2)
5151

5252
# seeding the processors if replicate is true
53-
if replicate
54-
for i in 1:nprocs()
55-
@spawnat i srand(seed[i])
56-
end
57-
end
53+
# if replicate
54+
# for i in 1:nprocs()
55+
# if replicate
56+
# @spawnat i rng = MersenneTwister(seed[i])
57+
# else
58+
# @spawnat i rng = MersenneTwister()
59+
# end
60+
# end
61+
# end
5862

59-
temp = @parallel (+) for ib in 1:T(scale)
63+
temp = @distributed (+) for ib in 1:T(scale)
6064
# Compare with probabilities and set bits of indices.
65+
if replicate
66+
rng = Random.seed!(seed[myid()])
67+
else
68+
rng = Random.seed!()
69+
end
6170
random_bits = falses(2, M)
62-
random_bits[1, :] = rand(M) .> (ab)
63-
random_bits[2, :] = rand(M) .> ( c_norm.*(random_bits[1, :]) + a_norm.*.!(random_bits[1, :]) )
71+
random_bits[1, :] = rand(rng, M) .> (ab)
72+
random_bits[2, :] = rand(rng, M) .> ( c_norm.*(random_bits[1, :]) + a_norm.*.!(random_bits[1, :]) )
6473
T_two^(ib-T_one).*random_bits
6574
end
6675

src/output.jl

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,57 @@
1-
@doc_str """
1+
doc"""
22
output(result, nv, ne)
33
44
Print Graph500 Benchmark statistics(http://graph500.org/?page_id=12#sec-9_3)
55
"""
66
function output(result::Graph500Results,nv::Integer,ne::Integer)
7-
print_with_color(:green, "\n", "Benchmark Info", "\n")
8-
println("Scale : ", result.scale)
9-
println("Number of vertices : ", nv)
10-
println("Number of Edges : ", ne)
11-
println("Number of Bfs : ", result.nbfs, "\n")
12-
13-
# kernel 1 Construction time
14-
print_with_color(:green, "\n", "Graph construction time", "\n")
15-
println("Graph Construction Time : ", result.kernel_1_time, "\n")
16-
17-
# bfs time statistics
18-
bfs_time_stats = summarystats(result.kernel_2_time)
19-
print_with_color(:green, "\n", "BFS time statistics", "\n")
20-
println("BFS min time : ", bfs_time_stats.min)
21-
println("BFS first quartile time : ", bfs_time_stats.q25)
22-
println("BFS median time : ", bfs_time_stats.median)
23-
println("BFS third quartile time : ", bfs_time_stats.q75)
24-
println("BFS max time : ", bfs_time_stats.max)
25-
println("BFS mean time : ", bfs_time_stats.mean)
26-
println("BFS standard deviation time : ", std(result.kernel_2_time), "\n")
27-
28-
# bfs statistics based on number of edges
29-
bfs_edgetraversed_stats = summarystats(result.kernel_2_nedge)
30-
print_with_color(:green, "\n", "Edges traversed per BFS statistics", "\n")
31-
println("BFS min nedge : ", bfs_edgetraversed_stats.min)
32-
println("BFS first quartile nedge : ", bfs_edgetraversed_stats.q25)
33-
println("BFS median nedge : ", bfs_edgetraversed_stats.median)
34-
println("BFS third quartile nedge : ", bfs_edgetraversed_stats.q75)
35-
println("BFS max nedge : ", bfs_edgetraversed_stats.max)
36-
println("BFS mean nedge : ", bfs_edgetraversed_stats.mean)
37-
println("BFS standard deviation nedge : ", std(result.kernel_2_nedge), "\n")
38-
39-
# statistics on traversed edges per second(teps)
40-
bfs_teps = result.kernel_2_nedge ./ result.kernel_2_time
41-
bfs_n = length(bfs_teps)
42-
teps_stats = summarystats(bfs_teps)
43-
print_with_color(:green, "\n", "Edges traversed per second statistics", "\n")
44-
println("BFS min TEPS : ", teps_stats.min)
45-
println("BFS first quartile TEPS : ", teps_stats.q25)
46-
println("BFS median TEPS : ", teps_stats.median)
47-
println("BFS third quartile TEPS : ", teps_stats.q75)
48-
println("BFS max TEPS : ", teps_stats.max)
49-
50-
# harmomnic mean of teps
51-
k2tmp = 1.0 ./ bfs_teps
52-
k2tmp = k2tmp - (1/harmmean(bfs_teps))
53-
harmonic_std = (sqrt(sum(k2tmp.^2)) / (bfs_n-1)) * harmmean(bfs_teps)^2
54-
println("BFS harmonic mean TEPS : ", harmmean(bfs_teps))
55-
println("BFS harmonic standard deviation TEPS : ", harmonic_std, "\n")
56-
end
7+
io = IOContext(stdout, :color=>true)
8+
printstyled(io, "\n", "Benchmark Info", "\n", color=:green)
9+
println("Scale : ", result.scale)
10+
println("Number of vertices : ", nv)
11+
println("Number of Edges : ", ne)
12+
println("Number of Bfs : ", result.nbfs, "\n")
13+
14+
# kernel 1 Construction time
15+
printstyled(io, "\n", "Graph construction time", "\n", color=:green)
16+
println("Graph Construction Time : ", result.kernel_1_time, "\n")
17+
18+
# bfs time statistics
19+
bfs_time_stats = summarystats(result.kernel_2_time)
20+
printstyled(io, "\n", "BFS time statistics", "\n", color=:green)
21+
println("BFS min time : ", bfs_time_stats.min)
22+
println("BFS first quartile time : ", bfs_time_stats.q25)
23+
println("BFS median time : ", bfs_time_stats.median)
24+
println("BFS third quartile time : ", bfs_time_stats.q75)
25+
println("BFS max time : ", bfs_time_stats.max)
26+
println("BFS mean time : ", bfs_time_stats.mean)
27+
println("BFS standard deviation time : ", std(result.kernel_2_time), "\n")
28+
29+
# bfs statistics based on number of edges
30+
bfs_edgetraversed_stats = summarystats(result.kernel_2_nedge)
31+
printstyled(io, "\n", "Edges traversed per BFS statistics", "\n", color=:green)
32+
println("BFS min nedge : ", bfs_edgetraversed_stats.min)
33+
println("BFS first quartile nedge : ", bfs_edgetraversed_stats.q25)
34+
println("BFS median nedge : ", bfs_edgetraversed_stats.median)
35+
println("BFS third quartile nedge : ", bfs_edgetraversed_stats.q75)
36+
println("BFS max nedge : ", bfs_edgetraversed_stats.max)
37+
println("BFS mean nedge : ", bfs_edgetraversed_stats.mean)
38+
println("BFS standard deviation nedge : ", std(result.kernel_2_nedge), "\n")
39+
40+
# statistics on traversed edges per second(teps)
41+
bfs_teps = result.kernel_2_nedge ./ result.kernel_2_time
42+
bfs_n = length(bfs_teps)
43+
teps_stats = summarystats(bfs_teps)
44+
printstyled(io, "\n", "Edges traversed per second statistics", "\n", color=:green)
45+
println("BFS min TEPS : ", teps_stats.min)
46+
println("BFS first quartile TEPS : ", teps_stats.q25)
47+
println("BFS median TEPS : ", teps_stats.median)
48+
println("BFS third quartile TEPS : ", teps_stats.q75)
49+
println("BFS max TEPS : ", teps_stats.max)
50+
51+
# harmomnic mean of teps
52+
k2tmp = 1.0 ./ bfs_teps
53+
k2tmp = k2tmp .- (1/harmmean(bfs_teps))
54+
harmonic_std = (sqrt(sum(k2tmp.^2)) / (bfs_n-1)) * harmmean(bfs_teps)^2
55+
println("BFS harmonic mean TEPS : ", harmmean(bfs_teps))
56+
println("BFS harmonic standard deviation TEPS : ", harmonic_std, "\n")
57+
end

src/validation.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@doc_str """
1+
doc"""
22
validate(g, parent_, ij, search_key)
33
validate `parent_` info for bfs on graph `g` with key `search_key` based on Graph500 result
44
validation(http://graph500.org/?page_id=12#sec-8)
@@ -20,16 +20,16 @@ function validate(
2020
end
2121

2222
N = nv(g)
23-
slice = find(x->(x > zero(T)), parent_)
23+
slice = findall(x->(x > zero(T)), parent_)
2424

2525
#Compute levels and check for cycles.
2626
level_ = zeros(T, length(parent_))
27-
level_[slice] = 1
27+
level_[slice] .= 1
2828
P = parent_[slice]
2929
mask = (P .!= search_key)
3030
k = 0
3131
while any(mask)
32-
level_[slice[mask]] = level_[slice[mask]] + 1
32+
level_[slice[mask]] .+= 1
3333
P = parent_[P]
3434
mask = (P .!= search_key)
3535
k = k + 1

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Graph500
2-
using Base.Test
2+
using Test
33

44
@testset begin
55
include("kronecker_generator.jl")

0 commit comments

Comments
 (0)