Unable to compile ROOT 6.11.02 on Ubuntu 16.04

Dear experts,

my system is Ubuntu 16.04, I have gcc 5.4 and CUDA toolkit 9.
I have a standalone installation of Vc (1.3) and Vecgeom (master branch) which uses Vc as backend and with CUDA support enabled.
The cmake command to configure the compilation is:

cmake …/git -Dqtgsi=“1” -Dvecgeom=“1” -DCMAKE_BUILD_TYPE=“RelWithDebInfo” -DCUDA_HOST_COMPILER=“/usr/bin/cc” -Dmemstat=“1” -Dpython3=“1” -Dldap=“1” -Dgnuinstall=“1” -Dqt=“1” -Dminuit2=“1” -Dshadowpw=“1” -Dtable=“1” -Dvc=“1” -Dgviz=“1” -DCMAKE_INSTALL_PREFIX=“/home/ccorti/programs/root6/build” -DCMAKE_PREFIX_PATH=“/home/ccorti/programs/vecgeom/build/lib/cmake/VecGeom” -Dbuiltin_vdt=“1” -Dveccore=“1” -Dkrb5=“1” -Dall=“1” -Dcuda=“1” -DENABLE_LINKER_BUILD_ID=“1” -Dcxx14=“1” -Dvdt=“1” -Dunuran=“1”

So far I had two compilation errors:

  1. Failed compilation of TMVA/DNN with CUDA and C++14, because nvcc was not passed the -std=c++14 flag.
    I solved this by setting CUDA_NVCC_FLAGS="-std=c++14" in CMakeCache.txt.

  2. Failed compilation of graf3d/gl/CMakeFiles/RGL.dir/G__RGL.cxx.o
    The compilation command being issued is:

/usr/bin/c++ -DVECCORE_ENABLE_CUDA -DVECCORE_ENABLE_VC -DVECGEOM_CUDA_NO_VOLUME_SPECIALIZATION -DVECGEOM_ENABLE_CUDA -DVECGEOM_INPLACE_TRANSFORMATIONS -DVECGEOM_NO_SPECIALIZATION -DVECGEOM_QUADRILATERALS_VC -DVECGEOM_USE_INDEXEDNAVSTATES -DVECGEOM_VC -I/home/ccorti/programs/root6/build/include -I/usr/local/include -I/home/ccorti/programs/root6/build/externals/home/ccorti/programs/root6/build/include -I/home/ccorti/programs/root6/git/graf3d/ftgl/inc -I/usr/include/freetype2 -I/usr/include/x86_64-linux-gnu/freetype2 -I/home/ccorti/programs/root6/git/graf3d/gl/src/gl2ps -pipe -m64 -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -fPIC -pthread -std=c++14 -DR__HAVE_CONFIG -fabi-version=0 -march=native -O2 -g -DNDEBUG -fPIC -o CMakeFiles/RGL.dir/G__RGL.cxx.o -c /home/ccorti/programs/root6/build/graf3d/gl/G__RGL.cxx

while the errors are (I report only the first lines):

In file included from /usr/include/GL/glx.h:30:0,
                 from /home/ccorti/programs/root6/build/include/TX11GL.h:27,
                 from /home/ccorti/programs/root6/build/graf3d/gl/G__RGL.cxx:56:
/usr/local/include/Vc/common/simdarray.h:1542:32: error: expected nested-name-specifier before numeric constant
     template <bool B, typename True, typename False>
                                ^
/usr/local/include/Vc/common/simdarray.h:1542:32: error: expected ‘>’ before numeric constant
In file included from /usr/local/include/Vc/vector.h:191:0,
                 from /usr/local/include/Vc/Vc:30,
                 from /home/ccorti/programs/root6/build/include/Math/Types.h:18,
                 from /home/ccorti/programs/root6/build/include/TFormula.h:24,
                 from /home/ccorti/programs/root6/build/include/TF1.h:27,
                 from /home/ccorti/programs/root6/build/include/TF2.h:26,
                 from /home/ccorti/programs/root6/build/include/TGLParametric.h:18,
                 from /home/ccorti/programs/root6/build/graf3d/gl/G__RGL.cxx:72:
/usr/local/include/Vc/common/simdarray.h:1543:65: error: type/value mismatch at argument 2 in template parameter list for ‘template<bool <anonymous>, class, class> struct std::conditional’
     using conditional = typename std::conditional<B, True, False>::type;
                                                                 ^
/usr/local/include/Vc/common/simdarray.h:1543:65: note:   expected a type, got ‘1’
/usr/local/include/Vc/common/simdarray.h:1543:65: error: type/value mismatch at argument 3 in template parameter list for ‘template<bool <anonymous>, class, class> struct std::conditional’
/usr/local/include/Vc/common/simdarray.h:1543:65: note:   expected a type, got ‘0’

I’m currently stuck here, since Vecgeom has been compiled with Vc with no problems, so I don’t know exactly what to do.

Best,
Claudio

Maybe @amadio can help…

Hi, you mention that you already have VecGeom and Vc installed. Were they also compiled with C++14 standard?

Also, please specify the full version of Vc that you are using, since the version I have (1.3.3) has different contents in the line with the error you mention. You could also try to update Vc and then retry to install everything, as the error might be solved in the latest version.

Thanks for the suggestion amadio.

I checked out Vc 1.3.3 and recompiled it successfully with C++14:

cmake …/ -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=“1” -DCMAKE_CXX_FLAGS=“-std=c++14”

Then I installed VecCore from GitHub - root-project/veccore: C++ Library for Portable SIMD Vectorization with:

cmake …/ -DVC=“1” -DCUDA=“1” -DCMAKE_CXX_STANDARD=“14”

I had to change the file cmake/CUDA.cmake to add support for C++14 to nvcc. Here is the diff:

--- cmake/CUDA.cmake    2017-11-30 12:25:24.652495307 -1000
+++ cmake/CUDA.cmake.orig       2017-11-30 13:28:05.531030526 -1000
@@ -6,10 +6,8 @@

 if(CMAKE_CXX_STANDARD STREQUAL 11)
   list(APPEND CUDA_NVCC_FLAGS -std=c++11)
-elseif(CMAKE_CXX_STANDARD STREQUAL 14)
-  list(APPEND CUDA_NVCC_FLAGS -std=c++14)
 else()
-  message(FATAL_ERROR "CUDA compilation supports only ISO C++ 2011 or 2014 standard")
+  message(FATAL_ERROR "CUDA compilation supports only ISO C++ 2011 standard")
 endif()

Then I recompiled VecGeom with:

cmake …/ -DCUDA=“1” -DBACKEND=“Vc” -DBUILTIN_VECCORE=“0” -DCMAKE_CXX_STANDARD=“14” -DCMAKE_INSTALL_PREFIX=$(pwd)

I had to change CMakeLists.txt to add support for C++14 to nvcc:

--- CMakeLists.txt      2017-11-30 13:25:45.227676737 -1000
+++ CMakeLists.txt.orig 2017-11-30 13:28:59.994779678 -1000
@@ -412,19 +412,11 @@
     set(VECGEOM_DEFINITIONS
         "${VECGEOM_DEFINITIONS} -DVECGEOM_CUDA_NO_VOLUME_SPECIALIZATION")
   endif()
-  if(CMAKE_CXX_STANDARD STREQUAL 14)
-    set(VECGEOM_NVCC_COMPILATION_FLAGS ${VECGEOM_NVCC_COMPILATION_FLAGS}
-      -std=c++14
-      -Xcompiler -Wno-unused-function
-      -Xcudafe "--diag_suppress=code_is_unreachable"
-      -Xcudafe "--diag_suppress=initialization_not_reachable")
-  else()
-    set(VECGEOM_NVCC_COMPILATION_FLAGS ${VECGEOM_NVCC_COMPILATION_FLAGS}
+  set(VECGEOM_NVCC_COMPILATION_FLAGS ${VECGEOM_NVCC_COMPILATION_FLAGS}
       -std=c++11
       -Xcompiler -Wno-unused-function
       -Xcudafe "--diag_suppress=code_is_unreachable"
       -Xcudafe "--diag_suppress=initialization_not_reachable")
-  endif()
   if (NOT NO_SPECIALIZATION)
      set(VECGEOM_NVCC_COMPILATION_FLAGS ${VECGEOM_NVCC_COMPILATION_FLAGS}
         -Xptxas --disable-optimizer-constants )

Finally, this is the cmake command for ROOT:

cmake …/git -Dqtgsi=“1” -Dvecgeom=“1” -DCMAKE_BUILD_TYPE=“RelWithDebInfo” -DCUDA_HOST_COMPILER=“/usr/bin/cc” -Dmemstat=“1” -Dpython3=“1” -Dldap=“1” -Dgnuinstall=“1” -Dqt=“1” -Dminuit2=“1” -Dshadowpw=“1” -Dtable=“1” -Dvc=“1” -Dgviz=“1” -DCMAKE_INSTALL_PREFIX=“$HOME/programs/root6/build” -DCMAKE_PREFIX_PATH=“$HOME/programs/vecgeom/build/lib/cmake/VecGeom” -Dbuiltin_vdt=“1” -Dveccore=“1” -Dkrb5=“1” -Dall=“1” -Dcuda=“1” -DENABLE_LINKER_BUILD_ID=“1” -Dcxx14=“1” -Dvdt=“1” -Dunuran=“1” -DCUDA_NVCC_FLAGS=“-std=c++14”

The compilation fails while linking libConverterVG.so:

/home/ccorti/programs/vecgeom/build/lib/libvecgeom.a(UnplacedPolyhedron.cpp.o): In function `vecgeom::cxx::UnplacedPolyhedron::CopyToGpu(vecgeom::cxx::DevicePtr<vecgeom::cuda::VUnplacedVolume>) const':
UnplacedPolyhedron.cpp:(.text+0x6fb): undefined reference to `cudaMemcpy'
UnplacedPolyhedron.cpp:(.text+0x760): undefined reference to `cudaMemcpy'
UnplacedPolyhedron.cpp:(.text+0x7c5): undefined reference to `cudaMemcpy'
/home/ccorti/programs/vecgeom/build/lib/libvecgeom.a(CudaManager.cpp.o): In function `vecgeom::cxx::CudaManager::Synchronize()':
CudaManager.cpp:(.text+0x51b2): undefined reference to `cudaMemcpy'
/home/ccorti/programs/vecgeom/build/lib/libvecgeom.a(CudaManager.cpp.o): In function `vecgeom::cxx::CudaManager::CudaManager()':
CudaManager.cpp:(.text+0x5c95): undefined reference to `cudaDeviceSetLimit'
/home/ccorti/programs/vecgeom/build/lib/libvecgeom.a(Interface.cpp.o): In function `vecgeom::cxx::CudaCheckError(cudaError)':
Interface.cpp:(.text+0x8): undefined reference to `cudaGetErrorString'
/home/ccorti/programs/vecgeom/build/lib/libvecgeom.a(Interface.cpp.o): In function `vecgeom::cxx::CudaCheckError()':
Interface.cpp:(.text+0x35): undefined reference to `cudaGetLastError'
/home/ccorti/programs/vecgeom/build/lib/libvecgeom.a(Interface.cpp.o): In function `vecgeom::cxx::CudaAssertError()':
Interface.cpp:(.text+0x65): undefined reference to `cudaGetLastError'
/home/ccorti/programs/vecgeom/build/lib/libvecgeom.a(Interface.cpp.o): In function `vecgeom::cxx::CudaMalloc(void**, unsigned int)':
Interface.cpp:(.text+0x83): undefined reference to `cudaMalloc'
/home/ccorti/programs/vecgeom/build/lib/libvecgeom.a(Interface.cpp.o): In function `vecgeom::cxx::CudaCopyToDevice(void*, void const*, unsigned int)':
Interface.cpp:(.text+0x98): undefined reference to `cudaMemcpy'
/home/ccorti/programs/vecgeom/build/lib/libvecgeom.a(Interface.cpp.o): In function `vecgeom::cxx::CudaCopyFromDevice(void*, void const*, unsigned int)':
Interface.cpp:(.text+0xa8): undefined reference to `cudaMemcpy'
/home/ccorti/programs/vecgeom/build/lib/libvecgeom.a(Interface.cpp.o): In function `vecgeom::cxx::CudaFree(void*)':
Interface.cpp:(.text+0xb1): undefined reference to `cudaFree'
collect2: error: ld returned 1 exit status

This is the linking command:

/usr/bin/c++ -fPIC -pipe -m64 -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -fPIC -pthread -std=c++14 -DR__HAVE_CONFIG -fabi-version=0 -march=native -fabi-version=6 -O2 -g -DNDEBUG -Wl,–no-undefined -shared -Wl,-soname,libConverterVG.so -o …/…/lib/libConverterVG.so CMakeFiles/ConverterVG.dir/G__ConverterVG.cxx.o CMakeFiles/ConverterVG.dir/src/TGeoVGConverter.cxx.o CMakeFiles/ConverterVG.dir/src/TGeoVGShape.cxx.o -Wl,-rpath,/home/ccorti/programs/vecgeom/build/lib/cmake/VecGeom/…/…:/home/ccorti/programs/root6/build/lib: /usr/local/lib/libVc.a -ldl -lrt /home/ccorti/programs/vecgeom/build/lib/libvecgeom.a /home/ccorti/programs/vecgeom/build/lib/libvecgeomcuda.so -ldl …/…/lib/libGeom.so …/…/lib/libRIO.so …/…/lib/libMathCore.so …/…/lib/libImt.so …/…/lib/libThread.so …/…/lib/libCore.so

If I move libvecgeomcuda.so before libvecgeom.a in the linking command and add at the end -L/usr/local/cuda/lib64 -lcudart, then it compiles.

Unfortunately, the installation fails with:

CMake Error at proof/pq2/cmake_install.cmake:47 (file):
  file INSTALL cannot find "/home/ccorti/programs/root6/build/bin/pq2".
Call Stack (most recent call first):
  proof/cmake_install.cmake:45 (include)
  cmake_install.cmake:205 (include)

If I do make pq2, the file bin/pq2 is created, but then calling again make install fails with the same error, and indeed bin/pq2 is not there any more.
Any ideas?

Hi! Thank you very much for the very detailed report. I wish every report was like this.

I will incorporate the C++14 changes to VecCore. I should have changed that when CUDA 9 was released.

I recommend not installing into the build directory, as you may overwrite/truncate files from when you were building. In particular, the installation of VecGeom is known to break if you install it into the same directory as you built it. Please always install into an area specific for this, be it /usr/local, /opt/, or $HOME/pkgs or something similar. Also, if you are installing multiple packages, it is ok (or even better) to install them all into the same prefix, so that the only extra option you have to give to CMake is -DCMAKE_PREFIX_PATH=<prefix>, where <prefix> is where you are installing everything. Also, if you add -Wl,-rpath=<prefix>/lib to your CXXFLAGS, you will not need to set LD_LIBRARY_PATH later either.

So, if you installed ROOT and other packages into the build directory, I’d say try again with the recommendations above. If it still doesn’t work, let us know and we will find a solution together. Cheers,

1 Like

I used -DCMAKE_INSTALL_PREFIX=$(pwd), because it was suggested in the VecGeom gitlab page.
Anyway, I recompiled VecGeom with the default installation path (/usr/local), reconfigured ROOT 6 with:

cmake …/git -DCMAKE_BUILD_TYPE=“RelWithDebInfo” -DCMAKE_INSTALL_PREFIX=“/home/ccorti/programs/root6/install” -DCMAKE_CXX_FLAGS=“-I/usr/local/cuda/include” -Dcxx14=“1” -Dgnuinstall=“1” -Dcuda=“1” -DCUDA_NVCC_FLAGS=“-std=c++14” -Dall=“1” -Dbuiltin_vdt=“1” -Dvc=“1” -Dveccore=“1” -Dvecgeom=“1” -Dminuit2=“1” -Dunuran=“1” -Dqt=“1” -Dqtgsi=“1” -Dgviz=“1” -Dmemstat=“1” -Dpython3=“1” -Dldap=“1” -Dkrb5=“1” -Dshadowpw=“1” -Dtable=“1”

and it finally worked! :smiley:
I still had to fix by hand the linking command for libConverterVG, though.
I guess that installing ROOT in a path different from the build directory it’s what really solved the “bin/pq2 not found” problem.
It should probably be explicitly written in the documentation at Building ROOT from source - ROOT.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.