Alex
Alex

Reputation: 18522

Trying to adapt existing c project to CUDA, .cu files not found by Makefile

I'm trying to accelerate a key function in a c project (not c++) using CUDA.

For some reason, i can't get the Makefile's to recognise the .cu extension when I change the name of one of the files to .cu.

It's using a configure script and .am/.in/.deps files, which I don't really understand all that well, but basically I grepped references to file.c and changed them all to file.cu, but it produces a file.o: File Not Found error.

Top level make file

https://www.dropbox.com/s/g282qvbdu8pdas0/Makefile

Src folder makefile

https://www.dropbox.com/s/b4pq026od8gauqi/Makefile

The search command I used was

grep -R -i "file.c"

and I simply changed them all to file.cu, then re-ran configure, make clean, make all - result is File Not Found.

I suppose it must be something to do with extensions being ignored/accepted by the Makefile, but as it's been a long time since I've programmed in C and I've never used such complex Makefiles I don't know how to fix it.

Any ideas?

*PS Also, file.cu has compile errors at the moment, but the error message I'm getting is File Not Found, so I think that's not the problem.

Upvotes: 0

Views: 575

Answers (2)

Alex
Alex

Reputation: 18522

The following guide seems to cover it...

http://mcclanahoochie.com/blog/2011/02/automake-and-cuda/

Actually, most of the advice given in the link seems unnecessary for basic compilation, but for some reason I found that when I re-created the config file using autoconf it worked. No explanation comes to mind.

Upvotes: 0

perreal
perreal

Reputation: 97918

You need to have a rule to build o file from a cu file:

cudafile.o: cudafile.cu
    nvcc $(NVCC_FLAGS) -c %< -o $@

So you also need to specify the rule for the cu file, and use nvcc for compilation.

Upvotes: 1

Related Questions