# parallel summation, using Snow; not claimed efficient, serial
# version usually faster

parsum <- function(cls,x) {
   # partition the indices of x among the cluster nodes (nothing 
   # is actually sent to them)
   parts <- clusterSplit(cls,1:length(x))
   # partition x among the nodes (again, not sent yet)
   xparts <- lapply(parts,function(part) x[part])
   # now send to the nodes and have them sum
   tmp <- clusterApply(cls,xparts,sum)
   Reduce(sum,tmp)  # implicit return()
}
