Skip to content

Commit

Permalink
update test/perf/micro from 0.4.0. to 0.7.0 (#23922)
Browse files Browse the repository at this point in the history
* Updated paths to BLAS, dsfmt, Rmath in Makefile & sscanf syntax in perf.m
* Expanded benchmark names (fib->recursion_fibonacci) and reordered languages.
* Commented out Go and Stata processing
  • Loading branch information
johnfgibson authored and StefanKarpinski committed Oct 10, 2017
1 parent df8efe5 commit 08dd631
Show file tree
Hide file tree
Showing 13 changed files with 217 additions and 128 deletions.
39 changes: 24 additions & 15 deletions test/perf/micro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ endif

#Which BLAS library am I using?
ifeq ($(USE_SYSTEM_BLAS), 0)
BLASDIR=$(JULIAHOME)/deps/build/openblas/
BLASMANIFEST=$(shell cat $(JULIAHOME)/usr/manifest/openblas)
BLASDIR=$(JULIAHOME)/deps/scratch/$(BLASMANIFEST)/
LIBBLAS=$(BLASDIR)$(LIBBLASNAME).a
endif

Expand All @@ -31,15 +32,15 @@ FFLAGS+= -static-libgfortran
endif

#Which libm library am I using?
LIBMDIR = $(JULIAHOME)/deps/build/openlibm/
LIBMDIR = $(JULIAHOME)/usr/lib/
ifeq ($(USE_SYSTEM_LIBM), 0)
ifeq ($(USE_SYSTEM_OPENLIBM), 0)
LIBM = $(LIBMDIR)libopenlibm.a
endif
endif

DSFMTDIR = $(JULIAHOME)/deps/build/dsfmt-$(DSFMT_VER)
RMATHDIR = $(JULIAHOME)/deps/build/Rmath-julia-$(RMATH_JULIA_VER)
DSFMTDIR = $(JULIAHOME)/deps/scratch/dsfmt-$(DSFMT_VER)
RMATHDIR = $(JULIAHOME)/deps/scratch/Rmath-julia-$(RMATH_JULIA_VER)

default: benchmarks.html

Expand All @@ -56,7 +57,8 @@ bin/perf%: perf.c perf.h

bin/fperf%: perf.f90
mkdir -p mods/$@ #Modules for each binary go in separate directories
$(FC) $(FFLAGS) -Jmods/$@ -O$* $< -o $@ $(LIBBLAS) -L$(LIBMDIR) $(LIBM) -lpthread
# $(FC) $(FFLAGS) -Jmods/$@ -O$* $< -o $@ $(LIBBLAS) -L$(LIBMDIR) $(LIBM) -lpthread
$(FC) $(FFLAGS) -Jmods/$@ -O$* $< -o $@ -lblas -L$(LIBMDIR) $(LIBM) -lpthread

benchmarks/c.csv: \
benchmarks/c0.csv \
Expand All @@ -72,6 +74,7 @@ benchmarks/fortran.csv: \
benchmarks/fortran3.csv
cat $^ > $@


benchmarks/c%.csv: bin/perf%
for t in 1 2 3 4 5; do $<; done >$@

Expand All @@ -80,7 +83,8 @@ benchmarks/fortran%.csv: bin/fperf%

benchmarks/go.csv: export GOPATH=$(abspath gopath)
benchmarks/go.csv: perf.go
CGO_LDFLAGS="$(LIBBLAS) $(LIBM)" go get github.com/gonum/blas/cgo
#CGO_LDFLAGS="$(LIBBLAS) $(LIBM)" go get github.com/gonum/blas/cgo
CGO_LDFLAGS="-lblas $(LIBM)" go get github.com/gonum/blas/cgo
go get github.com/gonum/matrix/mat64
go get github.com/gonum/stat
for t in 1 2 3 4 5; do go run $<; done >$@
Expand Down Expand Up @@ -110,7 +114,8 @@ benchmarks/stata.csv: perf.do
for t in 1 2 3 4 5; do stata -b do $^ $@; done

benchmarks/lua.csv: perf.lua
for t in 1 2 3 4 5; do gsl-shell $<; done >$@
for t in 1 2 3 4 5; do scilua $<; done >$@
# for t in 1 2 3 4 5; do gsl-shell $<; done >$@

benchmarks/java.csv: java/src/main/java/PerfBLAS.java
cd java; sh setup.sh; for t in 1 2 3 4 5; do mvn -q exec:java; done >../$@
Expand All @@ -121,17 +126,21 @@ benchmarks/scala.csv: scala/src/main/scala/perf.scala scala/build.sbt
BENCHMARKS = \
benchmarks/c.csv \
benchmarks/fortran.csv \
benchmarks/go.csv \
benchmarks/java.csv \
benchmarks/javascript.csv \
benchmarks/julia.csv \
benchmarks/python.csv \
benchmarks/lua.csv \
benchmarks/mathematica.csv \
benchmarks/matlab.csv \
benchmarks/octave.csv \
benchmarks/r.csv \
benchmarks/lua.csv \
benchmarks/javascript.csv \
benchmarks/mathematica.csv \
benchmarks/java.csv \
benchmarks/scala.csv
benchmarks/python.csv \
benchmarks/r.csv

# These were formerly listed in BENCHMARKS, but I can't get them to run
# 2017-09-27 johnfgibson
# benchmarks/go.csv \
# benchmarks/scala.csv


benchmarks.csv: bin/collect.pl $(BENCHMARKS)
@$(call PRINT_PERL, $^ >$@)
Expand Down
47 changes: 27 additions & 20 deletions test/perf/micro/bin/table.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,49 @@
}

our @benchmarks = qw(
fib
parse_int
quicksort
mandel
pi_sum
rand_mat_stat
rand_mat_mul
iteration_mandelbrot
iteration_pi_sum
recursion_fibonacci
recursion_quicksort
parse_integers
print_to_file
matrix_statistics
matrix_multiply
);

our $c_ver = `gcc -v 2>&1 | grep "gcc version" | cut -f3 -d" "`;
our $julia_ver = `../../../julia -v | cut -f3 -d" "`;
our $fortran_ver = `gfortran -v 2>&1 | grep "gcc version" | cut -f3 -d" "`;
our $python_ver = `python3 -V 2>&1 | cut -f2 -d" "`;
our $matlab_ver = `matlab -nodisplay -nojvm -nosplash -r "version -release, quit" | tail -n 3 | head -n 1`;
our $R_ver = `R --version | grep "R version" | cut -f3 -d" "`;
our $octave_ver = `octave -v | grep version | cut -f4 -d" "`;
our $go_ver = `go version | cut -f3 -d" "`;
our $lua_ver = `gsl-shell -v 2>&1 | grep Shell | cut -f3 -d" " | cut -f1 -d,`;
#our $go_ver = `go version | cut -f3 -d" "`;
#our $lua_ver = `scilua -v 2>&1 | grep Shell | cut -f3 -d" " | cut -f1 -d,`;
our $lua_ver = "scilua v1.0.0-b12";
our $javascript_ver = `nodejs -e "console.log(process.versions.v8)"`;
our $mathematica_ver = `echo quit | math -version | head -n 1 | cut -f2 -d" "`;
our $stata_ver = `stata -q -b version && grep version stata.log | cut -f2 -d" " && rm stata.log`;
#our $stata_ver = `stata -q -b version && grep version stata.log | cut -f2 -d" " && rm stata.log`;
our $java_ver = `java -version 2>&1 |grep "version" | cut -f 3 -d " " | cut -c 2-9`;

our %systems = (
"fortran" => ["Fortran" , "gcc $fortran_ver" ],
"c" => ["C" , "gcc $c_ver" ],
"julia" => ["Julia" , $julia_ver ],
"python" => ["Python" , $python_ver ],
"matlab" => ["Matlab" , "R$matlab_ver" ],
"octave" => ["Octave" , $octave_ver ],
"r" => ["R" , $R_ver ],
"lua" => ["LuaJIT" , "$lua_ver" ],
"fortran" => ["Fortran" , "gcc $fortran_ver" ],
"java" => ["Java" , $java_ver ],
"javascript" => ["JavaScript" , "V8 $javascript_ver" ],
"go" => ["Go" , $go_ver ],
"matlab" => ["Matlab" , "R$matlab_ver" ],
"python" => ["Python" , $python_ver ],
"mathematica"=> ["Mathe-matica" , $mathematica_ver ],
"lua" => ["LuaJIT" , "gsl-shell $lua_ver" ],
"stata" => ["Stata" , $stata_ver ],
"java" => ["Java" , $java_ver ],
"r" => ["R" , $R_ver ],
"octave" => ["Octave" , $octave_ver ],
# "go" => ["Go" , $go_ver ],
# "stata" => ["Stata" , $stata_ver ],
);

our @systems = qw(fortran julia python r matlab octave mathematica javascript go lua java);
our @systems = qw(c julia lua fortran java javascript matlab python mathematica r octave);
#our @systems = qw(lua);

print qq[<table class="benchmarks">\n];
print qq[<colgroup>\n];
Expand All @@ -65,11 +70,13 @@
print qq[</tr>\n];
print qq[</thead>\n];
print qq[<tbody>\n];

for my $benchmark (@benchmarks) {
print qq[<tr>];
print qq[<th>$benchmark</th>];
for my $system (@systems) {
printf qq[<td class="data">%.2f</td>], $_{$benchmark}{$system}/$_{$benchmark}{'c'};
#printf qq[<td class="data">%.3f</td>], $_{$benchmark}{$system};
}
print qq[</tr>\n];
}
Expand Down
20 changes: 10 additions & 10 deletions test/perf/micro/java/src/main/java/PerfPure.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void runBenchmarks() {
t = (System.nanoTime())-t;
if (t < tmin) tmin = t;
}
print_perf("fib", tmin);
print_perf("recursion_fibonacci", tmin);

// parse_bin
tmin = Long.MAX_VALUE;
Expand All @@ -59,7 +59,7 @@ void runBenchmarks() {
t = System.nanoTime()-t;
if (t < tmin) tmin = t;
}
print_perf("parse_int", tmin);
print_perf("parse_integers", tmin);

// mandel
int mandel_sum = 0;
Expand All @@ -71,7 +71,7 @@ void runBenchmarks() {
if (t < tmin) tmin = t;
}
assert(mandel_sum == 14720) : "value was "+mandel_sum;
print_perf("mandel", tmin);
print_perf("iteration_mandelbrot", tmin);

// sort
tmin = Long.MAX_VALUE;
Expand All @@ -86,7 +86,7 @@ void runBenchmarks() {
t = System.nanoTime()-t;
if (t < tmin) tmin = t;
}
print_perf("quicksort", tmin);
print_perf("recursion_quicksort", tmin);

// pi sum
double pi = 0;
Expand All @@ -98,7 +98,7 @@ void runBenchmarks() {
if (t < tmin) tmin = t;
}
assert(Math.abs(pi-1.644834071848065) < 1e-12);
print_perf("pi_sum", tmin);
print_perf("iteration_pi_sum", tmin);

// rand mat stat
double[] r;
Expand All @@ -109,7 +109,7 @@ void runBenchmarks() {
t = System.nanoTime()-t;
if (t < tmin) tmin = t;
}
print_perf("rand_mat_stat", tmin);
print_perf("matrix_statistics", tmin);

// rand mat mul
tmin = Long.MAX_VALUE;
Expand All @@ -120,7 +120,7 @@ void runBenchmarks() {
t = System.nanoTime()-t;
if (t < tmin) tmin = t;
}
print_perf("rand_mat_mul", tmin);
print_perf("matrix_multiply", tmin);


tmin = Long.MAX_VALUE;
Expand All @@ -130,7 +130,7 @@ void runBenchmarks() {
t = System.nanoTime()-t;
if (t < tmin) tmin = t;
}
print_perf("sinc_sum", tmin);
print_perf("iteration_sinc_sum", tmin);

// printfd
tmin = Long.MAX_VALUE;
Expand All @@ -140,7 +140,7 @@ void runBenchmarks() {
t = System.nanoTime()-t;
if (t < tmin) tmin = t;
}
print_perf("printfd", tmin);
print_perf("print_to_file", tmin);
}

void printfd(int n) {
Expand Down Expand Up @@ -330,7 +330,7 @@ protected int mandelperf() {
}

protected void print_perf(String name, long t) {
System.out.printf("javaPure,%s,%.6f\n", name, t/(double)1E6);
System.out.printf("java,%s,%.6f\n", name, t/(double)1E6);
}

protected int fib(int n) {
Expand Down
24 changes: 17 additions & 7 deletions test/perf/micro/perf.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fib = function(n) {
}

assert(fib(20) == 6765)
timeit("fib", fib, 20)
timeit("recursion_fibonacci", fib, 20)

## parse_int ##

Expand All @@ -39,7 +39,17 @@ parseintperf = function(t) {
}
}

timeit("parse_int", parseintperf, 1000)
timeit("parse_integers", parseintperf, 1000)

printfdperf = function(t) {
fd<-file("/dev/null")
for (i in 1:t) {
s = sprintf("%d %d", i, i)
writeLines(s, fd)
}
}

timeit("print_to_file", printfdperf, 100000)

## quicksort ##

Expand Down Expand Up @@ -75,7 +85,7 @@ sortperf = function(n) {
}

assert(!is.unsorted(sortperf(5000)))
timeit('quicksort', sortperf, 5000)
timeit('recursion_quicksort', sortperf, 5000)

## mandel ##

Expand Down Expand Up @@ -104,7 +114,7 @@ mandelperf = function() {
}

assert(sum(mandelperf()) == 14791)
timeit("mandel", mandelperf)
timeit("iteration_mandelbrot", mandelperf)

## pi_sum ##

Expand All @@ -120,7 +130,7 @@ pisum = function() {
}

assert(abs(pisum()-1.644834071848065) < 1e-12);
timeit("pi_sum", pisum, times=1)
timeit("iteration_pi_sum", pisum, times=1)

## pi_sum_vec ##

Expand Down Expand Up @@ -153,7 +163,7 @@ randmatstat = function(t) {
return(c(s1,s2))
}

timeit("rand_mat_stat", randmatstat, 1000)
timeit("matrix_statistics", randmatstat, 1000)

## rand_mat_mul ##

Expand All @@ -164,4 +174,4 @@ randmatmul = function(n) {
}

assert(randmatmul(1000)[1] >= 0)
timeit("rand_mat_mul", randmatmul, 1000)
timeit("matrix_multiply", randmatmul, 1000)
Loading

0 comments on commit 08dd631

Please sign in to comment.