[問題] CUDA 光學繞射 error
大家好, 遇到了些問題想請教各位大大,
我在使用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
→
11/19 08:53, , 1F
11/19 08:53, 1F
→
11/19 10:15, , 2F
11/19 10:15, 2F
→
11/19 10:15, , 3F
11/19 10:15, 3F
→
11/19 10:16, , 4F
11/19 10:16, 4F
推
11/19 11:08, , 5F
11/19 11:08, 5F
→
11/19 11:08, , 6F
11/19 11:08, 6F
→
11/19 11:08, , 7F
11/19 11:08, 7F
→
11/19 12:10, , 8F
11/19 12:10, 8F
→
11/19 14:12, , 9F
11/19 14:12, 9F
→
11/19 14:13, , 10F
11/19 14:13, 10F
→
11/19 14:41, , 11F
11/19 14:41, 11F
→
11/19 14:42, , 12F
11/19 14:42, 12F
→
11/19 14:50, , 13F
11/19 14:50, 13F
※ 編輯: aada 來自: 140.122.193.103 (11/19 14:52)
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
1
13
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章