[Swift-commit] r4190 - in SwiftApps/SwiftR/Swift: R tests
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Thu Mar 17 14:01:08 CDT 2011
Author: tga
Date: 2011-03-17 14:01:08 -0500 (Thu, 17 Mar 2011)
New Revision: 4190
Modified:
SwiftApps/SwiftR/Swift/R/TestFramework.R
SwiftApps/SwiftR/Swift/tests/param_size.R
SwiftApps/SwiftR/Swift/tests/perf_tests.R
Log:
Fixed argument size benchmark: now runs correctly and gives plottable results.
Modified: SwiftApps/SwiftR/Swift/R/TestFramework.R
===================================================================
--- SwiftApps/SwiftR/Swift/R/TestFramework.R 2011-03-17 03:31:54 UTC (rev 4189)
+++ SwiftApps/SwiftR/Swift/R/TestFramework.R 2011-03-17 19:01:08 UTC (rev 4190)
@@ -39,7 +39,7 @@
test$name = paste(fname, substring(deparse(args), 5) , sep="")
if (!is.null(prep)) {
test$fun <- f
- test$fun <- buildClosure(prep, args)
+ test$prep <- buildClosure(prep, args)
}
else {
test$fun <- buildClosure(f, args)
@@ -134,10 +134,12 @@
if (!is.null(test$prep)) {
prep <- try(test$prep())
if (inherits(res, "try-error")) {
+ print("prep failed")
group$tests[[i]]$passed <- res
group$tests[[i]]$time <- 0
}
else {
+ print("prep ran")
startTime = proc.time()[["elapsed"]]
group$tests[[i]]$passed <- try(test$fun(prep))
endTime <- proc.time()[["elapsed"]]
Modified: SwiftApps/SwiftR/Swift/tests/param_size.R
===================================================================
--- SwiftApps/SwiftR/Swift/tests/param_size.R 2011-03-17 03:31:54 UTC (rev 4189)
+++ SwiftApps/SwiftR/Swift/tests/param_size.R 2011-03-17 19:01:08 UTC (rev 4190)
@@ -4,12 +4,14 @@
cores <- 4
intsize <- 4
-param.bytes <- lapply(1:26, function (x) {list(cores, 4 * (2**x))})
+param.bytes <- lapply(1:24, function (x) {list(cores, 4 * (2**x))})
id <- function (x) {x}
test <- function (arr) {
res <- swiftLapply(arr, id)
+ length(res)
+ return (NULL)
}
makeArray <- function (procs, arr.bytes) {
#arrsize is in bytes
@@ -20,10 +22,25 @@
return(args)
}
-testGroup <- makePerfTestGroup(mode="swift", name="ArgSize",
+ts <- makeTestSuite(groups=list(
+ makePerfTestGroup(mode="swift", name="ArgSize",
f=test, prep=makeArray,
allargs=param.bytes,
- server="local", cores=cores)
+ server="local", cores=cores),
+ makePerfTestGroup(mode="swift", name="ArgSize",
+ f=test, prep=makeArray,
+ allargs=param.bytes,
+ server="ssh", cores=1, hosts="nettle wapato dandelion cattail")
+ ))
+res <- runTestSuite(ts)
-ts <- makeTestSuite(groups=list(testGroup))
-res <- runTestSuite(ts)
+anl <- mergeGroupResults(analyseSuitePerf(res,
+ argnames=c("procs", "arr.bytes"), perfparams=c('server')))
+
+
+
+loc <- subset(anl, server=="local")
+ssh <- subset(anl, server=="ssh")
+plot(x=ssh$arr.bytes, y=ssh$time, col='red', ylab="time", xlab="Argument size (bytes)")
+points(x=loc$arr.bytes, y=loc$time)
+
Modified: SwiftApps/SwiftR/Swift/tests/perf_tests.R
===================================================================
--- SwiftApps/SwiftR/Swift/tests/perf_tests.R 2011-03-17 03:31:54 UTC (rev 4189)
+++ SwiftApps/SwiftR/Swift/tests/perf_tests.R 2011-03-17 19:01:08 UTC (rev 4190)
@@ -3,6 +3,11 @@
swiftSetup <- function (...) {
+ libraries <- search()
+ if ("package:Swift" %in% libraries) {
+ library(Swift)
+ options(.swift.detach=T)
+ }
library(Swift)
swiftSess <- swiftInit(...)
# Wait to start
@@ -16,11 +21,25 @@
swiftTearDown <- function (...) {
swiftShutdown()
- detach(package:Swift)
+ dt <- getOption(".swift.detach")
+ options(.swift.detach=NULL)
+ if (!is.null(dt) && dt) {
+ detach(package:Swift)
+ }
}
sfSetup <- function(..., cpus=ncpus) {
- library(snowfall)
+ libraries <- search()
+ if (!("package:snowfall" %in% libraries)) {
+ library(snowfall)
+ options(.snowfall.detach=T)
+ }
+ # Swift needs to be detached
+ if ("package:Swift" %in% libraries) {
+ detach(package:Swift)
+ options(.swift.reattach=T)
+ }
+
sfInit(..., cpus=ncpus)
# warmup
sfLapply(rep(1, ncpus * 2),
@@ -30,7 +49,16 @@
sfTearDown <- function (...) {
sfStop()
- detach(package:snowfall)
+ dt <- getOption(".snowfall.detach")
+ options(.snowfall.detach=NULL)
+ if (!is.null(dt) && dt) {
+ detach(package:snowfall)
+ }
+ rt <- getOption(".swift.reattach")
+ options(.swift.reattach=NULL)
+ if (!is.null(rt) && rt) {
+ library(Swift)
+ }
}
More information about the Swift-commit
mailing list