练习中遇到一个问题,核函数不执行,不知道原因?
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();