0

I have a large ffdf named 'Scenarios' that I am applying a function to from the NGA package. I am already using mychunks to try and speed things up but it is still slow. Could I run it with parallel processing as well using say the Foreach package? My code at present is shown below:

PGA = (rep(NA,Nevs))
mychunks <- chunk(Scenarios)
for(myblock in mychunks){
  ScenariosINRAM <- Scenarios[myblock, ]
  PGA[seq(min(myblock), max(myblock))] <- mapply(Sa.ba,ScenariosINRAM$Magnitude,     ScenariosINRAM$Rjb, Vs30, ScenariosINRAM$Epsilon,T=0,rake=NA, U=0, SS=1, NS=0, RS=0, AB11=1)
 }

I have not had much success with Foreach, and I need to get the speed up, any help would be greatly appreciated. Thanks

user3565975
  • 75
  • 2
  • 9
  • Use mcmapply from the parallel package instead of mapply to speed up across your cores. –  Jun 04 '14 at 08:10
  • Thank you that does speed things up somewhat. – user3565975 Jun 06 '14 at 19:32
  • FYI. There are several profiling packages in R which allow to see which code take the bulk of computation. Maybe have a look also there. There are also several parallel versions of apply (mcmapply, mclapply, ...), depending on which one you use, you might be passing lots of data to the workers which is not really needed. You might want to take a look at the documentation of the parallel package for that. –  Jun 10 '14 at 21:07

0 Answers0