How to write a basic cude program?

Hi all,

I am totally a greenhand here and with little programming experience.

After reading the programming guide and some examples, I got to understand a little about cuda however I still don’t know how to wirte a basic program like “hello world!” with cuda. Why some example have and and xx_gold.cpp while some dont, some of the codes are just testing cuda as far as I see. I got confused.

My current task is to realize the particle swarm optimization algorithm with cuda but I dont know how to get started. If someone woule like to offer some help, I will be very greatful.

Thanks in advance.


First, CUDA isn’t capable of “hello world” since it doesn’t have any output functionality itself. Of course you could write that in host code, but it’s just not CUDA.
The xx xx_kernel xx_gold is just a programming style of nVidia. Maybe it originated from early stage of nvcc development or something. I personally prefer to write everything in one big file to avoid linking problems, but that’s entirely a matter of style.
To get started, I’d suggest you implement some basic vector operations in CUDA, like adding up two big vectors.

Thank you. I will try to do something out of it.

Here you can find a CUDA hello word:
Take into account that it will only work in emulation.

Thank you xcrow