Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is actually no need to dynamically load a shared library linking to <em>culatools</em>. I thought about this initially, but I did not get the .cpp file using <em>Rcpp</em> compiled. Anyway, the new .cpp file is:</p> <pre><code>#include&lt;Rcpp.h&gt; #include&lt;cula.h&gt; using namespace Rcpp; using namespace std; RcppExport SEXP gpuQR_Rcpp(SEXP x_, SEXP n_rows_, SEXP n_cols_) { vector&lt;float&gt; x = as&lt;vector&lt;float&gt; &gt;(x_); int n_rows = as&lt;int&gt;(n_rows_); int n_cols = as&lt;int&gt;(n_cols_); vector&lt;float&gt; scale(n_cols); culaInitialize(); culaSgeqrf(n_rows, n_cols, &amp;(x[0]), n_rows, &amp;(scale[0])); culaShutdown(); for(int ii = 1; ii &lt; n_rows; ii++) { for(int jj = 0; jj &lt; n_cols; jj++) { if(ii &gt; jj) { x[ii + jj * n_rows] *= scale[jj]; } } } return wrap(x); } </code></pre> <p>The .cpp file is compiled using:</p> <pre><code>library(Rcpp) PKG_LIBS &lt;- sprintf('-Wl,-rpath,/usr/local/cula/lib64 -L/usr/local/cula/lib64 -lcula_lapack %s $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)', Rcpp:::RcppLdFlags()) PKG_CPPFLAGS &lt;- sprintf('-I/usr/local/cula/include %s', Rcpp:::RcppCxxFlags()) Sys.setenv(PKG_LIBS = PKG_LIBS , PKG_CPPFLAGS = PKG_CPPFLAGS) R &lt;- file.path(R.home(component = 'bin'), 'R') file &lt;- 'path/gpuQR_inc.cpp' cmd &lt;- sprintf('%s CMD SHLIB %s', R, paste(file, collapse = ' ')) system(cmd) </code></pre> <p>where I set the appropriate path to <em>culatools</em>. The whole thing does not run faster, but there is no need any longer to compile the shared library linking to <em>culatools</em> and dynamically loading it. </p> <p>I think that this is a nice alternative to the <em>gputools R</em>-package to extend <em>R</em> with <em>C++</em> and perform linear algebra operations on the GPU. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload