Skip to content

Instantly share code, notes, and snippets.

@twmht
Created May 11, 2017 13:33
Show Gist options
  • Select an option

  • Save twmht/32f7d8734ccc231adea28bdc39db333d to your computer and use it in GitHub Desktop.

Select an option

Save twmht/32f7d8734ccc231adea28bdc39db333d to your computer and use it in GitHub Desktop.
cuda example
/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
#include <stdio.h>
#include "file1.h"
__global__ void mykernel(){
printf("Hello from mykernel\n");
}
int hello(){
mykernel<<<1,1>>>();
cudaDeviceSynchronize();
return 0;
}
int hello();
#include "file2.h"
int main(){
myfunc();
return 0;
}
#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