I am not a programmer by trade, I am a novice. So if you have examples/ideas to include, let me know I will include them here. :)
This tutorial will assume a basic knowledge of C programming (variable types, for/while loops, pointers, etc.). If you are new to C, I recommend you check out this site.
2. Intro and "Hello world" application
Re: Adventures in CUDA on Windows 7 x64
When I first started, I had many issues getting code to compile and getting CUDA setup. The runtimes are included in drivers from NVIDIA, but the CUDA SDK and toolkit needs to be downloaded.
You will need these files from the CUDA downloads page: http://developer.nvidia.com/cuda-toolkit-40
CUDA Toolkit (in 32-bit or 64-bit, if you use an express version you must use 32-bit)
CUDA Toolkit 4.0 Build Customization BUG Fix (follow instructions inside)
NVIDIA Parallel Nsight (recommended) from http://developer.nvidia.com/nvidia-parallel-nsight (you need to register)
Please note if you decide to use an express version of Visual Studio, you need to use the 32-bit CUDA Toolkit and SDK. For 64-bit, make sure you use the Full option when installing Visual Studio 2008. Furthermore, install the Windows 7 SDK from the following: http://www.microsoft.com/download/en...en&id=3138Also, make sure you follow their guide (link below) as you need the following environmental variables described below.
Hit Start, then right-click on Computer and select properties. Then click Advanced System Settings and select the Advanced tab. Hit the Environmental Variables button. Under User Variables, click New. For installation, check this PDF from NVIDIA: http://developer.download.nvidia.com...tedWindows.pdf. However, use the following variables.
Set the value to C:\Program Files (x86)\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin
Set the value to C:\Program Files (x86)\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include
Set the value to C:\Program Files (x86)\NVIDIA GPU Computing Toolkit\CUDA\v4.0\lib
I recommend using Nsight from NVIDIA (you need to register to download it). But note that it is only compatible with Visual Studio 2008 SP1 and 2010 (not Express versions). You should be able to open project files that are located in C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\src. Please be sure you open the correct file for your respective version of Visual Studio (2008 or 2010).
You can test the samples they provide which are located in the C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\bin directory.
Now I wasn't able to get Visual Studio Express versions to recognize the CUDA project type. However, with Visual Studio 2008, I do have a CUDA project option, which creates a basic project you can edit to your liking.
The sample project demonstrates how to add a kernel and it should compile and run a simple matrix addition example. I will be learning more about CUDA as I go, so I will post examples/explanations I come across as I learn them. :)
It's a lot easier to use the command prompt to compile .cu files. Compiling is quite simple really. The NVIDIA CUDA Toolkit installs the nvcc compiler linker. It's compatible with Visual Studio 8.0 and 9.0 C compilers. If you have Visual Studio 2008 SP1, you can compile a file via the following:
This should output your program in the command prompt.
Re: CUDA Guide/Tutorials
Intro and "Hello world" application
If you're new to CUDA (like I am) you should definitely check out some books. A good starter is CUDA by Example. It goes through the basics and is a good introduction. They also provide sample code from the book and it is easy to follow. You can obtain that from here. I recommend you check out the samples as they are a good introduction. I will however use my own examples and will try to attach them to the posts so you can download/compile them. Without further ado, let's begin.
Regular C code and CUDA code work together seamlessly. You can use nvcc to compile regular C programs. For example, let's take regular C code and compile with nvcc.
Compiling the helloworldgpu.cu file and running the executable, should output the same thing.
In the future we will learn more about how to handle blocks and threads per block on the GPU. Stay tuned. :)
|All times are GMT -5. The time now is 04:59 AM.|
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©1998 - 2014, nV News.