calling CUDA compiled .dll from R - .C vs .Call
<p>By following <a href="https://devblogs.nvidia.com/parallelforall/accelerate-r-applications-cuda/" rel="nofollow">this NVidia blog entry</a> I have created a CUDA function under Windows 7 x64 dll. The function is defined as follows:</p>

<pre><code>extern "C" __declspec(dllexport) void gvectorAdd(double *A, double *B, double *C, int *n)
</code></pre>

<p>I can call this successfuly from within R (v3.2.3 64bit) using the following:</p>

<pre><code>a &lt;- c(1,2,3,4)
b &lt;- c(5,6,7,8)
c &lt;- c(0,0,0,0)
n &lt;- length(c)

path.dll &lt;- "cuda_r_1.dll"
dyn.load(path.dll)

c &lt;- .C("gvectorAdd", 
        as.numeric(a), 
        as.numeric(b), 
        as.numeric(c), 
        as.integer(n),
        PACKAGE="cuda_r_1"
      )[[3]]
</code></pre>

<p>I believe that I should be using <code>.Call</code> instead of <code>.C</code>. However, when I replace <code>.C(...)</code> with <code>.Call(...)</code> in the above code the R session crashes.</p>

<p>Can someone please point me in the right direction?</p>