<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>I am actually working on a general purpose GPU library for R using Rcpp and RcppArmadillo but it is still under heavy development.  During these very early stages I have had an 'older' card (AMD Radeon HD 5700 Series) so I have been working primarily with OpenCL and the clBLAS library (which must be installed).  The idea has been to create the easiest possible (at least from my perspective) interface to leverage GPU's.  I will be receiving a newer NVIDIA card (GeForce GTX 970) so I will begin adding in CUDA as well (I fully intended to have a hybrid system similar to the arrayfire library).  <span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"></span>You can view it on my github as well: <a href="https://github.com/cdeterman/gpuR">https://github.com/cdeterman/gpuR</a> <br><br></div>As I said, keep in mind that it is still under heavy development and many more functions need to be added and it is only available for Linux at the moment.  It is designed to provide a new class structure similar to the 'Matrix' package.  You can see an example of some vector addition use on the github page but an example of matrix multiplication would be:<br><br></div># convert matrix to gpuMatrix object<br></div>gpuA <- gpuMatrix(A)<br></div>gpuB <- gpuMatrix(B)<br><br></div># matrix mutliplication<br></div>gpuC <- gpuA %*% gpuB<br><br><br></div>Also, if a user is looking in to GPGPU, they are likely dealing with 'big data' so this package is intended to be used in concert with the 'bigmemory' package as well with the 'gpuBigMatrix' function where the idea is to provide a full interface when matrices exceed local memory size (obviously would be slower but useful for those without access to expensive hardware).  There is also support for 'integer', 'float', and 'double' data types if the default R 'double' precision is not required (for an additional speed-up).<br><br></div>With my older card, and using code that could likely be optimized further, Dirk is correct that the data transfer time is very significant.  My initial benchmarks can exceed R's native BLAS (not much to celebrate) but is clearly bested by just using OpenBLAS.  Also, as Dirk mentions, as the size of the matrix increases the performance distance also shrinks until the GPU wins out.  Again, my initial benchmarks show that the gpuMatrix multiplication does eventually beat out OpenBLAS consistently once matrices begin to approaches sizes of 2048x2048.  I am optimistic however with the use of a newer card and beginning to apply some CUDA.  Once I have more functions and the CUDA interface set up I intend to have it submitted to CRAN.  I am always open to comments, concerns, and/or contributions :)<br><br></div>Regards,<br></div>Charles<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 16, 2015 at 2:58 PM, Colin Rundel <span dir="ltr"><<a href="mailto:rundel@gmail.com" target="_blank">rundel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I’ve been playing around with Rcpp and CUDA (CUBLAS and Magma in particular) for quite a while now and definitely find it useful for improving performance. My interest is mostly in spatial models and gaussian processes where the rate limiting step is usually O(n^3) matrix decomposition where n is between 1000 to 5000.</div><div><br></div><div>For these types of tasks I routinely see ~2x improvements over RcppArmadillo & OpenBLAS using a $100 consumer grade card, which isn’t huge but makes a big difference when the overall runtime is around 80 hours per model.</div><div><br></div><div>If anyone is interested in looking at some code I have the early stages of a package up on github: <a href="https://github.com/rundel/RcppGP" target="_blank">https://github.com/rundel/RcppGP</a>. In particular the gpu_mat class has a reasonably mature interface for moving data between armadillo and cuBLAS.</div><div><br></div><div>-Colin</div><div><br></div><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">-----<br><br>Colin Rundel<br>Assistant Professor of the Practice<br>Duke University, Department of Statistical Science<br><a href="http://www.stat.duke.edu/~cr173/" target="_blank">www.stat.duke.edu/~cr173/</a></div>

</div><div><div class="h5">
<br><div><blockquote type="cite"><div>On May 16, 2015, at 12:24 PM, Yue Li <<a href="mailto:gorillayue@gmail.com" target="_blank">gorillayue@gmail.com</a>> wrote:</div><br><div>Thanks for the quick insightful replies! I will look into the solutions and keep the list posted on any progress on this end.<br><br>Yue<br><br><blockquote type="cite">On May 16, 2015, at 12:10 PM, Dirk Eddelbuettel <<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>> wrote:<br><br><br>On 16 May 2015 at 17:05, Sean O'Riordain wrote:<br>| Some students I have been working with managed to get Rcpp to work with Cuda<br>| for a simple use case - calculating a big log-likelihood for MCMC - and they<br>| got a bit of a speedup compared with Rcpp - but it needs more work.  They<br>| promised they would write up a note for the gallery once their exams are over<br>| in a couple of weeks.<br><br>That is splendid news!<br><br>I better make sure I can compile with CUDA then or else building the article<br>may be tricky.<br><br>Dirk<br><br>-- <br><a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a><br></blockquote><br>_______________________________________________<br>Rcpp-devel mailing list<br><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br></div></blockquote></div><br></div></div></div><br>_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br></blockquote></div><br></div>