关于纹理访问的问题
texture<float, 1, cudaReadModeElementType> texfloat;
__global__void function()
{
int weight[9];
float sumweight = 0;
//calc weight[0];
...
weight0 = tex1Dfetch(texfloat, weight[0]);// ------ step 1
//calc weight[1];
...
weight1 = tex1Dfetch(texfloat, weight[1]);// ------ step 2
sumweight = weight0 + weight1; // ------ step 3
}
现在计算step1和2时,weight0和weight1返回值都正确(都为0.1~0.9),但是step3时,返回值就不正常(=0)。如果我把step3换成“sumweight=weight0”或者“sumweight=weight1”时返回sumweight也正确,就是一相加就不对。很奇怪的问题,希望大牛们赐教。