Reputation: 19
I have compiled my cuda project using visual studio 2010. I have countered an error stated:
student_func.cu(65): error C2059: syntax error : '<'
The line where error occurs is when the kernel function is called:
rgba_to_greyscale<<< gridSize, blockSize >>>(d_rgbaImage, d_greyImage, numRows, numCols);
and here is the code for 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());
}
Upvotes: 0
Views: 620
Reputation: 21515
Please, have first a look at this guide on how to integrate CUDA in a Visual Studio C++ project.
Also, you should organize the code so that:
__device__
functions and the kernel call in your case). However, in these files you can call CUDA APIs (for example, cudaMalloc
, cudaMemcpy
, etc.). These files are compiled by a compiler other than NVCC. As an example, suppose to have a GPU-based FDTD code. I usually do the following (Visual Studio 2010).
extern "C" void E_update(...)
function which contains the kernel <<< >>>
call;extern "C" void E_update(...)
prototype;__global__ void E_update_kernel(...)
function.Upvotes: 1