Rmpiとsnowで 並列処理

5,225 views

Published on

Tokyo Web Mining #10での発表資料です

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,225
On SlideShare
0
From Embeds
0
Number of Embeds
1,166
Actions
Shares
0
Downloads
31
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Rmpiとsnowで 並列処理

  1. 1. Rmpi snow 2011 2 27 (@mokjpn)2011 2 27 1
  2. 2. snow2011 2 27 2
  3. 3. “R” Wiki RjpWiki2011 2 27 3
  4. 4. .....2011 2 27 4
  5. 5. ....2011 2 27 5
  6. 6. Mac, 8 .... 12 .... R CPU 100%2011 2 27 6
  7. 7. , , 50 ( 5 ) , , , ID, ,2011 2 27 7
  8. 8. 2 0.3 ( ) 1 ±90 ( )2011 2 27 8
  9. 9. (5 ) ...50 5 (5 ) 12011 2 27 9
  10. 10. (R , ...) Simple Network of Workstations: snow parLapply2011 2 27 10
  11. 11. snow ”SOCK”, “MPI”, “PVM” , Mac Leopard OpenMPI (/usr/bin/mpirun ) MPI R Rmpi2011 2 27 11
  12. 12. 50 sample 5 2 ) system.time (Mac Pro, 2.66GHz Quad-Core Xeon), 4 35.815 6.944 42.481 4 5.226 21.670 26.806 8 5.169 28.009 34.398 2 7.339 23.668 30.8542011 2 27 12
  13. 13. snow > # Rmpi snow > library(Rmpi) > library(snow) > cl <- makeCluster(4, “MPI”) > #( : )..... > stopCluster(cl)2011 2 27 13
  14. 14. all2list <- function(cl, all=fakeall, columns=c("OrderAcceptDate.D","Sex", "Age", "XFT4000", "XQM9800")) { clusterExport(cl,c("all","columns")) id <- paste("P",unique(all$PatientID),sep="") idlist <- as.list(unique(all$PatientID)) names(idlist) <- id parLapply(cl, idlist, function(x) { ctable <- all[which(all$PatientID == x), columns] return(ctable.sorted <- ctable[order(ctable$OrderAcceptDate.D),]) } ) } ※ clusterExport export (RjpWiki “R ” )2011 2 27 14
  15. 15. OrderAcceptDate.D XFT4000 XQM9800 Admission Age Sex PatientID 1 2008-11-11 NA 1.13 55 F 5664297 2 2009-09-11 0.95 0.27 61 M 2989233 3 2010-05-28 0.82 0.92 70 F 3204964 4 2007-08-27 0.21 1.01 38 F 7503779 5 2010-02-18 7.26 0.88 73 M 3090135 6 2010-02-04 0.50 3.30 63 M 7271333 $P2989233 OrderAcceptDate.D Sex Age XFT4000 Admission XQM9800 2009-01-20 M 60 1.09 0.07 2009-02-13 M 60 1.06 0.63 2009-03-03 M 60 0.91 0.27 2009-09-11 M 61 0.95 0.27 2010-05-28 M 61 0.92 0.82 2010-06-25 M 62 1.17 0.33 2010-06-29 M 62 1.10 6.94 ※ID,2011 2 27 15
  16. 16. parLapply lapply function(x) unlist vector rbind parLapply lapply # parLapply : result, : d d <- data.frame() for(n in names(result)) { if(!is.null(a <- result[[n]] )) { d <<- rbind(d,data.frame(name=n, Sex=a$Sex,Age=a$Age, XFT4000=a$XFT4000)) } }2011 2 27 16
  17. 17. Mac R , Rmpi snow parLapply lapply list unlist , $ [[ ]]2011 2 27 17
  18. 18. Rmpi , snow ,R 50 R B5 , ISBN 978-4-489-02097-1 42011 2 27 18

×