Created
May 11, 2017 13:33
-
-
Save twmht/32f7d8734ccc231adea28bdc39db333d to your computer and use it in GitHub Desktop.
cuda example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /usr/local/cuda/bin/nvcc -c file1.cu | |
| g++ -c file2.cpp | |
| g++ -o test file1.o file2.o -L/usr/local/cuda/lib64 -lcudart | |
| ./test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include "file1.h" | |
| __global__ void mykernel(){ | |
| printf("Hello from mykernel\n"); | |
| } | |
| int hello(){ | |
| mykernel<<<1,1>>>(); | |
| cudaDeviceSynchronize(); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int hello(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "file2.h" | |
| int main(){ | |
| myfunc(); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include "file1.h" | |
| int myfunc(){ | |
| hello(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment