[Swift-commit] r4188 - in SwiftApps/SwiftR: . Swift/R Swift/tests

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Wed Mar 16 17:40:32 CDT 2011


Author: tga
Date: 2011-03-16 17:40:21 -0500 (Wed, 16 Mar 2011)
New Revision: 4188

Added:
   SwiftApps/SwiftR/Swift/tests/param_size.R
Modified:
   SwiftApps/SwiftR/IMMEDIATE-TODO
   SwiftApps/SwiftR/Swift/R/TestFramework.R
   SwiftApps/SwiftR/Swift/tests/perf_tests.R
Log:
Tests to investigate effect of parameter size on apply call duration. 


Modified: SwiftApps/SwiftR/IMMEDIATE-TODO
===================================================================
--- SwiftApps/SwiftR/IMMEDIATE-TODO	2011-03-15 04:48:23 UTC (rev 4187)
+++ SwiftApps/SwiftR/IMMEDIATE-TODO	2011-03-16 22:40:21 UTC (rev 4188)
@@ -74,10 +74,6 @@
 * restart batch jobs automatically if time runs out
 
 MID:
-* Fast branch: working? faster?
-    (* NOTE: wait until updates: fast branch afflicted by deadlocks *)
-
-MID:
 Implement omxXXX parallel calls, update openmx code
 
 MID:
@@ -163,3 +159,7 @@
 MID:
 - startup notes from Tim Bates
  -- rlib rpackage sugg   
+
+MID:
+* Fast branch: working? faster?
+    - DONE

Modified: SwiftApps/SwiftR/Swift/R/TestFramework.R
===================================================================
--- SwiftApps/SwiftR/Swift/R/TestFramework.R	2011-03-15 04:48:23 UTC (rev 4187)
+++ SwiftApps/SwiftR/Swift/R/TestFramework.R	2011-03-16 22:40:21 UTC (rev 4188)
@@ -1,9 +1,10 @@
 # Generic functions for running and displaying results
 # from a suite of tests
 
-mkTest <- function (f) {
+mkTest <- function (f, prep=NULL) {
     test = list()
     test$name = deparse(substitute(f))
+    test$prep = prep
     test$fun = f
     test$passed = NULL
     test$time <- NULL
@@ -20,7 +21,8 @@
 }
 
 makeParamTestGroup <- function (name, f, allargs,
-                setup=NULL, teardown=NULL, perfparams=NULL) {
+                setup=NULL, teardown=NULL, perfparams=NULL,
+                prep=NULL) {
 
 
     buildClosure <- function (f, args) {
@@ -35,7 +37,14 @@
         test = list()
         args <- as.list(args)
         test$name = paste(fname, substring(deparse(args), 5) , sep="") 
-        test$fun <- buildClosure(f, args)
+        if (!is.null(prep)) {
+            test$fun <- f
+            test$fun <- buildClosure(prep, args)
+        }
+        else {
+            test$fun <- buildClosure(f, args)
+        }
+        
         test$args <- args # Store for later analysis
         test$passed <- NULL
         test$time <- NULL
@@ -122,11 +131,27 @@
     for (i in 1:length(group$tests)) {
         test <- group$tests[[i]]
         cat("\n== Starting test ", test$name, " ==\n")
-        startTime = proc.time()[["elapsed"]]
-        group$tests[[i]]$passed <- try(test$fun())
-        endTime <- proc.time()[["elapsed"]]
-        runTime <- endTime - startTime
-        group$tests[[i]]$time <- runTime
+        if (!is.null(test$prep)) {
+            prep <- try(test$prep())
+            if (inherits(res, "try-error")) {
+                group$tests[[i]]$passed <- res
+                group$tests[[i]]$time <- 0
+            }
+            else {
+                startTime = proc.time()[["elapsed"]]
+                group$tests[[i]]$passed <- try(test$fun(prep))
+                endTime <- proc.time()[["elapsed"]]
+                runTime <- endTime - startTime
+                group$tests[[i]]$time <- runTime
+            }
+        }
+        else {
+            startTime = proc.time()[["elapsed"]]
+            group$tests[[i]]$passed <- try(test$fun())
+            endTime <- proc.time()[["elapsed"]]
+            runTime <- endTime - startTime
+            group$tests[[i]]$time <- runTime
+        }
         
     }
     if (!is.null(group$teardown))

Added: SwiftApps/SwiftR/Swift/tests/param_size.R
===================================================================
--- SwiftApps/SwiftR/Swift/tests/param_size.R	                        (rev 0)
+++ SwiftApps/SwiftR/Swift/tests/param_size.R	2011-03-16 22:40:21 UTC (rev 4188)
@@ -0,0 +1,29 @@
+require(Swift)
+source("Swift/tests/perf_tests.R")
+
+cores <- 4
+intsize <- 4
+
+param.bytes <- lapply(1:26, function (x) {list(cores, 4 * (2**x))})
+
+id <- function (x) {x}
+
+test <- function (arr) {
+    res <- swiftLapply(arr, id)
+}
+makeArray <- function (procs, arr.bytes) {
+    #arrsize is in bytes
+    args <- list()
+    for (i in 1:procs) {
+        args[[i]] <- as.vector(sample(1:1000, arr.bytes/intsize, replace=T), "integer")
+    }
+    return(args)
+}
+
+testGroup <- makePerfTestGroup(mode="swift", name="ArgSize", 
+                f=test, prep=makeArray, 
+                allargs=param.bytes,
+                server="local", cores=cores)
+
+ts <- makeTestSuite(groups=list(testGroup))
+res <- runTestSuite(ts)

Modified: SwiftApps/SwiftR/Swift/tests/perf_tests.R
===================================================================
--- SwiftApps/SwiftR/Swift/tests/perf_tests.R	2011-03-15 04:48:23 UTC (rev 4187)
+++ SwiftApps/SwiftR/Swift/tests/perf_tests.R	2011-03-16 22:40:21 UTC (rev 4188)
@@ -35,7 +35,7 @@
 
 
 
-makePerfTestGroup <- function (mode, name, f, allargs, ...) {
+makePerfTestGroup <- function (mode, name, f, allargs, prep=NULL, ...) {
     params <- list(...)
     paramstr <- paste(names(params),
                 rep("=", length(params)), 
@@ -43,7 +43,7 @@
                 sep="", collapse=", ")
     if (mode == "swift") {
         tg <- makeParamTestGroup(name=paste("swift_",name, " ", paramstr,sep=""),
-            f=f,
+            f=f, prep=prep,
             allargs=allargs,
             perfparams = params,
             setup=function() {swiftSetup(...)},
@@ -51,7 +51,7 @@
     }
     else if (mode == "snowfall") {
         tg <- makeParamTestGroup(name=paste("sf_",name, paramstr, sep=""),
-            f=f,
+            f=f,prep=prep,
             allargs=allargs,
             perfparams = params,
             setup=function() {sfSetup(...)},
@@ -61,7 +61,7 @@
     else {
         print("Making serial test")
         tg <- makeParamTestGroup(name=paste("serial_",name, paramstr, sep=""),
-            f=f,
+            f=f,prep=prep,
             allargs=allargs,
             perfparams = list(),
             setup=function() 




More information about the Swift-commit mailing list