CISMM / Clarity

An open-source deconvolution library with CUDA acceleration
http://cismm.cs.unc.edu/downloads/?dl_cat=11
16 stars 3 forks source link

Duplicate declarations in Clarity when using CUDA in Ubuntu 11.10 #2

Closed rcasero closed 12 years ago

rcasero commented 12 years ago

Hi,

I have tried to compile Clarity v1.0.0 in Ubuntu 11.10 using CUDA. The first problem was with CUDA requiring gcc v4.4 or older, while Ubuntu 11.10 ships gcc v4.6.1.

This problem can be solved by stating in the CMakeLists.txt that nvcc should look in another directory for the compilers

IF(BUILD_WITH_CUDA)
  # Load CUDA macros
  FIND_PACKAGE(CUDA)
  SET(CUDA_NVCC_FLAGS --compiler-bindir ${path/to/old/gcc/dir})
ENDIF(BUILD_WITH_CUDA)

and adding soft links in the directory, e.g.

$ cd path/to/old/gcc/dir
$ ln -s /usr/bin/gcc-4.4 gcc
$ ln -s /usr/bin/g++-4.4 g++

The build fails for me at linking time. I get errors of duplicated symbols. I think that the problem is e.g. with WienerDeconvolveGPU.cu, and WienerDeconvolve.cxx, that include Complex.h and ComplexCUDA.h, and these declare functions with the same identifier.

Best regards,

Ramon.

cquammen commented 12 years ago

Ramon,

The changes I've made in master should fix the duplicate declarations.

One thing I did differently from what you did was instead of having

SET(CUDA_NVCC_FLAGS --compiler-bindir ${path/to/old/gcc/dir})

I set the directory of my path/to/old/gcc/dir within ccmake directly. To get it to work properly, I had to quote the space between the "--compiler-bindir" and the path, so that it read

--compiler-bindir" "/path/to/old/gcc/dir

If you don't quote the middle space, CMake will quote the entire string, and nvcc apparently does not like that. This might be a bug in the FindCUDA.cmake module in CMake. I'm going to look into it a little further, and if it is, I'll report it on the CMake bug tracker.

Cory

rcasero commented 12 years ago

Hi Cory,

In my case, I have all my gcc versions in the same directory, /usr/bin, which is the default in Ubuntu, if I remember well, Debian, and probably other linux distributions. So the --compiler-bindir solution is actually a bit messy. I have a better way now, which is to say in the root CMakeLists.txt of Gerardus

http://code.google.com/p/gerardus/source/browse/trunk/CMakeLists.txt

IF(BUILD_WITH_CUDA) SET(CMAKE_C_COMPILER gcc-4.4) SET(CMAKE_CXX_COMPILER g++-4.4) ENDIF(BUILD_WITH_CUDA)

Then, in the CMakleLists.txt of Clarity you can have

http://code.google.com/p/gerardus/source/browse/trunk/cpp/src/third-party/cquammen-Clarity/CMakeLists.txt

ramc: operations when compiling CUDA variant of Clarity

IF(BUILD_WITH_CUDA)

Load CUDA macros

FIND_PACKAGE(CUDA) IF(CMAKE_COMPILER_IS_GNUCC)

get version of compiler

 EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion
   OUTPUT_VARIABLE GCC_VERSION)
 IF(GCC_VERSION VERSION_LESS 4.5)
   # ramc: CUDA v4.0 RC2 is incompatible with gcc >= 4.5. Gcc
   # 4.4. is selected in the root gerardus CMakeLists.txt, but this
   # flag needs to be set by hand, because otherwise nvcc will read
   # the version of the default gcc in the system, that is v4.5
   SET(CUDA_NVCC_FLAGS "-D__GNUC_MINOR__=4")
 ENDIF(GCC_VERSION VERSION_LESS 4.5)

ENDIF(CMAKE_COMPILER_IS_GNUCC) ENDIF(BUILD_WITH_CUDA)

Cheers,

Ramon.