Programming Question

Hello everyone.
I am new to the whole CUDA idea but it is very appealing to me. I want to learn how to program in CUDA and I was wondering what C language should I learn? I am going to learn C# because I want to anyways and I was wondering if I need to learn C++ for CUDA. Any help would be greatly appreciated.

Hi,

C and C++ are similar, and C# is different.

You’ll basically be using C to program CUDA, you can use some C++ stuff, but C# is another ball game.

Maybe learning C through learning C++ will fit well for your style of learning, but you don’t need to learn C++. Speaking generally, I personally like C++ better than C, as it’s more flexible and sometimes cleaner, especially when using the very nice Boost libraries.

Okay maybe I asked the wrong question. Which programming language should I learn for CUDA?

Thanks for the quick response

Just plain 'ol C is what you need to learn.

Thank you. Are there any really good books about learning C in that case?

I know there is a very standard ‘C’ book out there but can’t think of the title at the moment. If I think of it I’ll let you know.

Also what IDE should I use? It is far easier for me to use MS than any others because I basically get it for free.

Okay sounds good

The C Programming Language, aka K&R

Buy it, read it twenty times, keep it by your bed after that. There’s no equally great book for C++ (or any other programming language, in my opinion), although Stroustrup’s C++ Programming Language is a pretty good reference (but not nearly as concise or easy to get through as K&R).

As far as IDEs go, the standard C/C++ one for Windows is Microsoft Visual C++ (part of Visual Studio). You can get a free version (Visual C++ Express), although I think you should get 2005 and not 2008 if you want to run CUDA.

Thanks for the book suggestion, do you know if they use some other IDE as the example in the book?

MS Visual C++ covers both C and C++?

I think this is what I was thinking of :)

Yes, it does. Like he said Express edition is free and 2005 works wonderfully with CUDA. I haven’t tried 2008, but I currently see no real reason to. If you haven’t dealt with linking things before then you will definitely have to learn about that. It is what I got stuck on for a good amount of time since I haven’t had to deal with it before.

You cannot use 2008 yet, as the CUDA compiler is hardcoded to use 2005. If you try 2008 you will get an error “no proper lc.exe found”

BTW -
Thinking in C++ is very good for C++. It’s not what you need to learn CUDA though.

It’s free:
http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html

This is a book from the 80s–no IDEs, just code. I’ve never liked C++ IDEs at all besides VC++ anyway, and VC++ I only like as a debugger, certainly not as an editor. I grew up with Emacs, and I will probably use it until I die. A lot of the traditional IDE features that you’d find in Eclipse or something are pretty unnecessary in C in the first place, too.

I am having problems installing Visual Studio 2005, could I download 08 and learn on that till I get back to my house this weekend and get 05 on? Or would you advise me to stay away from 08?

CUDA currently doesn’t support VS2008, but you could certainly start learning C in VS2008 just fine and switch to VS2005 once you’re able to. Getting a good foundation in C will be essential to learning CUDA, especially pointers.

Okay thats what ill do. Thanks for the help.