I have read a lot of forums in this area. But I couldn’t find what I want.
I have lots of .c and .h files and an existing make file which works perfectly. The makefile is written using autotools(automake,autoconf and libtool). I want to accelerate one function from the large .c files using CUDA and I have got problem of editing the existing makefile. The concepts what I have got from different forums is how to use cuda in autotools but not explain how to modify the existing makefile and integrate it or how to use together cuda code and existing c code. I read this forum http://www.clusterchimps.org/autotools.php. and has good explanation how to use cuda with autotools. The order of compilation of files using gcc and nvcc also matters if I am not mistaken. So, how to modify the existing Makefile by adding cuda code and where to put these commands to integrate with the existing c makefile(means at the top, middle, at the end or some where…) I think the order matters. Any one who has experience in this area please share your experience(How to use cuda code and c code together in makefile with an existing makefile generated by autotools). This makes me crazy.
I am using Ubuntu and if it helps I can upload the make file. I am going to edit configure.ac and Makefile.am
hey guys. is the question not clear? No one answer me… When I tried to modify configure.ac and Makefile.am I got undefined reference error.
here is cuda code part of Makefile.am and configure.ac
the cuda compiler
NVCC = nvcc # root path of cuda toolkits CUDA_ROOT_DIR = /usr/local/cuda-6.5 # the preprocessing flags passed to the compiler NVCC_CPPFLAGS = -I$(CUDA_ROOT_DIR)/include \ -I$(CUDA_ROOT_DIR)/samples/common/inc # compiling flags NVCC_CXXFLAGS = -O2 -g -G -dc \ -gencode arch=compute_21,code=sm_21 # the linking flags NVCC_LINKFLAGS = -gencode arch=compute_21,code=sm_21 \ -L/usr/local/cuda-6.5/lib64 -lcudart bin_PROGRAMS = main main_SOURCES = main.cu main_LDFLAGS = $(NVCC_LINKFLAGS) # the rule that can recognize *.cu files # and compile the *.cu files to *.o files .cu.o : ; $(NVCC) $(NVCC_CPPFLAGS) $(NVCC_CXXFLAGS) -c -o $@ $<
I think undefined reference error is due to linking problem.
how to link gcc and nvcc in this case? is the above has linking problem?