hi,
I am relatively new to cuda and tried some examples which work fine.
Now I have an own c++ program, where I want to export some calculations to the gpu.
Beginning with small steps I tried to compile the c++ code using nvcc without any changes for gpu implementation,
which means: I tried to compile the same code I used for the gcc compiler.
After hundreds of errors my terminal stoped and i recognized that it wont be as easy as i hoped…
Without referring to my project,
isnt it possible to use the nvcc as a normal c++ compiler without any cuda programming ? Or has it just few different syntaxes ?
And do you know some documented programming samples, where normal c++ programs got some cuda implementation ?
For starters, nvcc (more correctly nvopencc, nvcc is just a compiler driver) is officially a C compiler which supports a small subset of C++ features (mostly templating). That alone means what you are trying to do won’t work, but the are a whole slew of other reasons why the whole notion of what you are trying to do is doomed to fail.
It might be time to look at some working CUDA code (from the SDK) to get a feel for the programming model and host/device roles, and then read the documentation.
From reading other forums posts, I think avidday knows far more on this subject than I do.
I would try just giving the code the fileending .cu instead of c/cpp/whatever and see what happens. I don’t have nvcc here at the moment, but IIRC that’s been an issue for me.
There not actual need to compile your code with nvcc. Add a trivial hello world function to a hello.cu, let nvcc deal with that, and g++ with the rest, link them together.