Skip to content

Commit 346f3bf

Browse files
committed
large refactor
1 parent d67a16c commit 346f3bf

File tree

5 files changed

+47
-116
lines changed

5 files changed

+47
-116
lines changed

DESCRIPTION

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
Package: gcbc
22
Type: Package
33
Title: 'GPU'/CPU Benchmarking in Centos Systems
4-
Version: 0.2.6
5-
Date: 2016-09-27
4+
Version: 0.1.0
5+
Date: 2020-04-15
66
Author: Dirk Eddelbuettel (Debian Version), Neal Fultz (Centos Port)
77
Maintainer: Neal Fultz <[email protected]>
88
Description: 'GPU'/CPU Benchmarking on Centos-package based systems
99
This package benchmarks performance of a few standard linear algebra
1010
operations (such as a matrix product and QR, SVD and LU decompositions)
1111
across a number of different 'BLAS' libraries as well as a 'GPU' implementation.
12-
To do so, it takes advantage of the ability to 'plug and play' different
13-
'BLAS' implementations easily on a Debian and/or Ubuntu system. The current
14-
version supports
12+
The current version supports
1513
- 'Reference BLAS' ('refblas') which are un-accelerated as a baseline
1614
- Atlas which are tuned but typically configure single-threaded
1715
- Atlas39 which are tuned and configured for multi-threaded mode
1816
- 'Goto Blas' which are accelerated and multi-threaded
1917
- 'Intel MKL' which is a commercial accelerated and multithreaded version.
2018
As for 'GPU' computing, we use the CRAN package
21-
- 'gputools'
22-
For 'Goto Blas', the 'gotoblas2-helper' script from the ISM in Tokyo can be
23-
used. For 'Intel MKL' we use the Revolution R packages from Ubuntu 9.10.
19+
- 'gpuR'
2420
License: GPL (>= 2)
2521
LazyLoad: yes
2622
Depends: R (>= 2.11.1)
27-
Imports: Matrix, DBI, RSQLite, plyr, reshape, lattice
23+
Imports: Matrix, DBI, RSQLite, plyr, reshape2, lattice
2824
Suggests: gpuR
2925
SystemRequirements: Centos or RHEL system with access to Goto Blas, Intel
3026
MKL, Atlas development build as well as a Nvidia GPU with CUDA support

NAMESPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ importFrom("DBI", "dbDriver", "dbConnect", "dbDisconnect", "dbGetQuery", "dbWrit
55
importFrom("RSQLite", "dbBuildTableDefinition")
66
importFrom("lattice", "trellis.par.get", "trellis.par.set", "xyplot", "simpleKey", "dotplot")
77
importFrom("plyr", "ddply")
8-
importFrom("reshape", "melt", "melt.data.frame")
8+
importFrom("reshape2", "melt", "melt.data.frame")
99
importFrom("Matrix", "lu")
1010

1111
export(

R/benchmark.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
# 1 / outer(i - 1, i, "+")
55
#}
66

7-
getMatrix <- function(N, type="matrix") {
7+
getMatrix <- function(N) {
88
on.exit(invisible(gc()))
99
a <- rnorm(N*N)
1010
#a <- hilbert(N)
1111
dim(a) <- c(N,N)
12-
invisible(as(a, "type"))
12+
invisible(as(a, Sys.getenv("GCBC_MATRIX_TYPE", "matrix")))
1313
}
1414

15-
matmultBenchmark <- function(N, n, trim=0.1, type="matrix") {
16-
a <- getMatrix(N, type)
15+
matmultBenchmark <- function(N, n, trim=0.1) {
16+
a <- getMatrix(N)
1717
traw <- replicate(n, system.time(crossprod(a))[3])
1818
tmean <- mean(traw,trim=trim)
1919
}

R/utilities.R

+11-83
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
11

2-
.dbfile <- "/var/tmp/gcbd.sqlite"
2+
.dbfile <- "~/gcbc.sqlite"
33

44
requirements <- function() {
55

6-
# are we on Unix ?
7-
stopifnot(.Platform$OS.type == "unix")
8-
9-
# are we on a Debian or Ubuntu system ?
10-
stopifnot(file.exists("/etc/debian_version"))
11-
12-
# reference blas as minimum standard installed ?
13-
stopifnot(file.exists("/usr/share/doc/libblas3gf/copyright"))
14-
stopifnot(file.exists("/usr/share/doc/liblapack3gf/copyright"))
15-
16-
# wajig frontend to dpkg, apt, ... ?
17-
stopifnot(file.exists("/usr/bin/wajig"))
18-
19-
# "littler" scripting frontend to R
20-
stopifnot(file.exists("/usr/bin/r"))
21-
22-
# is Goto available -- gotoblas2-help installs this
23-
stopifnot(file.exists("/etc/default/gotoblas2-helper"))
24-
256
# is database available ?
267
if ( ! file.exists(.dbfile)) {
278
createDatabase(.dbfile)
@@ -30,63 +11,14 @@ requirements <- function() {
3011
invisible(TRUE)
3112
}
3213

33-
installAtlas <- function() {
34-
res <- system("sudo apt-get -y --force-yes install libatlas3gf-base", intern=TRUE, ignore.stderr=TRUE)
35-
invisible(res)
36-
}
37-
38-
purgeAtlas <- function() {
39-
##-- old local build wajig purge libatlas-base-dev libatlas-dev libatlas3gf-amd64sse3 libatlas3gf-base
40-
res <- system("sudo apt-get -y --force-yes purge libatlas3gf-base", intern=TRUE, ignore.stderr=TRUE)
41-
invisible(res)
42-
}
43-
44-
installMKL <- function() {
45-
res <- system("sudo apt-get -y --force-yes install revolution-mkl r-revolution-revobase revolution-r", intern=TRUE, ignore.stderr=TRUE)
46-
invisible(res)
47-
}
48-
49-
purgeMKL <- function() {
50-
res <- system("sudo apt-get -y --force-yes purge revolution-mkl r-revolution-revobase revolution-r", intern=TRUE, ignore.stderr=TRUE)
51-
invisible(res)
52-
}
53-
54-
installGoto <- function() {
55-
res <- system("sudo wajig -y install /var/spool/gotoblas2-helper/archive/gotoblas2_1.13-1_amd64.deb", intern=TRUE, ignore.stderr=TRUE)
56-
invisible(res)
57-
}
58-
59-
purgeGoto <- function() {
60-
res <- system("sudo apt-get -y --force-yes purge gotoblas2", intern=TRUE, ignore.stderr=TRUE)
61-
invisible(res)
62-
}
63-
64-
installAtlas39 <- function() {
65-
res <- system("sudo wajig -y install /var/spool/atlas39/libatlas39_3.9.25-1_amd64.deb", intern=TRUE, ignore.stderr=TRUE)
66-
invisible(res)
67-
}
68-
69-
purgeAtlas39 <- function() {
70-
res <- system("sudo apt-get -y --force-yes purge libatlas39", intern=TRUE, ignore.stderr=TRUE)
71-
invisible(res)
72-
}
7314

7415
createDatabase <- function(dbfile=.dbfile) {
75-
76-
dbi <- dbDriver("SQLite")
77-
dframe <- data.frame(host="", datum="",
78-
type="", nobs=NA, nrun=NA,
79-
ref=NA, atlas=NA, atl39=NA,
80-
mkl=NA, gotob=NA, gpu=NA)
81-
dftypes <- list(host="text", datum="text", type="text",
82-
nobs="integer", nrun="integer",
83-
ref="real", atlas="real", atl39="real",
84-
mkl="real", gotob="real", gpu="real")
85-
sql <- dbBuildTableDefinition(dbi, name="benchmark", value=dframe,
86-
field.types=dftypes, row.names=FALSE)
8716
dbcon <- dbConnect(dbDriver("SQLite"), dbname=dbfile)
88-
res <- dbGetQuery(dbcon, sql)
89-
dbDisconnect(dbcon)
17+
on.exit(dbDisconnect(dbcon))
18+
dftypes <- list(host="text", datum="text", env="text", type="text",
19+
nobs="integer", nrun="integer")
20+
sql <- sqlCreateTable(dbcon, "benchmark", fields=dftypes, row.names = FALSE)
21+
dbExecute(dbcon, sql)
9022
}
9123

9224
databaseResult <- function(data,dbfile=.dbfile) {
@@ -101,20 +33,16 @@ databaseResult <- function(data,dbfile=.dbfile) {
10133
}
10234

10335
isPackageInstalled <- function(package) { # Henrik Bengtsson, r-devel, 24 Aug 2010
104-
path <- system.file(package=package)
105-
(path != "")
36+
system.file(package=package) != ""
10637
}
10738

108-
#hasMagma <- function() {
109-
# isPackageInstalled("magma")
110-
#}
11139

112-
hasGputools <- function() {
113-
isPackageInstalled("gputools")
40+
hasGpuR <- function() {
41+
isPackageInstalled("gpuR")
11442
}
11543

116-
getBenchmarkData <- function(host) {
117-
dbcon <- dbConnect(dbDriver("SQLite"), dbname=system.file("sql", "gcbd.sqlite", package="gcbd"))
44+
getBenchmarkData <- function(host, dbfile=.dbfile) {
45+
dbcon <- dbConnect(dbDriver("SQLite"), dbname=.dbfile)
11846
data <- dbGetQuery(dbcon, paste('select * from benchmark where host="',
11947
host, '" order by nobs', sep=""))
12048
invisible(dbDisconnect(dbcon))

inst/scripts/benchmark.r

+26-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/r -t
22

3-
suppressMessages(library(gcbd))
3+
suppressMessages(library(gcbc))
44
suppressMessages(library(getopt))
55

66
## default values
@@ -39,35 +39,42 @@ if (verbose) {
3939

4040
requirements()
4141

42-
purgeAtlas()
43-
purgeAtlas39()
44-
purgeMKL()
45-
purgeGoto()
46-
47-
cmd <- paste('r -lgcbd,Matrix -e"cat(', benchmark, 'Benchmark(', N, ",", n, '))"', sep="")
48-
cmdgpu <- paste('r -lgcbd,gpuR -e"cat(', benchmark, 'Benchmarkgputools(', N, ",", n, '))"', sep="")
49-
cmdtest <- paste('r -lgcbd,Matrix -e"cat(', benchmark, 'BenchmarkTEST(', N, ",", n, '))"', sep="")
42+
cmd <- paste('r -lgcbc,Matrix -e"cat(', benchmark, 'Benchmark(', N, ",", n, '))"', sep="")
43+
cmdgpu <- paste('r -lgcbc,gpuR -e"cat(', benchmark, 'Benchmarkgputools(', N, ",", n, '))"', sep="")
44+
cmdtest <- paste('r -lgcbc,Matrix -e"cat(', benchmark, 'BenchmarkTEST(', N, ",", n, '))"', sep="")
5045

5146
ref <- as.numeric(system(cmd, intern=TRUE))
5247

53-
installAtlas()
48+
##SETENV
49+
50+
# for b in lu qr svd matmult;
51+
# do
52+
# ##for n in 250 500 750 1000 1250 1500 1750 2000 2250 2500 2750 3000 3250 3500 3750 4000;
53+
# for n in 100 200 300 400 500 600 700 800 900 1000 1250 1500 1750 2000 2500 3000 3500 4000 4500 5000;
54+
# do
55+
# if [ $n -lt 1000 ]; then
56+
# r=50
57+
# elif [ $n -lt 2000 ]; then
58+
# r=30
59+
# elif [ $n -lt 3000 ]; then
60+
# r=20
61+
# elif [ $n -ge 3000 ]; then
62+
# r=5
63+
# fi
64+
# echo "Now starting $n $r $b"
65+
# ./benchmark.r -n $n -r $r -b $b -v
66+
# done
67+
# done
68+
5469
atlas <- as.numeric(system(cmd, intern=TRUE))
55-
purgeAtlas()
5670

57-
installAtlas39()
5871
atl39 <- as.numeric(system(cmd, intern=TRUE))
59-
purgeAtlas39()
6072

61-
installMKL()
6273
mkl <- as.numeric(system(cmd, intern=TRUE))
63-
purgeMKL()
6474

65-
installGoto()
6675
goto <- as.numeric(system(cmd, intern=TRUE))
67-
#magmaGoto <- ifelse( hasMagma(), as.numeric(system(cmdmagma, intern=TRUE)), NA)
68-
purgeGoto()
6976

70-
gpu <- ifelse( hasGputools(), as.numeric(system(cmdgpu, intern=TRUE)), NA)
77+
gpu <- ifelse( hasGpuR(), as.numeric(system(cmdgpu, intern=TRUE)), NA)
7178

7279
res <- data.frame(type=benchmark, nobs=N, nrun=n,
7380
ref=ref, atlas=atlas, atl39=atl39,

0 commit comments

Comments
 (0)