cuda 出现黑屏的现象
hwxyz 2016-12-10 10:49:00 大神们,,我找到程序问题在的地方,可是却不知道为什么会出现这样的问题,只要这一段运行第二次,或者说写成一个循环,重新计算写入共享存储器,就会出现黑屏,结果不对的的现象,是因为共享存储器分配的变量不能使用第二次么?求帮我看看是哪里出了问题,下面是这一段代码:
shared2[0][tid_in_block]=0;
__syncthreads();
shared2[1][tid_in_block]=0;
__syncthreads();
shared2[2][tid_in_block]=0;
__syncthreads();
shared2[3][tid_in_block]=0;
__syncthreads();
shared2[4][tid_in_block]=0;
__syncthreads();
shared2[5][tid_in_block]=0;
__syncthreads();
for (int j=0;j<6;j++)
{
shared2[j][tid_in_block]=2*gi[0][ii][jj]*gi[j][ii][jj];
__syncthreads();
}
offset1=1,mask1=1;
while(offset1<blockDim.x*blockDim.y)
{
if((tid_in_block&&mask1)==0)
{
for (int in=0;in<6;in++)
{
shared2[in][tid_in_block]=shared2[in][tid_in_block]+shared2[in][tid_in_block+offset1];
__syncthreads();
}
}
offset1=offset1+1;
mask1=mask1+offset1;
__syncthreads();
}
if(tid_in_block==0)
{
for (int ij=0;ij<6;ij++)
{
gigj[0][ij]=shared2[ij][0];
fgfg_check[ij+6*bid_in_grid]=gigj[0][ij];
__syncthreads();
}
}
__syncthreads();
谢谢啦!!!!