【发布时间】:2013-06-10 23:36:45
【问题描述】:
我使用 Visual Studio 2010 编译了我的 cuda 项目。我反驳了一个错误声明:
student_func.cu(65):错误 C2059:语法错误:'
发生错误的那一行是调用内核函数的时候:
rgba_to_greyscale<<< gridSize, blockSize >>>(d_rgbaImage, d_greyImage, numRows, numCols);
这里是 student_func.cu 的代码:
#include "reference_calc.cpp"
#include "utils.h"
#include <stdio.h>
__global__
void rgba_to_greyscale(const uchar4* const rgbaImage,
unsigned char* const greyImage,
int numRows, int numCols)
{
}
void your_rgba_to_greyscale(const uchar4 * const h_rgbaImage, uchar4 * const d_rgbaImage,
unsigned char* const d_greyImage, size_t numRows, size_t numCols)
{
//You must fill in the correct sizes for the blockSize and gridSize
//currently only one block with one thread is being launched
const dim3 blockSize(1, 1, 1); //TODO
const dim3 gridSize( 1, 1, 1); //TODO
rgba_to_greyscale<<< gridSize, blockSize >>>(d_rgbaImage, d_greyImage, numRows, numCols);
cudaDeviceSynchronize(); checkCudaErrors(cudaGetLastError());
}
【问题讨论】:
-
包含此代码的文件是否具有
.cpp扩展名? -
是的,包含 main 函数的主文件...我认为的问题是项目属性中缺少一些链接,因为我有另一个项目是通过编辑 cuda 示例项目制作的,它工作正常!
-
同时注释掉这一行可以成功构建项目!
标签: visual-studio-2010 opencv cuda