Skip to content

Instantly share code, notes, and snippets.

Created February 17, 2016 05:25
Show Gist options
  • Save anonymous/54da587b01b7fb163103 to your computer and use it in GitHub Desktop.
Save anonymous/54da587b01b7fb163103 to your computer and use it in GitHub Desktop.
if !isdir(Pkg.dir("Benchmarks"))
Pkg.clone("https://github.com/johnmyleswhite/Benchmarks.jl")
end
using Benchmarks
versioninfo()
# atlas lib from github.com/matthew-brett/np-wheel-builder
# commit 35038507f0d5860955f0bb4602982867d888e3c9
# github.com/flame/blis commit 0b126de1342c11c65623bcb38e258e21e9244e3d
# built in cygwin64 via
# mkdir buildref01 && cd buildref01 && ../configure reference
# make -j8 CC=x86_64-w64-mingw32-gcc CPICFLAGS="" BLIS_ENABLE_DYNAMIC_BUILD=yes
# mkdir ../buildsandy02 && cd ../buildsandy02 && ../configure sandybridge
# make -j8 CC=x86_64-w64-mingw32-gcc CPICFLAGS="" BLIS_ENABLE_DYNAMIC_BUILD=yes
toppath = "C:/cygwin64/home/Tony/github" # CHANGEME
ENV["PATH"] *= ";C:/cygwin64/usr/x86_64-w64-mingw32/sys-root/mingw/bin" # libgomp etc
for (func, BlasInt, lib) in
((:dgemm_atlas, Int32, "$toppath/np-wheel-builder/atlas-builds/atlas-3.10.1-sse2-64/lib/numpy-atlas.dll"),
(:dgemm_blisref, Int64, "$toppath/blis/buildref01/lib/reference/libblis.so"),
(:dgemm_blissandy, Int64, "$toppath/blis/buildsandy02/lib/sandybridge/libblis.so"),
(:dgemm_openblas, Int64, "libopenblas64_"))
if lib == "libopenblas64_"
# Julia's ILP64 symbol renaming convention
dgemm = Libdl.dlsym(Libdl.dlopen(lib), :dgemm_64_)
else
dgemm = Libdl.dlsym(Libdl.dlopen(lib), :dgemm_)
end
@eval function $func(A, B)
transa = transb = 'N'
(M, K) = size(A)
(K2, N) = size(B)
@assert K == K2
@assert eltype(A) == eltype(B) == Float64
C = Array(eltype(A), M, N)
alpha = convert(eltype(A), 1.0)
beta = convert(eltype(A), 0.0)
lda = M
ldb = K
ldc = M
ccall($dgemm, Void, (Ptr{Cchar}, Ptr{Cchar},
Ptr{$BlasInt}, Ptr{$BlasInt}, Ptr{$BlasInt},
Ptr{eltype(A)}, Ptr{eltype(A)}, Ptr{$BlasInt},
Ptr{eltype(A)}, Ptr{$BlasInt}, Ptr{eltype(A)},
Ptr{eltype(A)}, Ptr{$BlasInt}),
&transa, &transb, &M, &N, &K,
&alpha, A, &lda, B, &ldb, &beta, C, &ldc)
return C
end
end
A = rand(2000, 2000)
B = rand(2000, 2000)
Catlas = dgemm_atlas(A, B)
Cblisref = dgemm_blisref(A, B)
Cblissandy = dgemm_blissandy(A, B)
Copenblas = dgemm_openblas(A, B)
@show @benchmark dgemm_atlas(A, B)
@show @benchmark dgemm_blisref(A, B)
@show @benchmark dgemm_blissandy(A, B)
@show @benchmark dgemm_openblas(A, B)
@show maximum(abs(Catlas - Cblisref))
@show maximum(abs(Catlas - Cblissandy))
@show maximum(abs(Catlas - Copenblas))
Julia Version 0.4.3
Commit a2f713d (2016-01-12 21:37 UTC)
Platform Info:
System: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.3
@benchmark(dgemm_atlas(A,B)) = ================ Benchmark Results ========================
Time per evaluation: 2.76 s [2.64 s, 2.89 s]
Proportion of time in GC: 0.00% [0.00%, 0.00%]
Memory allocated: 30.52 mb
Number of allocations: 2 allocations
Number of samples: 2
Number of evaluations: 2
Time spent benchmarking: 8.43 s
@benchmark(dgemm_blisref(A,B)) = ================ Benchmark Results ========================
Warning: function may not have been precompiled
Time per evaluation: 5.24 s
Proportion of time in GC: 0.00%
Memory allocated: 30.52 mb
Number of allocations: 2 allocations
Number of samples: 1
Number of evaluations: 1
Time spent benchmarking: 5.28 s
@benchmark(dgemm_blissandy(A,B)) = ================ Benchmark Results ========================
Time per evaluation: 658.65 ms [643.63 ms, 673.66 ms]
Proportion of time in GC: 0.28% [0.00%, 0.57%]
Memory allocated: 30.52 mb
Number of allocations: 2 allocations
Number of samples: 14
Number of evaluations: 14
Time spent benchmarking: 9.98 s
@benchmark(dgemm_openblas(A,B)) = ================ Benchmark Results ========================
Time per evaluation: 119.70 ms [114.81 ms, 124.59 ms]
Proportion of time in GC: 1.93% [1.54%, 2.33%]
Memory allocated: 30.52 mb
Number of allocations: 2 allocations
Number of samples: 84
Number of evaluations: 84
Time spent benchmarking: 10.27 s
maximum(abs(Catlas - Cblisref)) = 3.0127011996228248e-12
maximum(abs(Catlas - Cblissandy)) = 3.0127011996228248e-12
maximum(abs(Catlas - Copenblas)) = 3.0127011996228248e-12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment