Hey there,
I’ve been puzzling for quite a while on how to call and run a kernel from a C++ application. Basically what i would like to have is a main.cpp looking like:
#include "simple_host.cu"
int main()
{
simpleHost();
return(0);
}
And then have a simple_host.cu file that says something like:
__global__ void simpleKernel()
{
//Perform calculation on device.
}
void simpleHost()
{
simpleKernel<<<x, y>>>();
}
The problem is, as soon as I have the main function in a separate file that gets compiled by my Visual studio compiler as a regular c++ application i run into syntax errors because now the compiler also checks the syntax of simple_host.cu even though the latter is set to use a custom build rule. Excluding simple_host.cu from the build wouldnt work. Visual studio still prints syntax errors due to the <<< for example.
Note that i set up the project correctly to use nvcc for the simple_host.cu. It actually does compile and run fine when i move the main() function into simple_host.cu and delete the main.cpp from the project. But thats not what i want to be working with.