1

Possible Duplicate:
Can I call cuda function calls in C++?

I have the functions

__global__ void Function(int *A, int *B, int N) {
  calculations...
}

void Function_Wrapper(int* a_h, int* b_h) {
  dimGrid, dimBlock;
  Function<<<dimGrid, dimBlock>>>(a_d,b_d,n);
}

inside the .cu file and the function

int main() {
  Create data and other crap...

  Function_Wrapper (a_h, b_h);
}

But when i try to compile all i get is this:

cmain.cpp:39: error: ‘Function_Wrapper’ was not declared in this scope

I'm compiling it like this:

all: program

program: cudacode.o
    g++ -o ctp -L /usr/local/cuda/lib64 -lcuda -lcudart cmain.cpp cudacode.o 

cudacode.o:
    nvcc -c -arch=sm_20 cmain.cu 

clean: rm -rf *.o

What am i doing wrong?

EDIT: I fixed the missing function problem with an external function declaration in the main file but i'm still having some problems. New makefile:

all: program

program: cudacode.o
    g++ -o ctp -L /Developer/NVIDIA/CUDA-5.0/lib -lcudart cmain.cpp cudacode.o 

cudacode.o:
    nvcc -c -arch=sm_20 cmain.cu -o cudacode.o 

clean: rm -rf *.o

New error message:

g++ -o ctp -L /Developer/NVIDIA/CUDA-5.0/lib -lcudart cmain.cpp cudacode.o

ld: warning: ignoring file cudacode.o, file was built for i386 which is not the architecture being linked (x86_64): cudacode.o

Undefined symbols for architecture x86_64:

"Function_Wrapper(int*, int*)", referenced from:

_main in ccjLlw82.o

ld: symbol(s) not found for architecture x86_64

collect2: ld returned 1 exit status

make: *** [program] Error 1

PS: Using macosx

Community
  • 1
  • 1
Jean-Luc Nacif Coelho
  • 1,006
  • 3
  • 14
  • 30

0 Answers0