代码问题

[复制链接]
查看11 | 回复0 | 2011-4-5 17:03:00 | 显示全部楼层 |阅读模式
__global__ void ConvertComplexToChar(cufftComplex* d_pCTSrc, int imgPadOutWidth, int imgPadOutHeight, int imgWidth, int imgHeight, unsigned char* d_pBufIn)
{
int tx = threadIdx.x;//0-15
int ty = threadIdx.y;//0-15
int bx = blockIdx.x;
int by = blockIdx.y;
//计算每一个block需要访问的d_pCTSrc的数据起始地址
cufftComplex* d_pCTSrcPerBlock = d_pCTSrc + by * imgPadOutWidth * IMG_TILE_HEIGHT + bx * IMG_TILE_WIDTH;
//计算每一个block需要访问的d_pBufIn的数据起始地址
unsigned char* d_pBufInPerBlock = d_pBufIn + by * imgWidth * IMG_TILE_HEIGHT + bx * IMG_TILE_WIDTH;
float upperLeftReal = d_pCTSrcPerBlock[ty * imgPadOutWidth + tx].x;
float upperLeftImage = d_pCTSrcPerBlock[ty * imgPadOutWidth + tx].y;
if(bx == gridDim.x - 1 || by == gridDim.y - 1)
{
if(bx * IMG_TILE_WIDTH + tx <= imgWidth && by * IMG_TILE_HEIGHT + ty <= imgHeight)
d_pBufInPerBlock[ty * imgWidth + tx] =
(unsigned char)(sqrtf(upperLeftReal * upperLeftReal + upperLeftImage * upperLeftImage) / (imgPadOutWidth * imgPadOutHeight));
。。。
}
else
{
d_pBufInPerBlock[ty * imgWidth + tx] =
(unsigned char)sqrtf(upperLeftReal * upperLeftReal + upperLeftImage * upperLeftImage) / (imgPadOutWidth * imgPadOutHeight);
。。。
}
代码是这样的,执行到else的时候,bx,by就变成???了,执行到else里面的那个语句时,upperLeftReal 和upperLeftImage 也变成???了。。请问有人知道为什么么。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行