Batch Apply Release
Pre-release
Pre-release
This release implements the proper batching of apply statements. This means you can parallelize a function by passing a vector to the grid.apply
function.
Example
In this next example, we will run a very simple function to illustrate how to use the batch apply. We will multiply a number by 2:
> a<-function(s){return(s*2)}
> library("GridR", lib.loc="/Library/Frameworks/R.framework/Versions/2.15/Resources/library")
Loading required package: codetools
> grid.init(service="bosco.direct", localTmpDir="tmp")
> grid.apply("x", a, c(1:10), batch=c(1))
In this example, we created a vector using the c(1:10)
that contains the numbers 1 to 10. Next, we call the grid.apply
function to call the function a
against every element in the vector. The grid.apply
function sends each of these function calls to a separate processor on the remote Bosco connected cluster, parallelizing the execution. After the function is complete, we can access the result in the variable x
:
> x
Grid job finished, result written to variable x
[[1]]
[1] 2
[[2]]
[1] 4
[[3]]
[1] 6
[[4]]
[1] 8
[[5]]
[1] 10
...
Fixed Issues
- Fixed CAMPUS-120 - Add proper support for Apply functionality