作者aada (aada)
看板C_and_CPP
標題[問題] CUDA 光學繞射 error
時間Thu Nov 19 05:27:29 2009
大家好, 遇到了些問題想請教各位大大,
我在使用paper所提供的程式碼, 後來在下載他的sample code後有error,
但不知道要從什麼地方改起
這是網址,想執行上面所提供的sample code,但一直失敗
You can download the GWO library from
http://sourceforge.net/projects/thegwolibrary/
sample code 來源
http://thegwolibrary.sourceforge.net/
The system requirements of the GWO library are as follows:
(1) Operating system : Windows XP
(2) NVIDIA CUDA version : 2.0 (please download here)
(3) NVIDIA GPU (Geforce8800 higher)
The installation of the GWO library is as follows:
(1) Please place the GWO files (gwo.dll, gwo.h, gwo.lib) on your project
directory.
(2) Please register gwo.h and gwo.lib to your project.
If you have any problem or want to add a new function to the library,
please feel free to contact me.
%%%%%%%%%%%%%%%%%% SAMPLE CODE %%%%%%%%%%%%%%%%%%%%%%
Sample code using the GWO library (1)
We show a sample code in order to calculate diffraction.
#include "gwo.h"
#define WIDTH 1024
#define HEIGHT 1024
#define WIDTH2 (WIDTH*2)
#define HEIGHT2 (HEIGHT*2)
float gwo_max=0.0, gwo_min=0.0;
//gwoComplex is the complex number.
//if you use to the real part of gwoComplex, please use GWO_RE(...).
//if you use to the imaginary part of gwoComplex, please use GWO_IM(...).
gwoComplex ape_small[WIDTH*WIDTH];
gwoComplex ape[WIDTH2*HEIGHT2];
gwoComplex result[WIDTH*HEIGHT];
unsigned char pix[WIDTH*WIDTH];
void main()
{
//Prepare an aperture with 20*20 pixel.
for(int i=0;i<HEIGHT;i++)
{
for(int j=0;j<WIDTH;j++)
{
if(j>WIDTH/2-10 && j<WIDTH/2+10 && >HEIGHT/2-10 && i<HEIGHT/2+10)
{
GWO_RE(ape_small[(j)+(i)*WIDTH])=1.0;
GWO_IM(ape_small[(j)+(i)*WIDTH])=0.0;
}
}
}
//Initialize the library.
gwoInit(GWO_ANGULAR,WIDTH2,HEIGHT2); //if you calculate the Angular
spectrum
//gwoInit(GWO_FRESNEL_CONV,WIDTH2,HEIGHT2);//if you calculate the Fresnel
difraction(convolution type)
//gwoInit(GWO_SHIFTED_FRESNEL,WIDTH2,HEIGHT2);////if you calculate the
Shifted-Fresnel difraction
//Expands the original aperture (ape_small).
//The expanded aperture (ape) has double size as compared with the
original aperture.
gwoHostExpandC2C(
ape_small,WIDTH,HEIGHT,
ape,WIDTH2,HEIGHT2);
//Set the sampling spacing (4.65 um) on the aperture and the diffracted
plane.
gwoSetPitch(4.65e-6, 4.65e-6);
//Set the wavelength (633nm).
gwoSetWaveLength(633.0e-9);
//Send the expanded aperture to the GPU.
gwoSendData(ape);
//Calculate the diffraction with the propagation distance of 0.2m.
gwoCalc(0.2);
//If you need the light intensity of the diffracted light,
//please execute gwoIntensity().
//If you do not need the light intensity,
//please comment out gwoIntensity();
gwoIntensity();
//The host computer receives the calculated result (the diffracted
result).
gwoReceiveResult(ape);
//Reduce the expanded aperture (ape) to the buffer (result).
gwoHostExpandC2C(
ape,WIDTH2,HEIGHT2,
result,WIDTH,HEIGHT);
//Search the maximum and minimum value in the buffer (result).
gwoHostSearchMaxMin(result,&gwo_max,&gwo_min,WIDTH,HEIGHT);
//Convert the light intensity to 256 monochrome image.
for(int i=0;i<HEIGHT;i++)
{
for(int j=0;j<WIDTH;j++)
{
float tmp=GWO_RE(result[j+i*WIDTH]);
unsigned char c=(unsigned char)(255.0*(tmp-gwo_min)/gwo_max));
pix[j+i*WIDTH]=c;
}
}
//Finalize the library.
gwoFree();
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.122.193.103
1F:→ blackwindy:所以error是什麼? 11/19 08:53
2F:→ aada:fatal error C1010: 尋找先行編譯標頭檔指示詞時碰到未預期 11/19 10:15
3F:→ aada:的檔案結尾。您的原始檔中是否忘了加上 '#include "stdafx.h" 11/19 10:15
4F:→ aada:但是加了#include "stdafx.h"業還是有錯誤 11/19 10:16
5F:推 ledia:pch 的問題是一回事, 這裡用到的 gwo 似乎跟 link 下載到的 11/19 11:08
6F:→ ledia:版本不太合.... 11/19 11:08
7F:→ ledia:interface 長得不太一樣 11/19 11:08
8F:→ aada:interface不太一樣是什麼意思? 11/19 12:10
9F:→ TeaEEE:在專案的property pages中的Precompiled Header設定裡 選擇 11/19 14:12
10F:→ TeaEEE:Not Using Precompiled Headers看看 11/19 14:13
11F:→ aada:我試了,fatal error C1083: 無法開啟包含檔案: 'gwo.h': No 11/19 14:41
12F:→ aada:such file or directory 11/19 14:42
※ 編輯: aada 來自: 140.122.193.103 (11/19 14:52)