修复bug

pull/13/head
陈增辉 2025-03-24 14:03:54 +08:00
parent 4cf63eee36
commit 25057d0b62
5 changed files with 30 additions and 16 deletions

View File

@ -748,8 +748,10 @@ ErrorCode EchoL0Dataset::saveEchoArr(std::shared_ptr<std::complex<double>> echoP
}
GDALClose(rasterDataset);
rasterDataset = nullptr;
GDALDestroy();
omp_unset_lock(&lock); //
omp_destroy_lock(&lock); //
return ErrorCode::SUCCESS;
}

View File

@ -531,6 +531,7 @@ __global__ void Kernel_Computer_R_amp_NoAntPattern(
d_temp_amps[idx] = temp_amp * isNan;
d_temp_R[idx] = temp_R * isNan;
//printf("out R amp : %f %e %d %e\n", d_temp_R[idx], d_temp_amps[idx], isNan, sigma);
return;
}
}
@ -695,12 +696,11 @@ __global__ void CUDA_Kernel_RFPC(
/** ·Ö¿é´¦Àí ****************************************************************************************************************/
extern "C" void ProcessRFPCTask(RFPCTask& task, long devid)
{
size_t pixelcount = task.prfNum * task.freqNum;
size_t grid_size = (pixelcount + BLOCK_SIZE - 1) / BLOCK_SIZE;
printf("start %d,%d ,%d,%d\n", pixelcount, task.targetnum, grid_size, BLOCK_SIZE);
printf("computer pixelcount goalnum gridsize blocksize %zu,%zu ,%zu,%d\n", pixelcount, task.targetnum, grid_size, BLOCK_SIZE);
double* d_R = (double*)mallocCUDADevice(task.prfNum * SHAREMEMORY_FLOAT_HALF * sizeof(double), devid);
double* d_amps = (double*)mallocCUDADevice(task.prfNum * SHAREMEMORY_FLOAT_HALF * sizeof(double), devid);
@ -726,6 +726,9 @@ extern "C" void ProcessRFPCTask(RFPCTask& task, long devid)
d_R, d_amps// ¼ÆËãÊä³ö
);
PrintLasterError("CUDA_Kernel_Computer_R_amp");
cudaDeviceSynchronize();
cudaBlocknum = (task.prfNum * BLOCK_FREQNUM + BLOCK_SIZE - 1) / BLOCK_SIZE;
@ -737,7 +740,7 @@ extern "C" void ProcessRFPCTask(RFPCTask& task, long devid)
task.prfNum
);
PrintLasterError("CUDA_Kernel_Computer_echo");
cudaDeviceSynchronize();
if ((sTi * 100.0 / task.targetnum) - process >= 1) {
process = sTi * 100.0 / task.targetnum;
PRINT("TargetID [%f]: %d / %d finished\n", sTi * 100.0 / task.targetnum, sTi, task.targetnum);

View File

@ -87,7 +87,7 @@ extern "C" struct RFPCTask
CUDASigmaParam sigma0_cls;
long targetnum;
size_t targetnum;
};

View File

@ -1108,6 +1108,18 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU_NoAntPattern(size_t startprfid, si
}
this->SaveBlockSimulationEchoArr(task.d_echoData, prfcount, task.freqNum, startprfid);
FreeCUDADevice(task.d_echoData);
FreeCUDADevice(task.antlist);
//FreeCUDADevice(task.goallist);
return ErrorCode::SUCCESS;
}
ErrorCode RFPCProcessCls::SaveBlockSimulationEchoArr(cuComplex* d_echoData,size_t prfcount,size_t freqNum,long startprfid)
{
// 文件读写
omp_lock_t lock;
@ -1115,18 +1127,18 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU_NoAntPattern(size_t startprfid, si
omp_set_lock(&lock);
cuComplex* h_echoData = (cuComplex*)mallocCUDAHost(prfcount * task.freqNum * sizeof(cuComplex));
DeviceToHost(h_echoData, task.d_echoData, prfcount* task.freqNum * sizeof(cuComplex));
cuComplex* h_echoData = (cuComplex*)mallocCUDAHost(prfcount * freqNum * sizeof(cuComplex));
DeviceToHost(h_echoData, d_echoData, prfcount * freqNum * sizeof(cuComplex));
long prfcount_read = prfcount;
std::shared_ptr<std::complex<double>> fileEchoArr = this->EchoSimulationData->getEchoArr(startprfid, prfcount_read);
for (size_t i = 0; i < prfcount; i++) {
for (size_t j = 0; j < task.freqNum; j++) {
std::complex<double> temp = fileEchoArr.get()[i * task.freqNum + j];
fileEchoArr.get()[i * task.freqNum + j] = std::complex<double>(
temp.real() + h_echoData[i * task.freqNum + j].x,
temp.imag() + h_echoData[i * task.freqNum + j].y
for (size_t j = 0; j < freqNum; j++) {
std::complex<double> temp = fileEchoArr.get()[i * freqNum + j];
fileEchoArr.get()[i * freqNum + j] = std::complex<double>(
temp.real() + h_echoData[i * freqNum + j].x,
temp.imag() + h_echoData[i * freqNum + j].y
);
}
}
@ -1138,9 +1150,6 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU_NoAntPattern(size_t startprfid, si
omp_unset_lock(&lock); // 锟酵放伙拷斤拷
omp_destroy_lock(&lock); // 劫伙拷斤拷
FreeCUDADevice(task.d_echoData);
FreeCUDADevice(task.antlist);
//FreeCUDADevice(task.goallist);
return ErrorCode::SUCCESS;
}

View File

@ -27,7 +27,7 @@
#include "SatelliteOribtModel.h"
#include "EchoDataFormat.h"
#include "SigmaDatabase.h"
#include <cuComplex.h>
/***** 工具函数 *******************************/
@ -82,7 +82,7 @@ private: //
ErrorCode RFPCMainProcess_MultiGPU_NoAntPattern(); // 多GPU处理,不考虑天线方向图
ErrorCode RFPCMainProcess_GPU_NoAntPattern(size_t startprfid, size_t prfcount,int devId=0);
ErrorCode SaveBlockSimulationEchoArr(cuComplex* d_echoData, size_t prfcount, size_t freqNum, long startprfid);
std::shared_ptr<SatelliteOribtNode[]> getSatelliteOribtNodes(double prf_time, double dt, bool antflag, long double imageStarttime);