Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You cannot do this...</p> <pre><code>#include "kernel.cu" </code></pre> <p>Now you're asking the Visual Studio CPP compiler to compile the .CU file as though it was a header. You need to have a header file that declares doStuff() and include the header not the definition.</p> <p>The following might be helpful. </p> <p><a href="http://www.ademiller.com/blogs/tech/2010/12/using-cudathrust-with-the-parallel-patterns-library/" rel="nofollow">http://www.ademiller.com/blogs/tech/2010/12/using-cudathrust-with-the-parallel-patterns-library/</a></p> <p><a href="http://blog.cuvilib.com/2011/02/24/how-to-run-cuda-in-visual-studio-2010/" rel="nofollow">http://blog.cuvilib.com/2011/02/24/how-to-run-cuda-in-visual-studio-2010/</a></p> <p>Typically I set this up as two projects. One project that compiles against the the 2008 CPP compiler for .CU and another that uses the 2010 compiler to get all the C++0x features.</p> <p>The warnings your getting can be fixed by exporting the appropriate templates. Something like this but you'll have to write a specific one for each of the warning types.</p> <pre><code>#if defined(__CUDACC__) #define DECLSPECIFIER __declspec(dllexport) #define EXPIMP_TEMPLATE #else #define DECLSPECIFIER __declspec(dllimport) #define EXPIMP_TEMPLATE extern #endif EXPIMP_TEMPLATE template class DECLSPECIFIER thrust::device_vector&lt;unsigned long&gt;; </code></pre> <p>See: </p> <p><a href="http://support.microsoft.com/default.aspx?scid=KB;EN-US;168958" rel="nofollow">http://support.microsoft.com/default.aspx?scid=KB;EN-US;168958</a> and <a href="http://msdn.microsoft.com/en-us/library/esew7y1w.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/esew7y1w.aspx</a></p> <p><strong>I've written a step-by-step guide to setting up VS 2010 and CUDA 4.0 here</strong></p> <p><a href="http://www.ademiller.com/blogs/tech/2011/03/using-cuda-and-thrust-with-visual-studio-2010/" rel="nofollow">http://www.ademiller.com/blogs/tech/2011/03/using-cuda-and-thrust-with-visual-studio-2010/</a></p> <p>BTW: A better way of timing CUDA code is with the event API.</p> <pre><code>cudaEvent_t start, stop; float time; cudaEventCreate(&amp;start); cudaEventCreate(&amp;stop); cudaEventRecord( start, 0 ); kernel&lt;&lt;&lt;grid,threads&gt;&gt;&gt; ( d_odata, d_idata, size_x, size_y, NUM_REPS); cudaEventRecord( stop, 0 ); cudaEventSynchronize( stop ); cudaEventElapsedTime( &amp;time, start, stop ); cudaEventDestroy( start ); cudaEventDestroy( stop ); </code></pre>
 

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