ループを使用する__device__
関数を作成しました。for
GTX640 カード (計算能力 2.1) では動作しますが、9500GT (計算能力 1.1) では動作しません。
関数はおおよそ次のようになります。
__device__ void myFuncD(float4 *myArray, float4 *result, uint index, uint foo, uint *here, uint *there)
{
uint j;
float4 myValue = myArray[index];
uint idxHere = here[foo];
uint idxThere = there[foo];
float4 temp;
for(j=idxHere;j<idxThere;j++){
temp = myArray[j];
//do things with myValue and temp, write result to *result
result->x += /* some calculations with myValue.x and temp.x */
result->y += /* some calculations with myValue.y and temp.y */
result->z += /* some calculations with myValue.z and temp.z */
}
}
__global__ void myKernelD(float4 *myArray, float4 *myResults, uint *here, uint *there)
{
uint index = blockDim.x*blockIdx.x+threadIdx.x;
float4 result = = make_float4(0.0f,0.0f,0.0f,0.0f);
uint foo1, foo2, foo3, foo4;
//compute foo1, foo2, foo3, foo4 based on myArray[index]
myFuncD(myArray, &result, index, foo1, here, there);
myFuncD(myArray, &result, index, foo2, here, there);
myFuncD(myArray, &result, index, foo3, here, there);
myFuncD(myArray, &result, index, foo4, here, there);
myResults[index] = result;
}
GTX460 ではmyResults
適切な値がありますが、9500GT ではそのメンバーのすべてのコンポーネントがすべてゼロです。
コンピューティング機能 1.1 デバイスで同じ効果を得るにはどうすればよいですか?