悠然时光 2019-01-16 16:58 采纳率: 100%
浏览 1379
已采纳

cuda核函数不执行的可能原因?

练习中遇到一个问题,核函数不执行,不知道原因?
typedef struct
{
int x;
int y;
}TstRst;

typedef struct
{
int x;
int y;
int z;
}TstDat;

device int TstDeviceFun(const int * pData1, const int * pData2)
{
return 100;
}

global void Kernel_Tst(TstRst*pRsts, const TstDat *pDats, const int nCount)
{
int i = threadIdx.x;
pRsts[i].y = 100;

return;

}
main里的相关调用如下
int nCount = 200;
TstRst*pTstRsts;
TstDat pTstDats;
TstRst*pAjustRsts = (TstRst
)malloc(nCount * sizeof(TstRst));
TstDat*pAjustDats = (TstDat*)malloc(nCount * sizeof(TstDat));
memset(pAjustRsts, 0, nCount * sizeof(TstRst));
memset(pAjustDats, 0, nCount * sizeof(TstDat));

cudaMalloc((void**)&pTstRsts, nCount * sizeof(TstRst));
cudaMemcpy(pTstRsts, pAjustRsts, nCount * sizeof(TstRst), cudaMemcpyHostToDevice);

cudaMalloc((void**)&pTstDats, nCount * sizeof(TstDat));
cudaMemcpy(pTstDats, pAjustDats, nCount * sizeof(TstDat), cudaMemcpyHostToDevice);

Kernel_Tst <<<1, 100 >>>(pTstRsts, pTstDats, 100);
cudaStatus = cudaMemcpy(pAjustRsts, pTstRsts, nStockCount * sizeof(StockCoorInfo), cudaMemcpyDeviceToHost);
cudaStatus = cudaThreadSynchronize();
  • 写回答

2条回答 默认 最新

  • 悠然时光 2019-01-17 11:27
    关注

    已解决,因为在窗口系统下,Kernel函数的执行有时间限制,Kernel函数执行时间过长而出错了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64