首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >For Loop in Device函数on Compute Capability 1.1 Device

For Loop in Device函数on Compute Capability 1.1 Device
EN

Stack Overflow用户
提问于 2012-08-29 12:24:20
回答 1查看 386关注 0票数 1

我编写了一个使用for循环的__device__函数。它可以在GTX640卡(计算能力2.1)上运行,但不能在9500GT (计算能力1.1)上运行。

该函数大致如下:

代码语言:javascript
复制
__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设备实现相同的效果?

EN

回答 1

Stack Overflow用户

发布于 2012-09-11 11:53:10

用户试图在每个块中使用太多的线程来启动,并收到错误“请求的资源太多,无法启动”。减少每个块的线程数允许内核启动。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12170855

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档