Hello World on CUDA

This is my second program. But I get the errors shown below. I am 2 days into GPU world so far so please educate me.

#include <iostream>

_global_ void kernel(void) {

}

int main( void ) {

    kernel<<<1,1>>>();

    printf( "Hello, World!\n" );

    return 0;

}

These are my errors:

nvcc /home/sp2412/CUDA\ Examples/hello_world.cu 

/home/sp2412/CUDA Examples/hello_world.cu(3): error: this declaration has no storage class or type specifier

/home/sp2412/CUDA Examples/hello_world.cu(3): error: expected a ";"

At end of source: warning: parsing restarts here after previous syntax error

2 errors detected in the compilation of "/tmp/tmpxft_000040f4_00000000-4_hello_world.cpp1.ii".

I have not clue what I am supposed to do now.

This is my second program. But I get the errors shown below. I am 2 days into GPU world so far so please educate me.

#include <iostream>

_global_ void kernel(void) {

}

int main( void ) {

    kernel<<<1,1>>>();

    printf( "Hello, World!\n" );

    return 0;

}

These are my errors:

nvcc /home/sp2412/CUDA\ Examples/hello_world.cu 

/home/sp2412/CUDA Examples/hello_world.cu(3): error: this declaration has no storage class or type specifier

/home/sp2412/CUDA Examples/hello_world.cu(3): error: expected a ";"

At end of source: warning: parsing restarts here after previous syntax error

2 errors detected in the compilation of "/tmp/tmpxft_000040f4_00000000-4_hello_world.cpp1.ii".

I have not clue what I am supposed to do now.

It’s global (with 2 underscores on each side), not global.

Also, you should include <stdio.h> rather than since you only use printf ;)

It’s global (with 2 underscores on each side), not global.

Also, you should include <stdio.h> rather than since you only use printf ;)