|
Single program file compilation: nvcc -o prog prog.cu |
lab1a lab1b ... lab1h |
The CUDA servers are only accessible via lab0z.mathcs.emory.edu (or a lab machine in the CS lab)
Login to the MathCS gateway lab0z.mathcs.emory.edu Then on lab0z.mathcs.emory.edu, execute: ssh -X lab1a or ssh -X lab1b etc. |
You must logon to a CUDA server before you can compile/run your CUDA C program(s) !!!
#include <cuda.h> (Path: /usr/local/cuda-9.0/include/cuda.h) |
The CUDA header file is automatically included by the CUDA C compiler nvcc !!!
/* --------------------------------------------------- My Hello world for CUDA programming --------------------------------------------------- */ #include <stdio.h> // C programming header file #include <unistd.h> // C programming header file // cude.h is automatically included by nvcc... /* ------------------------------------ Your first kernel (= GPU function) ------------------------------------ */ __global__ void hello( ) { printf("Hello World !\n"); } int main() { /* ------------------------------------ Call the hello( ) kernel function ------------------------------------ */ hello<<< 1, 4 >>>( ); printf("I am the CPU: Hello World ! \n"); return 0; } |
/home/cs355001/demo/CUDA/1-intro/hello1 Output: I am the CPU: Hello World ! |
/* --------------------------------------------------- My Hello world for CUDA programming --------------------------------------------------- */ #include <stdio.h> // C programming header file #include <unistd.h> // C programming header file // cude.h is automatically included by nvcc... /* ------------------------------------ Your first kernel (= GPU function) ------------------------------------ */ __global__ void hello( ) { printf("Hello World !\n"); } int main() { /* ------------------------------------ Call the hello( ) kernel function ------------------------------------ */ hello<<< 1, 4 >>>( ); printf("I am the CPU: Hello World ! \n"); sleep(1); // Necessary to give time to let GPU threads run !!! return 0; } |
/home/cs355001/demo/CUDA/1-intro/hello1 Output: I am the CPU: Hello World ! Hello World ! Hello World ! Hello World ! Hello World ! |
|