Time for my first CUDA 'Hello World' program. Well, there won't be any GPU processing in it, but at least I'll prove that my environment is fully operational. Let's get to work!
I'll start by creating new Win32 Console Application (selecting 'Empty Project' option). Although it is a Visual C++ project, I will try to stick to C as I simply feel more confident using this language and don't want the OOP getting in my way.
First of all, since I use 64-bit windows, I changed my program to target the x64 platform.
Next, I selected CUDA 5.0 targets in my project's build customization options.
And I modify my project's Include and Library directories adding $(CUDA_INC_PATH) and $(CUDA_LIB_PATH) respectively (these settings can be located in project's properties menu -> Configuration Properties -> VC++ Directories).
Last thing to do before I started writing code was to change CUDA/C++ target machine platform, which was still 32-bit.
And finally, my project nicely compiles (Intellisense complains about the angle brackets though, but I have yet to find an answer for this one).
#include <cuda.h> #include <cuda_runtime.h> #include <device_launch_parameters.h> #include <stdio.h> #pragma comment(lib, "cudart") __global__ void mykernel(void) { } int main(void) { mykernel<<<1,1>>>(); printf("Hello World!\n"); getchar(); return 0; }
No comments:
Post a Comment