2012-08-29 3 views
1

for 루프를 사용하는 __device__ 함수를 썼습니다. GTX640 카드 (계산 기능 2.1)에서는 작동하지만 9500GT (계산 기능 1.1)에서는 작동하지 않습니다. myResults 적절한 값을 가지며, GTX460에서계산 기능 1.1 장치 기능 루프에서 For

__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; 
} 

하지만 9500GT에 그 멤버의 모든 구성 요소들은 모두 0이다 :

함수는 다음과 같이 대략이다.

컴퓨팅 기능 1.1 장치로 어떻게 동일한 효과를 얻을 수 있습니까?

+2

"9500 GT에서 작동하지 않습니다"라는 뜻입니까? SM 1.1에서 불법이 될 코드에 대해서는 구체적인 내용이 없습니다. 특히, 나는 제목에서 언급 된 재귀와 같은 행동을 보지 못한다. – harrism

+0

이제는 질문을 상당히 변경하여 모든 재귀 언급은 사라졌습니다. 그러나 당신은 컴퓨팅 1.1 장치에서 작동하지 않는 것을 말하지 않았습니다. 질문 내용을 다시 편집하여 문제의 설명을 포함 시키십시오. – talonmies

+0

나는'for' 루프를 의미했습니다. 그 죄송합니다. SM 1.1이 재귀를 지원하지 않고 용어가 섞여 있다는 것을 다른 질문에 대한 토론을 읽었습니다. 또한,'__device__' 함수는'void' 함수이고'result'는'->'연산자를 사용하여 접근됩니다. 9500GT에서,'myResults'의 모든 멤버는 (0.0, 0.0, 0.0, 0.0)입니다. 측면 질문 : 나는 w 컴포넌트가 필요하지 않더라도 float4를 사용하는 것이 float3을 사용하는 것보다 낫다고 가정 할 때 맞습니까? – user1411287

답변

2

사용자가 블록 당 너무 많은 스레드를 사용하여 실행하려고했으나 "너무 많은 리소스가 실행을 요청했습니다."라는 오류가 발생했습니다. 블록 당 스레드를 줄이면 커널이 시작될 수있었습니다.