该部分的代码如下:
__global__ void CFAR0(float *cfar, float *real)
{
int bid = blockIdx.x + blockIdx.y*gridDim.x + blockIdx.z*gridDim.x*gridDim.y;
int tid = bid * blockDim.x * blockDim.y*blockDim.z + threadIdx.x + threadIdx.y * blockDim.x + threadIdx.z*blockDim.x*blockDim.y;
float x = tid % DistanceDim;
float y = tid / DistanceDim;
float average1 = (tex2D(texRef01, x, y - 9) + tex2D(texRef01, x, y - 10)
+ tex2D(texRef01, x, y - 11) + tex2D(texRef01, x, y - 12)
+ tex2D(texRef01, x, y - 13) + tex2D(texRef01, x, y - 14)
+ tex2D(texRef01, x, y - 15) + tex2D(texRef01, x, y - 16)
+ tex2D(texRef01, x, y - 17) + tex2D(texRef01, x, y - 18)
+ tex2D(texRef01, x, y - 19) + tex2D(texRef01, x, y - 20)
+ tex2D(texRef01, x, y - 21) + tex2D(texRef01, x, y - 22)
+ tex2D(texRef01, x, y - 23) + tex2D(texRef01, x, y - 24)) / 16;
cfar[tid] = (real[tid] >= average1 * threshold) ? real[tid] : 0;
if (cfar[tid] != 0){
float average2 = (tex2D(texRef01, x, y + 9) + tex2D(texRef01, x, y + 10)
+ tex2D(texRef01, x, y + 11) + tex2D(texRef01, x, y + 12)
+ tex2D(texRef01, x, y + 13) + tex2D(texRef01, x, y + 14)
+ tex2D(texRef01, x, y + 15) + tex2D(texRef01, x, y + 16)
+ tex2D(texRef01, x, y + 17) + tex2D(texRef01, x, y + 18)
+ tex2D(texRef01, x, y + 19) + tex2D(texRef01, x, y + 20)
+ tex2D(texRef01, x, y + 21) + tex2D(texRef01, x, y + 22)
+ tex2D(texRef01, x, y + 23) + tex2D(texRef01, x, y + 24)) / 16;
cfar[tid] = (cfar[tid] >= average2 * threshold) ? cfar[tid] : 0;
}
if (cfar[tid] != 0){
float average3 = (tex2D(texRef01, x - 9, y) + tex2D(texRef01, x - 10, y)
+ tex2D(texRef01, x - 11, y) + tex2D(texRef01, x - 12, y)
+ tex2D(texRef01, x - 13, y) + tex2D(texRef01, x - 14, y)
+ tex2D(texRef01, x - 15, y) + tex2D(texRef01, x - 16, y)
+ tex2D(texRef01, x - 17, y) + tex2D(texRef01, x - 18, y)
+ tex2D(texRef01, x - 19, y) + tex2D(texRef01, x - 20, y)
+ tex2D(texRef01, x - 21, y) + tex2D(texRef01, x - 22, y)
+ tex2D(texRef01, x - 23, y) + tex2D(texRef01, x - 24, y)) / 16;
float average4 = (tex2D(texRef01, x + 9, y) + tex2D(texRef01, x + 10, y)
+ tex2D(texRef01, x + 11, y) + tex2D(texRef01, x + 12, y)
+ tex2D(texRef01, x + 13, y) + tex2D(texRef01, x + 14, y)
+ tex2D(texRef01, x + 15, y) + tex2D(texRef01, x + 16, y)
+ tex2D(texRef01, x + 17, y) + tex2D(texRef01, x + 18, y)
+ tex2D(texRef01, x + 19, y) + tex2D(texRef01, x + 20, y)
+ tex2D(texRef01, x + 21, y) + tex2D(texRef01, x + 22, y)
+ tex2D(texRef01, x + 23, y) + tex2D(texRef01, x + 24, y)) / 16;
average3 = average3 > average4 ? average3 : average4;
cfar[tid] = (cfar[tid] >= average3 * threshold) ? cfar[tid] : 0;
}
}