代码修改同步远程检查

pull/3/head
陈增辉 2025-01-16 10:12:08 +08:00
parent dfe057c13c
commit 6737300246
3 changed files with 58 additions and 62 deletions

View File

@ -394,8 +394,8 @@ __global__ void CUDAKernel_RFPC_Computer_R_Gain(
double antDirectX, double antDirectY, double antDirectZ,// 天线的指向
double Pt,// 发射能量
double refPhaseRange,
double* TransAntpattern, PatternImageDesc TransAntpatternDesc,// double Transtarttheta, double Transstartphi, double Transdtheta, double Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
double* ReceiveAntpattern, PatternImageDesc ReceiveAntpatternDesc,// double Receivestarttheta, double Receivestartphi, double Receivedtheta, double Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
double* TransAntpattern, double Transtarttheta, double Transstartphi, double Transdtheta, double Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
double* ReceiveAntpattern, double Receivestarttheta, double Receivestartphi, double Receivedtheta, double Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
double NearR, double FarR, // 距离范围
CUDASigmaParam* sigma0Paramslist, long sigmaparamslistlen,// 插值图
float* outR, // 输出距离
@ -417,7 +417,7 @@ __global__ void CUDAKernel_RFPC_Computer_R_Gain(
double RstR2 = RstX * RstX + RstY * RstY + RstZ * RstZ;
double RstR = sqrt(RstR2); // 矢量距离
//printf("antX=%f;antY=%f;antZ=%f;targetX=%f;targetY=%f;targetZ=%f;RstR=%.6f;diffR=%.6f;\n",antX,antY,antZ,targetX,targetY,targetZ,RstR, RstR - 9.010858499003178e+05);
//printf("idx=%d;antX=%f;antY=%f;antZ=%f;targetX=%f;targetY=%f;targetZ=%f;RstR=%.6f;diffR=%.6f;\n", idx,antX,antY,antZ,targetX,targetY,targetZ,RstR, RstR - 9.010858499003178e+05);
if (RstR<NearR || RstR>FarR) {
outAmp[idx] = 0;
@ -444,17 +444,13 @@ __global__ void CUDAKernel_RFPC_Computer_R_Gain(
double TansantPatternGain =
GPU_BillerInterpAntPattern(
TransAntpattern,
TransAntpatternDesc.startTheta, TransAntpatternDesc.startPhi,
TransAntpatternDesc.dtheta, TransAntpatternDesc.dphi, TransAntpatternDesc.thetanum, TransAntpatternDesc.phinum,
//Transtarttheta, Transstartphi, Transdtheta, Transdphi, Transthetapoints, Transphipoints,
Transtarttheta, Transstartphi, Transdtheta, Transdphi, Transthetapoints, Transphipoints,
temptheta, tempphi);
// 接收方向图
double antPatternGain = GPU_BillerInterpAntPattern(
ReceiveAntpattern,
ReceiveAntpatternDesc.startTheta, ReceiveAntpatternDesc.startPhi,
ReceiveAntpatternDesc.dtheta, ReceiveAntpatternDesc.dphi, ReceiveAntpatternDesc.thetanum, ReceiveAntpatternDesc.phinum,
//Receivestarttheta, Receivestartphi, Receivedtheta, Receivedphi, Receivethetapoints, Receivephipoints,
Receivestarttheta, Receivestartphi, Receivedtheta, Receivedphi, Receivethetapoints, Receivephipoints,
temptheta, tempphi);
// 计算
@ -487,6 +483,7 @@ __global__ void CUDAKernel_RFPC_Computer_R_Gain(
ampGain = ampGain / (powf(4 * LAMP_CUDA_PI, 2) * powf(RstR, 4)); // 反射强度
outAmp[idx] = float(ampGain * Pt * sigma0);
outR[idx] = float(RstR - refPhaseRange);
//printf("%f-%f=%f\n", RstR , refPhaseRange, outR[idx]);
}
else {
}
@ -499,7 +496,7 @@ __global__ void CUDAKernel_RFPC_Computer_R_Gain(
__global__ void CUDAKernel_PRF_GeneratorEcho(float* Rarr, float* ampArr,
long pixelcount,
float f0, float dfreq,long freqnum,
double* echo_real,double* echo_imag, long prfid)
float* echo_real, float* echo_imag, long prfid)
{
//// 假定共享内存大小为49152 byte
//// 假定每个Block 线程数大小为 32
@ -533,10 +530,10 @@ __global__ void CUDAKernel_PRF_GeneratorEcho(float* Rarr, float* ampArr,
for (long j = 0; j < GPU_SHARE_STEP; j++) {
dataid = j * BLOCK_SIZE + tid; //
temp_phi = s_R[dataid] * factorjTemp;
temp_amp = s_Amp[dataid];
temp_amp = 1; s_Amp[dataid];
temp_real += temp_amp * cosf(temp_phi);
temp_imag += temp_amp * sinf(temp_phi);
temp_real += 1; //temp_amp* cosf(temp_phi);
temp_imag += 1;// temp_amp* sinf(temp_phi);
}
atomicAdd(&echo_real[prfid * freqnum + fid], temp_real); // 更新实部
atomicAdd(&echo_imag[prfid * freqnum + fid], temp_imag); // 更新虚部
@ -564,11 +561,11 @@ extern "C" void CUDA_RFPC_MainBlock(
double* demSlopeX, double* demSlopeY, double* demSlopeZ, // 地表坡度矢量
double Pt,// 发射能量
double refPhaseRange,
double* TransAntpattern, PatternImageDesc TransAntpatternDesc,// double Transtarttheta, double Transstartphi, double Transdtheta, double Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
double* ReceiveAntpattern, PatternImageDesc ReceiveAntpatternDesc, //double Receivestarttheta, double Receivestartphi, double Receivedtheta, double Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
double* TransAntpattern, double Transtarttheta, double Transstartphi, double Transdtheta, double Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
double* ReceiveAntpattern, double Receivestarttheta, double Receivestartphi, double Receivedtheta, double Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
double NearR, double FarR, // 距离范围
CUDASigmaParam* sigma0Paramslist, long sigmaparamslistlen,// 插值图
double* out_echoReal, double* out_echoImag,// 输出回波
float* out_echoReal, float* out_echoImag,// 输出回波
float* temp_R, float* temp_amp
//, double* temp_phi, double* temp_real, double* temp_imag// 临时变量
) {
@ -589,12 +586,10 @@ extern "C" void CUDA_RFPC_MainBlock(
antDirectX[startpid + pid], antDirectY[startpid + pid], antDirectZ[startpid + pid],
Pt,// 增益后发射能量
refPhaseRange,
TransAntpattern,
TransAntpatternDesc,
//Transtarttheta, Transstartphi, Transdtheta, Transdphi, Transthetapoints, Transphipoints,
ReceiveAntpattern,
ReceiveAntpatternDesc,
//Receivestarttheta, Receivestartphi, Receivedtheta, Receivedphi, Receivethetapoints, Receivephipoints,
TransAntpattern,
Transtarttheta, Transstartphi, Transdtheta, Transdphi, Transthetapoints, Transphipoints,
ReceiveAntpattern,
Receivestarttheta, Receivestartphi, Receivedtheta, Receivedphi, Receivethetapoints, Receivephipoints,
NearR, FarR,
sigma0Paramslist, sigmaparamslistlen,
//factorj, freqnum,
@ -602,13 +597,26 @@ extern "C" void CUDA_RFPC_MainBlock(
temp_amp
//out_echoReal, out_echoImag, pid // 输出振幅
);
#ifdef __CUDADEBUG__
cudaError_t err = cudaGetLastError();
if (err != cudaSuccess) {
printf("CUDA_RFPC_MainBlock [CUDAKernel_RFPC_Computer_R_Gain] CUDA Error [pid:%d] : %s\n", startpid + pid, cudaGetErrorString(err));
// Possibly: exit(-1) if program cannot continue....
}
#endif // __CUDADEBUG__
blocknum = (pixelcount + GPU_SHARE_STEP - 1) / GPU_SHARE_STEP;
numBlocks = (blocknum + BLOCK_SIZE - 1) / BLOCK_SIZE; // 网格数量
CUDAKernel_PRF_GeneratorEcho << <numBlocks, BLOCK_SIZE >> >
(temp_R, temp_amp, pixelcount,
f0,dfreq,freqnum,
out_echoReal, out_echoImag, pid);
#ifdef __CUDADEBUG__
err = cudaGetLastError();
if (err != cudaSuccess) {
printf("CUDA_RFPC_MainBlock [CUDAKernel_PRF_GeneratorEcho] CUDA Error [pid:%d] : %s\n", startpid+pid,cudaGetErrorString(err));
// Possibly: exit(-1) if program cannot continue....
}
#endif // __CUDADEBUG__
}
cudaDeviceSynchronize();

View File

@ -71,8 +71,8 @@ extern __global__ void CUDAKernel_RFPC_Computer_R_Gain(
double antDirectX, double antDirectY, double antDirectZ,// 天线的指向
double Pt,// 发射能量
double refPhaseRange,
double* TransAntpattern, PatternImageDesc TransAntpatternDesc, //double Transtarttheta, double Transstartphi, double Transdtheta, double Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
double* ReceiveAntpattern, PatternImageDesc ReceiveAntpatternDesc,// double Receivestarttheta, double Receivestartphi, double Receivedtheta, double Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
double* TransAntpattern, double Transtarttheta, double Transstartphi, double Transdtheta, double Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
double* ReceiveAntpattern, double Receivestarttheta, double Receivestartphi, double Receivedtheta, double Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
double NearR, double FarR, // 距离范围
CUDASigmaParam* sigma0Paramslist, long sigmaparamslistlen,// 插值图
float* outR, // 输出距离
@ -83,7 +83,7 @@ extern __global__ void CUDAKernel_RFPC_Computer_R_Gain(
extern __global__ void CUDAKernel_PRF_GeneratorEcho(float* Rarr, float* ampArr,
long pixelcount,
float f0, float dfreq, long freqnum,
double* echo_real, double* echo_imag, long prfid);
float* echo_real, float* echo_imag, long prfid);
@ -113,11 +113,11 @@ extern "C" void CUDA_RFPC_MainBlock(
double* demSlopeX, double* demSlopeY, double* demSlopeZ, // 地表坡度矢量
double Pt,// 发射能量
double refPhaseRange,
double* TransAntpattern, PatternImageDesc TransAntpatternDesc, //double Transtarttheta, double Transstartphi, double Transdtheta, double Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
double* ReceiveAntpattern, PatternImageDesc ReceiveAntpatternDesc,//double Receivestarttheta, double Receivestartphi, double Receivedtheta, double Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
double* TransAntpattern, double Transtarttheta, double Transstartphi, double Transdtheta, double Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
double* ReceiveAntpattern, double Receivestarttheta, double Receivestartphi, double Receivedtheta, double Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
double NearR, double FarR, // 距离范围
CUDASigmaParam* sigma0Paramslist, long sigmaparamslistlen,// 插值图
double* out_echoReal,double* out_echoImag,// 输出回波
float* out_echoReal, float* out_echoImag,// 输出回波
float* temp_R, float* temp_amp
//,double* temp_phi ,double* temp_real, double* tmep_imag// 临时变量
);

View File

@ -320,7 +320,7 @@ void RFPCProcessMain(long num_thread,
RFPC.setTaskSetting(task); //qDebug() << "setTaskSetting";
RFPC.setTaskFileName(simulationtaskName); //qDebug() << "setTaskFileName";
RFPC.setDEMTiffPath(demTiffPath); //qDebug() << "setDEMTiffPath";
RFPC.setDEMTiffPath(demTiffPath); //qDebug() << "setDEMTiffPath";
RFPC.setSloperPath(sloperPath); //qDebug() << "setDEMTiffPath";
RFPC.setLandCoverPath(LandCoverPath); //qDebug() << "setLandCoverPath";
RFPC.setOutEchoPath(OutEchoPath); //qDebug() << "setOutEchoPath";
qDebug() << "-------------- RFPC start---------------------------------------";
@ -470,8 +470,8 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU()
double Tdtheta = (Tmaxtheta - Tmintheta) / (Tthetanum - 1);
double Tdphi = (Tmaxphi - Tminphi) / (Tphinum - 1);
double* h_TantPattern = (double*)mallocCUDAHost(sizeof(double) * Tthetanum * Tphinum);
double* d_TantPattern = (double*)mallocCUDADevice(sizeof(double) * Tthetanum * Tphinum);
h_TantPattern = (double*)mallocCUDAHost(sizeof(double) * Tthetanum * Tphinum);
d_TantPattern = (double*)mallocCUDADevice(sizeof(double) * Tthetanum * Tphinum);
for (long i = 0; i < Tthetanum; i++) {
for (long j = Tphinum - 1; j >= 0; j--) {
@ -515,8 +515,8 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU()
double Rdtheta = (Rmaxtheta - Rmintheta) / (Rthetanum - 1);
double Rdphi = (Rmaxphi - Rminphi) / (Rphinum - 1);
double* h_RantPattern = (double*)mallocCUDAHost(sizeof(double) * Rthetanum * Rphinum);
double* d_RantPattern = (double*)mallocCUDADevice(sizeof(double) * Rthetanum * Rphinum);
h_RantPattern = (double*)mallocCUDAHost(sizeof(double) * Rthetanum * Rphinum);
d_RantPattern = (double*)mallocCUDADevice(sizeof(double) * Rthetanum * Rphinum);
for (long i = 0; i < Rthetanum; i++) {
for (long j = 0; j < Rphinum; j++) {
@ -636,10 +636,10 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU()
float* d_amp = (float*)mallocCUDADevice(sizeof(float) * blokline * tempDemCols);
double* h_PRFEcho_real = (double*)mallocCUDAHost(sizeof(double) * echoblockline * PlusePoint);
double* h_PRFEcho_imag = (double*)mallocCUDAHost(sizeof(double) * echoblockline * PlusePoint);
double* d_PRFEcho_real = (double*)mallocCUDADevice(sizeof(double) * echoblockline * PlusePoint);
double* d_PRFEcho_imag = (double*)mallocCUDADevice(sizeof(double) * echoblockline * PlusePoint);
float* h_PRFEcho_real = (float*)mallocCUDAHost(sizeof(float) * echoblockline * PlusePoint);
float* h_PRFEcho_imag = (float*)mallocCUDAHost(sizeof(float) * echoblockline * PlusePoint);
float* d_PRFEcho_real = (float*)mallocCUDADevice(sizeof(float) * echoblockline * PlusePoint);
float* d_PRFEcho_imag = (float*)mallocCUDADevice(sizeof(float) * echoblockline * PlusePoint);
double* h_factorj = (double*)mallocCUDAHost(sizeof(double) * freqlist.size());
@ -649,11 +649,6 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU()
h_freqlist[ii] = freqlist[ii];
}
double* d_factorj = (double*)mallocCUDADevice(sizeof(double) * freqlist.size());
double* d_freqlist = (double*)mallocCUDADevice(sizeof(double) * freqlist.size());
HostToDevice(h_factorj, d_factorj, (sizeof(double) * freqlist.size()));
HostToDevice(h_freqlist, d_freqlist, (sizeof(double) * freqlist.size()));
testOutAmpArr("freqlist.bin", h_freqlist, freqlist.size(), 1);
testOutAmpArr("factorj.bin", h_factorj, freqlist.size(), 1);
// 地表覆盖类型
@ -754,16 +749,11 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU()
HostToDevice((void*)h_demsloper_z, (void*)d_demsloper_z, sizeof(double) * newblokline * tempDemCols);
HostToDevice((void*)h_demcls, (void*)d_demcls, sizeof(long) * newblokline * tempDemCols);
#ifdef __PRFDEBUG__ && __PRFDEBUG_PRFINF__
printf("tatgetPs=[%f,%f,%f]\n", h_dem_x[0], h_dem_y[0], h_dem_z[0]);
std::shared_ptr<double> h_temp_R(new double[PluseCount], delArrPtr);
#endif // __PRFDEBUG__
long pixelcount = newblokline * tempDemCols;
long startprfid = 0;
for (startprfid = 0; startprfid < pluseCount; startprfid = startprfid + echoblockline) {
@ -776,8 +766,9 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU()
h_PRFEcho_imag[tempprfid * PlusePoint + freqid] = 0;// echotemp.get()[tempprfid * PlusePoint + freqid].imag();
}
}
HostToDevice(h_PRFEcho_real, d_PRFEcho_real, sizeof(double) * echoblockline * PlusePoint);
HostToDevice(h_PRFEcho_imag, d_PRFEcho_imag, sizeof(double) * echoblockline * PlusePoint);
HostToDevice(h_PRFEcho_real, d_PRFEcho_real, sizeof(float) * echoblockline * PlusePoint);
HostToDevice(h_PRFEcho_imag, d_PRFEcho_imag, sizeof(float) * echoblockline * PlusePoint);
CUDA_RFPC_MainBlock(
antpx, antpy, antpz, // 天线的坐标
@ -793,8 +784,10 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU()
d_demsloper_x, d_demsloper_y, d_demsloper_z, // 地表坡度矢量
Pt,// 增益后发射能量
refphaseRange,
d_TantPattern, TantPatternDesc,// TstartTheta, TstartPhi, Tdtheta, Tdphi, Tthetanum, Tphinum, // 发射天线方向图
d_RantPattern, RantPatternDesc,// RstartTheta, RstartPhi, Rdtheta, Rdphi, Rthetanum, Rphinum,//接收天线方向图
d_TantPattern,
TantPatternDesc.startTheta, TantPatternDesc.startPhi, TantPatternDesc.dtheta,TantPatternDesc.dphi,TantPatternDesc.thetanum,TantPatternDesc.phinum,
d_RantPattern,
RantPatternDesc.startTheta, RantPatternDesc.startPhi, RantPatternDesc.dtheta, RantPatternDesc.dphi, RantPatternDesc.thetanum, RantPatternDesc.phinum,
NearRange, FarRange,
d_clsSigmaParam, clamapid,
d_PRFEcho_real, d_PRFEcho_imag,// 输出回波
@ -802,8 +795,9 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU()
//, d_phi, d_real, d_imag// 临时变量
);
DeviceToHost(h_PRFEcho_real, d_PRFEcho_real, sizeof(double) * echoblockline * PlusePoint);
DeviceToHost(h_PRFEcho_imag, d_PRFEcho_imag, sizeof(double) * echoblockline * PlusePoint);
DeviceToHost(h_PRFEcho_real, d_PRFEcho_real, sizeof(float) * echoblockline * PlusePoint);
DeviceToHost(h_PRFEcho_imag, d_PRFEcho_imag, sizeof(float) * echoblockline * PlusePoint);
for (long tempprfid = 0; tempprfid < templine; tempprfid++) {
for (long freqid = 0; freqid < PlusePoint; freqid++) {
echotemp.get()[tempprfid * PlusePoint + freqid].real(
@ -821,12 +815,6 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU()
#endif // __PRFDEBUG__
}
std::cout << std::endl;
// 地面数据释放
@ -842,8 +830,8 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU()
FreeCUDAHost(h_amp); FreeCUDADevice(d_amp);
FreeCUDAHost(h_demcls); FreeCUDADevice(d_demcls);
FreeCUDAHost(h_factorj); FreeCUDADevice(d_factorj);
FreeCUDAHost(h_freqlist); FreeCUDADevice(d_freqlist);
FreeCUDAHost(h_factorj); //FreeCUDADevice(d_factorj);
FreeCUDAHost(h_freqlist); //FreeCUDADevice(d_freqlist);
FreeCUDAHost(h_PRFEcho_real); FreeCUDADevice(d_PRFEcho_real);
FreeCUDAHost(h_PRFEcho_imag); FreeCUDADevice(d_PRFEcho_imag);
//FreeCUDAHost(h_phi); FreeCUDADevice(d_phi);