CUDA 要怎麼產生DLL檔呢?

要怎麼產生DLL檔呢

<font =“apple-style-span”="" size=“3”>

請問你已經可以在你的電腦compile cuda的程式了嗎?

<font =“apple-style-span”="" size=“3”>
<font =“apple-style-span”="" size=“3”>如果還不行,請參考:
  1. <font =“apple-style-span”="" color="#000000" size=“3”>http://benjamin.blog.it360.tw/2011/03/27/752/
  2. <font =“apple-style-span”="" color="#000000" size=“3”>http://benjamin.blog.it360.tw/2011/03/27/767/
<font =“apple-style-span”="" size=“3”>我的做法是用<span =“apple-style-span”="" style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “>CUDA_VS_Wizard產生dll的必要檔案。
<span =“apple-style-span”=”” style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “><font =“apple-style-span”=”” size=“3”>
<span =“apple-style-span”="" style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “><font =“apple-style-span”=”” size=“3”>
<span =“apple-style-span”="" style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “><font =“apple-style-span”=”” size=“3”>
<span =“apple-style-span”="" style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “><font =“apple-style-span”=”” size=“3”>
<span =“apple-style-span”="" style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “><font =“apple-style-span”=”” size=“3”>
<font =“apple-style-span”="" face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” size=“3”><font =“apple-style-span”="" face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif”><span =“apple-style-span”="" style=“line-height: 17px; “>stdafx.h 要修改, 如果你要輸入一個整數,輸出一個1d array的單精確浮點數,就要在文件的下面<span =“apple-style-span”=”” style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “>stdafx.h<span =“apple-style-span”=”” style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “>加上以下的code
<span =“apple-style-span”=”” style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “><font =“apple-style-span”=”” size=“3”>
<font =“apple-style-span”="" face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; "><div>BOOL WINAPI Main(HINSTANCE hinstDLL,DWORD,LPVOID);</div><div>_declspec (dllexport) long CUDA_DLL_Test(int, float *);</div></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">
<font =“apple-style-span”=”” face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” size=“3”><font =“apple-style-span”="" face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif”><span =“apple-style-span”="" style=“line-height: 17px; “>所以整個<span =“apple-style-span”=”” style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “>stdafx.h<span =“apple-style-span”=”” style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “>的文件就是:
<span =“apple-style-span”=”” style=“font-family: verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif; line-height: 17px; “><font =“apple-style-span”=”” size=“3”></font></span></div><div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">// stdafx.h : include file for standard system include files,</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">// or project specific include files that are used frequently, but</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">// are changed infrequently</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">//</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; "><br></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#pragma once</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; "><br></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">// Modify the following defines if you have to target a platform prior to the ones specified below.</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">// Refer to MSDN for the latest info on corresponding values for different platforms.</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#ifndef WINVER<span ="apple-tab-span"="" style="white-space:pre"> </span>// Allow use of features specific to Windows XP or later.</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#define WINVER 0x0501<span ="apple-tab-span"="" style="white-space:pre"> </span>// Change this to the appropriate value to target other versions of Windows.</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#endif</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; "><br></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#ifndef _WIN32_WINNT<span ="apple-tab-span"="" style="white-space:pre"> </span>// Allow use of features specific to Windows XP or later. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#define _WIN32_WINNT 0x0501<span ="apple-tab-span"="" style="white-space:pre"> </span>// Change this to the appropriate value to target other versions of Windows.</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#endif<span ="apple-tab-span"="" style="white-space:pre"> </span></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; "><br></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#ifndef _WIN32_WINDOWS<span ="apple-tab-span"="" style="white-space:pre"> </span>// Allow use of features specific to Windows 98 or later.</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#endif</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; "><br></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#ifndef _WIN32_IE<span ="apple-tab-span"="" style="white-space:pre"> </span>// Allow use of features specific to IE 6.0 or later.</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#define _WIN32_IE 0x0600<span ="apple-tab-span"="" style="white-space:pre"> </span>// Change this to the appropriate value to target other versions of IE.</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#endif</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; "><br></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#define WIN32_LEAN_AND_MEAN<span ="apple-tab-span"="" style="white-space:pre"> </span>// Exclude rarely-used stuff from Windows headers</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">// Windows Header Files:</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">#include &lt;windows.h&gt;</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; "><br></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; "><br></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; "><br></span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">// TODO: reference additional headers your program requires here</span></font></div><div><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif" size="3"><span ="apple-style-span"="" style="line-height: 17px; ">BOOL WINAPI Main(HINSTANCE hinstDLL,DWORD,LPVOID);</span></font></div><div><font ="apple-style-span"="" size="3"><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif"><span ="apple-style-span"="" style="line-height: 17px; ">_declspec (dllexport) long&nbsp;</span></font><span ="apple-style-span"="" style="font-family: verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif; line-height: 17px; ">CUDA_DLL_Test</span><font ="apple-style-span"="" face="verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif"><span ="apple-style-span"="" style="line-height: 17px; ">(int, float *);</span></font></font></div></div><div><span ="apple-style-span"="" style="font-family: verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif; line-height: 17px; "><font ="apple-style-span"="" size="3">
<font =“apple-style-span”="" face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>接下來你在「sample.cu」也要寫相對應的程式:
<font =“apple-style-span”=”” face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “></span></font></div><div><span ="apple-style-span"="" style="font-family: verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif; line-height: 17px; "><font ="apple-style-span"="" size="3"><div>_declspec (dllexport) long CUDA_DLL_Test(</div><div>&nbsp; &nbsp; int int_in,&nbsp;</div><div>&nbsp; &nbsp; float *array_output)</div><div>{</div><div>&nbsp; &nbsp; ...</div><div>&nbsp; &nbsp; ...</div><div>&nbsp; &nbsp; ...</div><div><br></div><div>&nbsp; &nbsp; return 0;</div><div>}</div></font></span></div><div><span ="apple-style-span"="" style="font-family: verdana, 'bitstream vera sans', tahoma, helvetica, sans-serif; line-height: 17px; "><font ="apple-style-span"="" size="3">
<font =“apple-style-span”=”” color="#555555" face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” color="#555555" face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style=“line-height: 17px; “>
<font =“apple-style-span”=”” face=“verdana, ‘bitstream vera sans’, tahoma, helvetica, sans-serif” size=“3”><span =“apple-style-span”="" style="line-height: 17px; ">大致是這樣

感謝b大的分享!接收!

我的GTX590剛到手~~一共買了3塊,還2塊在路上XD~

等了一個月才來一片,原來上一版的GTX590有問題,超頻會出現110度以上.

拿到的是6月出廠的

我的是GTX580,Fermi的效能真的很好。

跑CUDA的效率蠻高的。

你的3塊都要裝在同一台電腦上面嗎?


可不可以說說看你的應用呢?

能用到3張GTX590的應用,好威阿…!!

打算3張插同一張主機板上,用來做最佳化運算

請問… 會使用SLI連結3張顯卡嗎?



我買的是微星的主機板,有8支PCIE2.0插槽,但沒支援3 WAY SLI.

跟之前預期的一樣,會有空間、供電跟散熱的問題,正在克服中.

SLI對CUDA不知有沒有幫助

YuLuw77740717.0189583333