CUDA C language compatibility

I’ve built my CUDA system, and have installed the nVidia driver, toolkit and SDK. They all work.

Now comes the C compiler. My understanding is that CUDA requires a native C compiler. Since I am using Windows Vista 64 I have installed Microsoft Visual Studio 2008.

Now I am not a C++ or C# programmer, and have no interest in learning any of that unless it is strictly required for CUDA. I am highly fluent in the original K&R and ANSI C, although I have not yet checked the C99 standard I doubt that will be a problem.

What I would like to know about CUDA is whether CUDA is “straight C” as it appears to be. If it is, then can I tell Visual Studio to limit the language to a standard C that is compatible with CUDA?

CUDA is, in a sense, a superset of C; C with a few extra keywords and macros, basically. Not too hard to learn if you’re fluent in normal C.

As for Visual Studio…I seem to remember hearing once that there is a setting that sets it from C++ to “C only” mode, but to be honest I can’t remember what it is. I really only use C/C++ for CUDA purposes these days. In any case, you shouldn’t have to change that to make it work, since nvcc is doing the kernel compilation, and will happily throw an error if you use something unsupported.

Well if you don’t remember the setting, then can I take it I don’t need to know it either? I’m not interested in using C except for CUDA myself.

You don’t need it.

You will probably want to take some time to figure out all the build paths and stuff for visual studio though. nvcc is invoked on the .cu files via a custom build rule, and you can’t just copy/paste one of the SDK projects and start from that; even the template project needs to be fooled around with a bit (last time I checked) because some of the include paths are relatively defined (so it won’t compile if you move it).

Other than that, you should be good to go.

Oh God that’s the sort of nonsense I would have liked to avoid. I suppose a simple, straightforward makefile would be too much to ask?

At the moment I am looking to develop about 200 lines of source, and I will not need to use any CUDA functions that did not occur in that simple four part introduction to CUDA I found in a link from this forum. I would guess it’s going to take me much longer to figure out a bunch of path dependencies than it will take to write, and for my CUDA box to run, this code.

It really depends. I’m not sure why, but some people seem to be up and running with CUDA very quickly, while some people have a big hassle installing it and getting it to work; either it has something to do with Windows being a bit weird with install paths, or some people (like me) are just terrible at dealing with all the build settings.

If you are good with Linux, I’d suggest developing your kernels in Linux and then just compiling them to PTX (the intermediate language that you’ll pass to the driver API to call your methods, unless you go with the .cubin route). You also get valgrind and some other stuff that helps detect any errors in the kernel.

If not…don’t fret. It really shouldn’t be too bad getting everything set up (maybe just the first time until you get used to it). There are also some Visual Studio project templates available in the XP forum, though I don’t know if they’re any good or not. I really wish nVidia would get someone who’s a Visual Studio whiz to write some official templates and intellisense stuff for it and put it in the next (after 2.3) release.

Ack. I have just fired Visual Studio as a development quagmire. I used to use Visual Fortran about ten years ago but this is nuts. I’ll tell you what I want for a C development environment:

vi

cc

make

and we’re done! I have written many tens of thousands of lines of code with just those tools.

I am good at Linux, but it’s been fifteen years since I administered Unix boxes, and I would likely be a bit of a hassle for me. I don’t have any IT support here - it’s just me. Plus I have a Windows license for Matlab, so it made sense to make the fast computer Windows.

I have found that there is a command line interface to the Visual Studio compiler, or at least there used to be one - you can invoke it at the command line as “csc.exe”.

Well, the Visual Studio installation has added things to my path, but apparently not enough to include anyplace where there is an executable called csc.

Now if I could only find where this file is. Microsoft Visual Studio installs a bunch of directories in the Program Files places, and Windows is smart enough to hide things from you unless you figure out how to trick it, so of course the File Explorer cannot find files named csc except for the wrong ones. There is no way to bludgeon Windows into letting you tell it what the “extension” of the file is. So either there is no longer a command line interface, or there is, but Windows ain’t telling where it is.

Does anyone know how to look at some part of nvcc or it’s configuration to figure out where it expects the Microsoft compiler is? Or does nvcc rely on being invoked from the C compiler?

So far I have not figured out this IDE to the point where I can successfully compile and run anything, and I am seriously wondering why I should bother. Do I have to bother if I am going to stay with Windows?

Based on this:

And this:

(Except for the Matlab part)

I’d suggest you take a look at Ubuntu Linux. Vastly simplified administration for the most part (occasionally people get into trouble, but usually it goes well), and with a few commands, you will have cc and make at your disposal.

As far as I know, a license for matlab is a license for all versions (windows, linux, mac)

Well all right, that might be the best course. I know some people on the internet who are quite current with Linux.

Here’s a couple of MSDN topics that should help you out:

“How to: Compile a Native C++ Program from the Command Line”
http://msdn.microsoft.com/en-us/library/ms…28VS.80%29.aspx

“Setting the Path and Environment Variables for Command-Line Builds”
http://msdn.microsoft.com/en-us/library/f2…28VS.80%29.aspx

ALSO: I just realized you wrote csc.exe there. That’s the C# compiler. You want cl.exe, which is the C/C++ compiler.

That seems to be true. Linux is looking more and more like the way to go. I have one application which keeps me nailed to Windows but I can live without running that on the CUDA machine.

So far I have got the trial for Jacket working, and I have also got the trial for GPUmat working. So it’s not all chewing on granite.