2024-11-29 15:29:45 +00:00
#include <iostream>
#include <memory>
#include <cmath>
#include <complex>
#include <device_launch_parameters.h>
#include <cuda_runtime.h>
#include <cublas_v2.h>
#include <cuComplex.h>
#include "BaseConstVariable.h"
#include "GPUTool.cuh"
#ifdef __CUDANVCC___
#define CUDAMEMORY Memory1MB*100
#define LAMP_CUDA_PI 3.141592653589793238462643383279
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
__device__ cuComplex cuCexpf(cuComplex x)
{
float factor = exp(x.x);
return make_cuComplex(factor * cos(x.y), factor * sin(x.y));
}
2024-11-30 13:07:10 +00:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
__device__ float GPU_getSigma0dB(CUDASigmaParam param,float theta) {
return param.p1 + param.p2 * exp(-param.p3 * theta) + param.p4 * cos(param.p5 * theta + param.p6);
}
__device__ CUDAVector GPU_VectorAB(CUDAVector A, CUDAVector B) {
CUDAVector C;
C.x = B.x - A.x;
C.y = B.y - A.y;
C.z = B.z - A.z;
return C;
}
__device__ float GPU_VectorNorm2(CUDAVector A) {
return sqrtf(A.x * A.x + A.y * A.y + A.z * A.z);
}
__device__ float GPU_dotVector(CUDAVector A, CUDAVector B) {
return A.x * B.x + A.y * B.y + A.z * B.z;
}
__device__ float GPU_CosAngle_VectorA_VectorB(CUDAVector A, CUDAVector B) {
return GPU_dotVector(A, B) / (GPU_VectorNorm2(A)*GPU_VectorNorm2(B));
}
__device__ CUDAVectorEllipsoidal GPU_SatelliteAntDirectNormal(float RstX, float RstY, float RstZ,
float antXaxisX, float antXaxisY, float antXaxisZ,
float antYaxisX, float antYaxisY, float antYaxisZ,
float antZaxisX, float antZaxisY, float antZaxisZ,
float antDirectX, float antDirectY, float antDirectZ
) {
CUDAVectorEllipsoidal result{0,0,-1};
float Xst = -1 * RstX; // <20> <> <EFBFBD> <EFBFBD> --> <20> <> <EFBFBD> <EFBFBD>
float Yst = -1 * RstY;
float Zst = -1 * RstZ;
float AntXaxisX = antXaxisX;
float AntXaxisY = antXaxisY;
float AntXaxisZ = antXaxisZ;
float AntYaxisX = antYaxisX;
float AntYaxisY = antYaxisY;
float AntYaxisZ = antYaxisZ;
float AntZaxisX = antZaxisX;
float AntZaxisY = antZaxisY;
float AntZaxisZ = antZaxisZ;
// <20> <> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϵ<EFBFBD> µ<EFBFBD> ֵ
float Xant = (Xst * (AntYaxisY * AntZaxisZ - AntYaxisZ * AntZaxisY) + Xst * (AntXaxisZ * AntZaxisY - AntXaxisY * AntZaxisZ) + Xst * (AntXaxisY * AntYaxisZ - AntXaxisZ * AntYaxisY)) / (AntXaxisX * (AntYaxisY * AntZaxisZ - AntZaxisY * AntYaxisZ) - AntYaxisX * (AntXaxisY * AntZaxisZ - AntXaxisZ * AntZaxisY) + AntZaxisX * (AntXaxisY * AntYaxisZ - AntXaxisZ * AntYaxisY));
float Yant = (Yst * (AntYaxisZ * AntZaxisX - AntYaxisX * AntZaxisZ) + Yst * (AntXaxisX * AntZaxisZ - AntXaxisZ * AntZaxisX) + Yst * (AntYaxisX * AntXaxisZ - AntXaxisX * AntYaxisZ)) / (AntXaxisX * (AntYaxisY * AntZaxisZ - AntZaxisY * AntYaxisZ) - AntYaxisX * (AntXaxisY * AntZaxisZ - AntXaxisZ * AntZaxisY) + AntZaxisX * (AntXaxisY * AntYaxisZ - AntXaxisZ * AntYaxisY));
float Zant = (Zst * (AntYaxisX * AntZaxisY - AntYaxisY * AntZaxisX) + Zst * (AntXaxisY * AntZaxisX - AntXaxisX * AntZaxisY) + Zst * (AntXaxisX * AntYaxisY - AntYaxisX * AntXaxisY)) / (AntXaxisX * (AntYaxisY * AntZaxisZ - AntZaxisY * AntYaxisZ) - AntYaxisX * (AntXaxisY * AntZaxisZ - AntXaxisZ * AntZaxisY) + AntZaxisX * (AntXaxisY * AntYaxisZ - AntXaxisZ * AntYaxisY));
// <20> <> <EFBFBD> <EFBFBD> theta <20> <> phi
float Norm = sqrtf(Xant * Xant + Yant * Yant + Zant * Zant); // <20> <> <EFBFBD> <EFBFBD> pho
float ThetaAnt = acosf(Zant / Norm); // theta <20> <> Z<> <5A> <EFBFBD> ļн<C4BC>
float YsinTheta = Yant / sinf(ThetaAnt);
float PhiAnt = (YsinTheta / abs(YsinTheta)) * acosf(Xant / (Norm * sinf(ThetaAnt)));
result.theta = ThetaAnt;
result.phi = PhiAnt;
result.pho = Norm;
return result;
}
/**
<EFBFBD> <EFBFBD> <EFBFBD> ߷<EFBFBD> <EFBFBD> <EFBFBD> ͼ<EFBFBD> <EFBFBD> ֵ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˫<EFBFBD> <EFBFBD> <EFBFBD> Բ<EFBFBD> ֵ<EFBFBD> 㷨Ϊ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> theta<EFBFBD> <EFBFBD> phi<EFBFBD> <EFBFBD> <EFBFBD> ϵõ<EFBFBD> <EFBFBD> ľ<EFBFBD> <EFBFBD> <EFBFBD> ͼΪ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> ͨ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ķ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡĿ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݡ<EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> theta<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> phi
*/
__device__ float GPU_BillerInterpAntPattern(float* antpattern,
float starttheta, float startphi, float dtheta, float dphi,
long thetapoints, long phipoints,
float searththeta, float searchphi) {
float stheta = searththeta;
float sphi = searchphi;
float pthetaid = (stheta - starttheta) / dtheta;//
float pphiid = (sphi - startphi) / dphi;
long lasttheta = floorf(pthetaid);
long nextTheta = lasttheta + 1;
long lastphi = floorf(pphiid);
long nextPhi = lastphi + 1;
if (lasttheta < 0 || nextTheta < 0 || lastphi < 0 || nextPhi < 0 ||
lasttheta >= thetapoints || nextTheta >= thetapoints || lastphi >= phipoints || nextPhi >= phipoints)
{
return 0;
}
else {
float x = stheta;
float y = sphi;
float x1 = lasttheta * dtheta + starttheta;
float x2 = nextTheta * dtheta + starttheta;
float y1 = lastphi * dphi + startphi;
float y2 = nextPhi * dphi + startphi;
float z11 = antpattern[lasttheta * phipoints + lastphi];
float z12 = antpattern[lasttheta * phipoints + nextPhi];
float z21 = antpattern[nextTheta * phipoints + lastphi];
float z22 = antpattern[nextTheta * phipoints + nextPhi];
z11 = powf(10, z11 / 10);
z12 = powf(10, z12 / 10);
z21 = powf(10, z21 / 10);
z22 = powf(10, z22 / 10);
float GainValue = (z11 * (x2 - x) * (y2 - y)
+ z21 * (x - x1) * (y2 - y)
+ z12 * (x2 - x) * (y - y1)
+ z22 * (x - x1) * (y - y1));
GainValue = GainValue / ((x2 - x1) * (y2 - y1));
return GainValue;
}
}
__device__ cuComplex GPU_calculationEcho(float sigma0, float TransAnt, float ReciveAnt,
float localangle, float R, float slopeangle,float Pt, float lamda ) {
float r = R;
float amp = Pt * TransAnt * ReciveAnt;
amp = amp * sigma0;
amp = amp / (powf(4 * LAMP_CUDA_PI, 2) * powf(r, 4)); // <20> <> <EFBFBD> <EFBFBD> ǿ<EFBFBD> <C7BF>
float phi = (-4 * LAMP_CUDA_PI / lamda) * r;
cuComplex echophi = make_cuComplex(0, phi);
cuComplex echophiexp = cuCexpf(echophi);
cuComplex echo;
echo.x = echophiexp.x * amp;
echo.y = echophiexp.y * amp;
return echo;
}
2024-11-29 15:29:45 +00:00
__global__ void CUDA_DistanceAB(float* Ax, float* Ay, float* Az, float* Bx, float* By, float* Bz,float *R, long len) {
long idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
R[idx] = sqrtf(powf(Ax[idx]-Bx[idx], 2) + powf(Ay[idx] - By[idx], 2) + powf(Az[idx] - Bz[idx], 2));
}
}
__global__ void CUDA_B_DistanceA(float* Ax, float* Ay, float* Az, float Bx, float By, float Bz, float* R, long len) {
long idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
R[idx] = sqrtf(powf(Ax[idx] - Bx, 2) + powf(Ay[idx] - By, 2) + powf(Az[idx] - Bz, 2));
}
}
__global__ void CUDA_make_VectorA_B(float sX, float sY, float sZ, float* tX, float* tY, float* tZ, float* RstX, float* RstY, float* RstZ, long len) {
long idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
RstX[idx] = sX - tX[idx];
RstY[idx] = sY - tY[idx];
RstZ[idx] = sZ - tZ[idx];
}
}
__global__ void CUDA_Norm_Vector(float* Vx, float* Vy, float* Vz,float *R, long len) {
long idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
R[idx] = sqrtf(powf(Vx[idx],2)+powf(Vy[idx],2)+powf(Vz[idx], 2));
}
}
__global__ void CUDA_cosAngle_VA_AB(float* Ax, float* Ay, float* Az, float* Bx, float* By, float* Bz, float* anglecos,long len) {
long idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
float tAx = Ax[idx];
float tAy = Ay[idx];
float tAz = Az[idx];
float tBx = Bx[idx];
float tBy = By[idx];
float tBz = Bz[idx];
float AR = sqrtf(powf(tAx,2) + powf(tAy,2) + powf(tAz,2));
float BR = sqrtf(powf(tBx,2) + powf(tBy,2) + powf(tBz,2));
float dotAB = tAx * tBx + tAy * tBy + tAz * tBz;
float result =acosf( dotAB / (AR * BR));
anglecos[idx] = result;
}
}
__global__ void CUDA_SatelliteAntDirectNormal(float* RstX,float* RstY,float* RstZ,
float antXaxisX,float antXaxisY,float antXaxisZ,
float antYaxisX,float antYaxisY,float antYaxisZ,
float antZaxisX,float antZaxisY,float antZaxisZ,
float antDirectX,float antDirectY,float antDirectZ,
float* thetaAnt,float* phiAnt
, long len) {
long idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
float Xst = -1*RstX[idx]; // <20> <> <EFBFBD> <EFBFBD> --> <20> <> <EFBFBD> <EFBFBD>
float Yst = -1*RstY[idx];
float Zst = -1*RstZ[idx];
float AntXaxisX=antXaxisX ;
float AntXaxisY=antXaxisY ;
float AntXaxisZ=antXaxisZ ;
float AntYaxisX=antYaxisX ;
float AntYaxisY=antYaxisY ;
float AntYaxisZ=antYaxisZ ;
float AntZaxisX=antZaxisX ;
float AntZaxisY=antZaxisY ;
float AntZaxisZ=antZaxisZ ;
// <20> <> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϵ<EFBFBD> µ<EFBFBD> ֵ
float Xant = (Xst * (AntYaxisY * AntZaxisZ - AntYaxisZ * AntZaxisY) + Xst * ( AntXaxisZ * AntZaxisY - AntXaxisY * AntZaxisZ) + Xst * ( AntXaxisY * AntYaxisZ - AntXaxisZ * AntYaxisY)) / ( AntXaxisX * ( AntYaxisY * AntZaxisZ - AntZaxisY * AntYaxisZ) - AntYaxisX * ( AntXaxisY * AntZaxisZ - AntXaxisZ * AntZaxisY) + AntZaxisX * ( AntXaxisY * AntYaxisZ - AntXaxisZ * AntYaxisY));
float Yant = (Yst * (AntYaxisZ * AntZaxisX - AntYaxisX * AntZaxisZ) + Yst * ( AntXaxisX * AntZaxisZ - AntXaxisZ * AntZaxisX) + Yst * ( AntYaxisX * AntXaxisZ - AntXaxisX * AntYaxisZ)) / ( AntXaxisX * ( AntYaxisY * AntZaxisZ - AntZaxisY * AntYaxisZ) - AntYaxisX * ( AntXaxisY * AntZaxisZ - AntXaxisZ * AntZaxisY) + AntZaxisX * ( AntXaxisY * AntYaxisZ - AntXaxisZ * AntYaxisY));
float Zant = (Zst * (AntYaxisX * AntZaxisY - AntYaxisY * AntZaxisX) + Zst * ( AntXaxisY * AntZaxisX - AntXaxisX * AntZaxisY) + Zst * ( AntXaxisX * AntYaxisY - AntYaxisX * AntXaxisY)) / ( AntXaxisX * ( AntYaxisY * AntZaxisZ - AntZaxisY * AntYaxisZ) - AntYaxisX * ( AntXaxisY * AntZaxisZ - AntXaxisZ * AntZaxisY) + AntZaxisX * ( AntXaxisY * AntYaxisZ - AntXaxisZ * AntYaxisY));
// <20> <> <EFBFBD> <EFBFBD> theta <20> <> phi
float Norm = sqrtf(Xant * Xant + Yant * Yant + Zant * Zant); // <20> <> <EFBFBD> <EFBFBD> pho
float ThetaAnt = acosf(Zant / Norm); // theta <20> <> Z<> <5A> <EFBFBD> ļн<C4BC>
float YsinTheta = Yant / sinf(ThetaAnt);
float PhiAnt = (YsinTheta/abs(YsinTheta)) * acosf( Xant / (Norm * sinf(ThetaAnt)));
thetaAnt[idx] = ThetaAnt;
phiAnt[idx] = PhiAnt;
}
}
__global__ void CUDA_calculationEcho(float* sigma0, float* TransAnt, float* ReciveAnt,
float* localangle, float* R,float* slopeangle,
float nearRange, float Fs,float Pt,float lamda,long FreqIDmax,
cuComplex* echoArr , long* FreqID,
long len) {
long idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
float r = R[idx];
float amp = Pt * TransAnt[idx] * ReciveAnt[idx];
amp= amp * sigma0[idx];
amp = amp / (powf(4* LAMP_CUDA_PI,2)*powf(r,4)); // <20> <> <EFBFBD> <EFBFBD> ǿ<EFBFBD> <C7BF>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ
float phi = (-4 * LAMP_CUDA_PI / lamda) * r;
cuComplex echophi = make_cuComplex(0, phi) ;
cuComplex echophiexp = cuCexpf(echophi);
float timeR = 2 * (r - nearRange) / LIGHTSPEED * Fs;
long timeID = floorf(timeR);
if (timeID < 0 || timeID >= FreqIDmax) {
timeID = 0;
amp = 0;
}
cuComplex echo;
echo.x = echophiexp.x * amp;
echo.y = echophiexp.y * amp;
echoArr[idx] = echo;
}
}
2024-11-30 13:07:10 +00:00
__global__ void CUDA_BillerInterpAntPattern(float* antpattern,
float starttheta, float startphi, float dtheta, float dphi,
long thetapoints, long phipoints,
float* searththeta, float* searchphi,float* searchantpattern,
long len) {
long idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
float stheta = searththeta[idx];
float sphi = searchphi[idx];
float pthetaid = (stheta - starttheta) / dtheta;//
float pphiid = (sphi - startphi) / dphi;
long lasttheta = floorf(pthetaid);
long nextTheta = lasttheta + 1;
long lastphi = floorf(pphiid);
long nextPhi = lastphi + 1;
if (lasttheta < 0 || nextTheta < 0 || lastphi < 0 || nextPhi < 0 ||
lasttheta >= thetapoints || nextTheta >= thetapoints || lastphi >= phipoints || nextPhi >= phipoints)
{
searchantpattern[idx] = 0;
}
else {
float x = stheta;
float y = sphi;
float x1 = lasttheta * dtheta + starttheta;
float x2 = nextTheta * dtheta + starttheta;
float y1 = lastphi * dphi + startphi;
float y2 = nextPhi * dphi + startphi;
float z11 = antpattern[lasttheta * phipoints + lastphi];
float z12 = antpattern[lasttheta * phipoints + nextPhi];
float z21 = antpattern[nextTheta * phipoints + lastphi];
float z22 = antpattern[nextTheta * phipoints + nextPhi];
z11 = powf(10, z11 / 10);
z12 = powf(10, z12 / 10);
z21 = powf(10, z21 / 10);
z22 = powf(10, z22 / 10);
float GainValue = (z11 * (x2 - x) * (y2 - y)
+ z21 * (x - x1) * (y2 - y)
+ z12 * (x2 - x) * (y - y1)
+ z22 * (x - x1) * (y - y1));
GainValue = GainValue / ((x2 - x1) * (y2 - y1));
searchantpattern[idx] = GainValue;
}
}
}
__global__ void CUDA_RTPC_Kernel(
float antPx, float antPy, float antPz,// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
float antXaxisX, float antXaxisY, float antXaxisZ, // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϵ
float antYaxisX, float antYaxisY, float antYaxisZ, //
float antZaxisX, float antZaxisY, float antZaxisZ,
float antDirectX, float antDirectY, float antDirectZ,// <20> <> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8>
float* demx, float* demy, float* demz, long* demcls, // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
float* demslopex, float* demslopey, float* demslopez, float* demslopeangle,// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ¶<EFBFBD>
float* Tantpattern, float Tstarttheta, float Tstartphi, float Tdtheta, float Tdphi, long Tthetapoints, long Tphipoints,// <20> <> <EFBFBD> ߷<EFBFBD> <DFB7> <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD>
float* Rantpattern, float Rstarttheta, float Rstartphi, float Rdtheta, float Rdphi, long Rthetapoints, long Rphipoints,// <20> <> <EFBFBD> ߷<EFBFBD> <DFB7> <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD>
float lamda, float fs, float nearrange, float Pt, long Freqnumbers, // <20> <> <EFBFBD> <EFBFBD>
CUDASigmaParam* sigma0Paramslist, long sigmaparamslistlen,// <20> ر<EFBFBD> <D8B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> -sigma<6D> <61> ֵ<EFBFBD> <D6B5> Ӧ<EFBFBD> <D3A6> <EFBFBD> <EFBFBD> -ulaby
cuComplex* outecho, long* d_echoAmpFID,
long len
) {
long idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
long clsid = demcls[idx];
CUDAVector Rs{ antPx,antPy,antPz };
CUDAVector Rt{ demx[idx],demy[idx],demz[idx] };
CUDAVector Rst{ Rs.x - Rt.x,Rs.y - Rt.y,Rs.z - Rt.z };
CUDAVector Vslope{ demslopex[idx],demslopey[idx],demslopez[idx] };
float R = GPU_VectorNorm2(Rst); // б <> <D0B1>
CUDAVectorEllipsoidal Rtanttheta = GPU_SatelliteAntDirectNormal( // <20> <> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߵ <EFBFBD> λ<EFBFBD> <CEBB>
Rst.x, Rst.y, Rst.z,
antXaxisX, antXaxisY, antXaxisZ,
antYaxisX, antYaxisY, antYaxisZ,
antZaxisX, antZaxisY, antZaxisZ,
antDirectX, antDirectY, antDirectZ);
float localangle=GPU_CosAngle_VectorA_VectorB(Rst, Vslope); // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
float sigma = GPU_getSigma0dB(sigma0Paramslist[clsid], localangle);
sigma = powf(10.0, sigma / 10.0);// <20> <> <EFBFBD> <EFBFBD> ɢ<EFBFBD> <C9A2> ϵ<EFBFBD> <CFB5>
// <20> <> <EFBFBD> ䷽<EFBFBD> <E4B7BD> ͼ
float transPattern = GPU_BillerInterpAntPattern(Tantpattern,
Tstarttheta, Tstartphi, Tdtheta, Tdphi,Tthetapoints, Tphipoints,
Rtanttheta.theta, Rtanttheta.phi);
// <20> <> <EFBFBD> շ<EFBFBD> <D5B7> <EFBFBD> ͼ
float receivePattern = GPU_BillerInterpAntPattern(Rantpattern,
Rstarttheta, Rstartphi, Rdtheta, Rdphi, Rthetapoints, Rphipoints,
Rtanttheta.theta, Rtanttheta.phi);
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ
float amp = Pt * transPattern * receivePattern * sigma / (powf(4 * LAMP_CUDA_PI, 2) * powf(R, 4));
float phi = (-4 * LAMP_CUDA_PI / lamda) * R;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ز<EFBFBD>
cuComplex echophi = make_cuComplex(0, phi);
cuComplex echophiexp = cuCexpf(echophi);
float timeR = 2 * (R - nearrange) / LIGHTSPEED * fs;
long timeID = floorf(timeR);
if (timeID < 0 || timeID >= Freqnumbers) {
timeID = 0;
amp = 0;
}
else {}
cuComplex echo;
echo.x = echophiexp.x * amp;
echo.y = echophiexp.y * amp;
outecho[idx] = echo;
d_echoAmpFID[idx] = timeID;
}
}
2024-11-29 15:29:45 +00:00
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʾ
void checkCudaError(cudaError_t err, const char* msg) {
if (err != cudaSuccess) {
std::cerr << "CUDA error: " << msg << " (" << cudaGetErrorString(err) << ")" << std::endl;
exit(EXIT_FAILURE);
}
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> <EFBFBD> <EFBFBD> <EFBFBD>
2024-11-30 13:07:10 +00:00
extern "C" void* mallocCUDAHost( long memsize) {
void* ptr;
2024-11-29 15:29:45 +00:00
cudaMallocHost(&ptr, memsize);
2024-11-30 13:07:10 +00:00
return ptr;
2024-11-29 15:29:45 +00:00
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> ͷ<EFBFBD>
extern "C" void FreeCUDAHost(void* ptr) {
cudaFreeHost(ptr);
}
// GPU<50> <55> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> <EFBFBD> <EFBFBD> <EFBFBD>
2024-11-30 13:07:10 +00:00
extern "C" void* mallocCUDADevice( long memsize) {
void* ptr;
2024-11-29 15:29:45 +00:00
cudaMalloc(&ptr, memsize);
2024-11-30 13:07:10 +00:00
return ptr;
2024-11-29 15:29:45 +00:00
}
// GPU<50> <55> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> ͷ<EFBFBD>
extern "C" void FreeCUDADevice(void* ptr) {
cudaFree(ptr);
}
// GPU <20> ڴ<EFBFBD> <DAB4> <EFBFBD> <EFBFBD> <EFBFBD> ת<EFBFBD> <D7AA>
extern "C" void HostToDevice(void* hostptr, void* deviceptr, long memsize) {
cudaMemcpy(deviceptr, hostptr, memsize, cudaMemcpyHostToDevice);
}
extern "C" void DeviceToHost(void* hostptr, void* deviceptr, long memsize) {
cudaMemcpy(hostptr, deviceptr, memsize, cudaMemcpyDeviceToHost);
}
extern "C" void distanceAB(float* Ax, float* Ay, float* Az, float* Bx, float* By, float* Bz, float* R,long len) {
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϳ <EFBFBD> <CDBF> ijߴ <C4B3>
int blockSize = 256; // ÿ<> <C3BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߳<EFBFBD> <DFB3> <EFBFBD>
int numBlocks = (len + blockSize - 1) / blockSize; // <20> <> <EFBFBD> <EFBFBD> pixelcount <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD>
CUDA_DistanceAB << <blockSize, numBlocks >> > ( Ax, Ay, Az, Bx, By, Bz, R, len);
}
extern "C" void BdistanceAs(float* Ax, float* Ay, float* Az, float Bx, float By, float Bz, float* R, long len) {
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϳ <EFBFBD> <CDBF> ijߴ <C4B3>
int blockSize = 256; // ÿ<> <C3BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߳<EFBFBD> <DFB3> <EFBFBD>
int numBlocks = (len + blockSize - 1) / blockSize; // <20> <> <EFBFBD> <EFBFBD> pixelcount <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD>
CUDA_B_DistanceA << <blockSize, numBlocks >> > (Ax, Ay, Az, Bx, By, Bz, R, len);
cudaDeviceSynchronize();
}
extern "C" void make_VectorA_B(float sX, float sY, float sZ, float* tX, float* tY, float* tZ, float* RstX, float* RstY, float* RstZ, long len) {
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϳ <EFBFBD> <CDBF> ijߴ <C4B3>
int blockSize = 256; // ÿ<> <C3BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߳<EFBFBD> <DFB3> <EFBFBD>
int numBlocks = (len + blockSize - 1) / blockSize; // <20> <> <EFBFBD> <EFBFBD> pixelcount <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD>
CUDA_make_VectorA_B << <blockSize, numBlocks >> > (sX, sY, sZ,tX, tY, tZ, RstX,RstY, RstZ, len);
cudaDeviceSynchronize();
}
extern "C" void Norm_Vector(float* Vx, float* Vy, float* Vz, float* R, long len) {
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϳ <EFBFBD> <CDBF> ijߴ <C4B3>
int blockSize = 256; // ÿ<> <C3BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߳<EFBFBD> <DFB3> <EFBFBD>
int numBlocks = (len + blockSize - 1) / blockSize; // <20> <> <EFBFBD> <EFBFBD> pixelcount <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD>
CUDA_Norm_Vector << <blockSize, numBlocks >> > (Vx,Vy,Vz,R, len);
cudaDeviceSynchronize();
}
extern "C" void cosAngle_VA_AB(float* Ax, float* Ay, float* Az, float* Bx, float* By, float* Bz, float* anglecos, long len) {
int blockSize = 256; // ÿ<> <C3BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߳<EFBFBD> <DFB3> <EFBFBD>
int numBlocks = (len + blockSize - 1) / blockSize; // <20> <> <EFBFBD> <EFBFBD> pixelcount <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD>
CUDA_cosAngle_VA_AB << <blockSize, numBlocks >> > (Ax, Ay, Az, Bx, By, Bz, anglecos, len);
cudaDeviceSynchronize();
}
extern "C" void SatelliteAntDirectNormal(float* RstX, float* RstY, float* RstZ,
float antXaxisX, float antXaxisY, float antXaxisZ,
float antYaxisX, float antYaxisY, float antYaxisZ,
float antZaxisX, float antZaxisY, float antZaxisZ,
float antDirectX, float antDirectY, float antDirectZ,
float* thetaAnt, float* phiAnt
, long len) {
int blockSize = 256; // ÿ<> <C3BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߳<EFBFBD> <DFB3> <EFBFBD>
int numBlocks = (len + blockSize - 1) / blockSize; // <20> <> <EFBFBD> <EFBFBD> pixelcount <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD>
CUDA_SatelliteAntDirectNormal << <blockSize, numBlocks >> > ( RstX, RstY, RstZ,
antXaxisX, antXaxisY, antXaxisZ,
antYaxisX, antYaxisY, antYaxisZ,
antZaxisX, antZaxisY, antZaxisZ,
antDirectX, antDirectY, antDirectZ,
thetaAnt, phiAnt
, len);
cudaDeviceSynchronize();
}
extern "C" void calculationEcho(float* sigma0,float* TransAnt,float* ReciveAnt,
float* localangle,float* R, float* slopeangle,
float nearRange,float Fs, float pt, float lamda, long FreqIDmax,
cuComplex* echoAmp,long* FreqID,
long len)
{
int blockSize = 256; // ÿ<> <C3BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߳<EFBFBD> <DFB3> <EFBFBD>
int numBlocks = (len + blockSize - 1) / blockSize; // <20> <> <EFBFBD> <EFBFBD> pixelcount <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD>
CUDA_calculationEcho << <blockSize, numBlocks >> > ( sigma0, TransAnt,ReciveAnt,
localangle, R, slopeangle,
nearRange, Fs, pt, lamda, FreqIDmax,
echoAmp, FreqID,
len);
cudaDeviceSynchronize();
}
2024-11-30 13:07:10 +00:00
extern "C" void CUDA_RTPC_SiglePRF(
float antPx, float antPy, float antPZ,// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
float antXaxisX, float antXaxisY, float antXaxisZ, // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϵ
float antYaxisX, float antYaxisY, float antYaxisZ, //
float antZaxisX, float antZaxisY, float antZaxisZ,
float antDirectX, float antDirectY, float antDirectZ,// <20> <> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8>
float* demx, float* demy, float* demz, long* demcls, // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
float* demslopex, float* demslopey, float* demslopez, float* demslopeangle,// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ¶<EFBFBD>
float* Tantpattern, float Tstarttheta, float Tstartphi, float Tdtheta, float Tdphi, long Tthetapoints, long Tphipoints,// <20> <> <EFBFBD> ߷<EFBFBD> <DFB7> <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD>
float* Rantpattern, float Rstarttheta, float Rstartphi, float Rdtheta, float Rdphi, long Rthetapoints, long Rphipoints,// <20> <> <EFBFBD> ߷<EFBFBD> <DFB7> <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD>
float lamda, float fs, float nearrange, float Pt, long Freqnumbers, // <20> <> <EFBFBD> <EFBFBD>
CUDASigmaParam* sigma0Paramslist, long sigmaparamslistlen,// <20> ر<EFBFBD> <D8B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> -sigma<6D> <61> ֵ<EFBFBD> <D6B5> Ӧ<EFBFBD> <D3A6> <EFBFBD> <EFBFBD> -ulaby
cuComplex* outecho, long* d_echoAmpFID,
long len
) {
int blockSize = 256; // ÿ<> <C3BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߳<EFBFBD> <DFB3> <EFBFBD>
int numBlocks = (len + blockSize - 1) / blockSize; // <20> <> <EFBFBD> <EFBFBD> pixelcount <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С
// <20> <> <EFBFBD> <EFBFBD> CUDA <20> ˺<EFBFBD> <CBBA> <EFBFBD>
CUDA_RTPC_Kernel<<<blockSize,numBlocks>>>(
antPx, antPy, antPZ,// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
antXaxisX, antXaxisY, antXaxisZ, // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϵ
antYaxisX, antYaxisY, antYaxisZ, //
antZaxisX, antZaxisY, antZaxisZ,
antDirectX, antDirectY, antDirectZ,// <20> <> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8>
demx, demy, demz, demcls, // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
demslopex, demslopey, demslopez, demslopeangle,// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ¶<EFBFBD>
Tantpattern, Tstarttheta, Tstartphi, Tdtheta, Tdphi, Tthetapoints, Tphipoints,// <20> <> <EFBFBD> ߷<EFBFBD> <DFB7> <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD>
Rantpattern, Rstarttheta, Rstartphi, Rdtheta, Rdphi, Rthetapoints, Rphipoints,// <20> <> <EFBFBD> ߷<EFBFBD> <DFB7> <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD>
lamda, fs, nearrange, Pt, Freqnumbers, // <20> <> <EFBFBD> <EFBFBD>
sigma0Paramslist, sigmaparamslistlen,// <20> ر<EFBFBD> <D8B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> -sigma<6D> <61> ֵ<EFBFBD> <D6B5> Ӧ<EFBFBD> <D3A6> <EFBFBD> <EFBFBD> -ulaby
outecho, d_echoAmpFID,
len
);
cudaDeviceSynchronize();
}
2024-11-29 15:29:45 +00:00
#endif