我试图从我的Go代码调用CUDA函数.我有以下三个文件.
test.h:
int test_add(void);
Run Code Online (Sandbox Code Playgroud)
test.cu:
__global__ void add(int *a, int *b, int *c){
*c = *a + *b;
}
int test_add(void) {
int a, b, c; // host copies of a, b, c
int *d_a, *d_b, *d_c; // device copies of a, b, c
int size = sizeof(int);
// Allocate space for device copies of a, b, c
cudaMalloc((void **)&d_a, size);
cudaMalloc((void **)&d_b, size);
cudaMalloc((void **)&d_c, size);
// Setup input values
a = 2;
b = 7;
// Copy inputs …Run Code Online (Sandbox Code Playgroud)