automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cuda compilation


From: Tomas Oberhuber
Subject: Re: cuda compilation
Date: Sat, 2 Jan 2010 11:33:46 +0100
User-agent: KMail/1.9.10

Hello Ralph,

On Wednesday 30 of December 2009 22:52:51 Ralf Wildenhues wrote:
> Hello Tomas,
>
> * Tomas Oberhuber wrote on Tue, Dec 29, 2009 at 07:25:36PM CET:
> > I am experiencing some troubles with cuda. I studied mailing lists about
> > autoconf, automake and libtool and from what I have read
> >
> > I have understood that from the linking point of view nvcc and gcc are
> > compatible. So one should only compile .cu files with nvcc and then link
> > all together with gcc. To compile .cu files with nvcc I did this in my
> > Makefile.am
> >
> > include  ${top_srcdir}/cuda.mk
> >
> > where cuda.mk is
> >
> > SUFFIXES = .cu
> > .cu.$(OBJEXT):
> >     $(NVCC) -c $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $
> > (CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -o $@ $<
> >
> > libcore_tests_sources = tnlLongVectorCUDATester.cu \
> >                         tnlLongVectorCUDATester.h
> >
> > check_LTLIBRARIES = libcore-tests.la
> > libcore_tests_la_SOURCES = $(libcore_tests_sources)
>
> The .cu.$(OBJEXT) rule to create objects from sources only works for
> objects not created with libtool.  For the latter, you'd need a .cu.lo
> rule, and you also need libtool to know about nvcc.  The support that
> was added to git Libtool in commit 741a9867e only works when $CC is set
> to nvcc, so at this point your best bet might be to either use
>   ./configure CC=nvcc
>
> and compile all your sources with nvcc.
>
> Alternatively, you could write a .cu.lo rule that looks like the
> automake-generated .c.lo rule, has --tag=CC but uses $(NVCC); you'd then
> still need a nvcc-wrapper that translates '-fPIC' to '-Xcompiler -fPIC'
> for nvcc.  Ugly, yes, but I'm not sure how to do this any nicer at the
> moment.
>
> Cheers,
> Ralf

Now I try to compile whole project with nvcc. It seems to work but I get this 

ibtool: link: 
nvcc -shared -nostdlib    
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebugStructure.o 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-parse.o 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebugGroup.o 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebugParser.o 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebug.o 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebugScanner.o  
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlParameterContainer.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlString.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlTimerCPU.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlTimerRT.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlConfigDescription.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlConfigDescriptionScanner.o
 .libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-mpi-supp.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlTester.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-parse.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlConfigDescriptionParser.o
 .libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlObject.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-compress-file.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-mfilename.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlLogger.o   
.libs/libtnl-0.1.lax/libtnlmatrix-0.1.a/libtnlmatrix_0_1_la-tnlBaseMatrix.o   
-L/usr/local/cuda/lib64 -lcppunit -lcudart     -Wl,-soname -Wl,libtnl-0.1.so.0 
-o .libs/libtnl-0.1.so.0.0.0
nvcc fatal   : Unknown option 'nostdlib'

which means that nvcc is also used as linker. Even if I remove -nostdlib, nvcc 
complains about other parameters. So I think it would be better to link with 
g++. Can I change linker somehow? And in that case if I do it by hand (copy 
the command on the command line and replace nvcc by g++) I get this

g++ -shared -nostdlib    
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebugStructure.o 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-parse.o 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebugGroup.o 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebugParser.o 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebug.o 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebugScanner.o  
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlParameterContainer.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlString.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlTimerCPU.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlTimerRT.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlConfigDescription.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlConfigDescriptionScanner.o
 .libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-mpi-supp.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlTester.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-parse.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlConfigDescriptionParser.o
 .libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlObject.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-compress-file.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-mfilename.o 
.libs/libtnl-0.1.lax/libtnlcore-0.1.a/libtnlcore_0_1_la-tnlLogger.o   
.libs/libtnl-0.1.lax/libtnlmatrix-0.1.a/libtnlmatrix_0_1_la-tnlBaseMatrix.o   
-L/usr/local/cuda/lib64 -lcppunit -lcudart     -Wl,-soname -Wl,libtnl-0.1.so.0 
-o .libs/libtnl-0.1.so.0.0.0
/usr/bin/ld: 
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebugStructure.o: 
relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a 
shared object; recompile with -fPIC
.libs/libtnl-0.1.lax/libtnldebug-0.1.a/libtnldebug_0_1_la-tnlDebugStructure.o: 
could not read symbols: Bad value
collect2: ld returned 1 exit status

Or maybe we can solve it using -Xcompiler nad -Xlinker. May I ask what does 
libtool do now in case we use nvcc to compile or link?

Thanks and have a good day, Tomas.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]