Community
cancel
Showing results for 
Search instead for 
Did you mean: 
388 Views

Build fails using ICC but not GCC

Hi all,

I am building ITK from source. I have had the same issue on Centos 7 and Ubuntu 14.04 systems running on Xeon Broadwell systems.

Building with GCC

When I use cmake to configure for a standard build using gcc, it use this method below. The compilation completes and works well.

mkdir build; cd build;
cmake -D Module_PerformanceBenchmarking:BOOL=ON ..
make 

Building with ICC (latest release 2017; update 2 16 Feb 2017)

When I use cmake to configure for a standard build using Intel compiler, it use this method below. The compilation completes and works well.

mkdir build; cd build;
CC=/opt/bin/icc CXX=/opt/bin/icc cmake -DCMAKE_CXX_COMPILER:FILEPATH=/opt/bin/icc -DCMAKE_C_COMPILER:FILEPATH=/opt/bin/icc -DModule_PerformanceBenchmarking:BOOL=ON ..
cmake -D Module_PerformanceBenchmarking:BOOL=ON ..
make 

There is this problem with Centos 7

Scanning dependencies of target ITKTransform-all
[ 58%] Built target ITKTransform-all
[ 58%] Building CXX object Modules/Core/ImageFunction/test/CMakeFiles/ITKImageFunctionTestDriver.dir/itkRayCastInterpolateImageFunctionTest.cxx.o
/src/ITK/Modules/Core/ImageFunction/include/itkRayCastInterpolateImageFunction.hxx(38): error: member "<unnamed>::RayCastHelper<TInputImage, TCoordRep>::InputImageDimension [with TInputImage=itk::Image<unsigned char, 3U>, TCoordRep=double]" was referenced but not defined
    itkStaticConstMacro(InputImageDimension, unsigned int,
    ^

compilation aborted for /src/ITK/Modules/Core/ImageFunction/test/itkRayCastInterpolateImageFunctionTest.cxx (code 2)
make[2]: *** [Modules/Core/ImageFunction/test/CMakeFiles/ITKImageFunctionTestDriver.dir/itkRayCastInterpolateImageFunctionTest.cxx.o] Error 2
make[1]: *** [Modules/Core/ImageFunction/test/CMakeFiles/ITKImageFunctionTestDriver.dir/all] Error 2
make: *** [all] Error 2

I get this problem when I use Ubuntu 14.04

Building CXX object Modules/Filtering/LabelMap/test/CMakeFiles/ITKLabelMapTestDriver.dir/itkBinaryImageToLabelMapFilterTest2.cxx.o
[ 68%] icc: error #10106: Fatal error in /opt/compilers_and_libraries_2017.2.174/linux/bin/intel64/mcpcom, terminated by kill signal
compilation aborted for /path/ITK/ITK-IntelCompiler/build/Modules/Segmentation/SignedDistanceFunction/test/ITKSignedDistanceFunctionTestDriver.cxx (code 1)
icc: error #10106: Fatal error in /opt/compilers_and_libraries_2017.2.174/linux/bin/intel64/mcpcom, terminated by kill signal
compilation aborted for /path/ITK/ITK-IntelCompiler/build/Modules/IO/BioRad/test/ITKIOBioRadTestDriver.cxx (code 1)
make[2]: *** [Modules/IO/XML/test/CMakeFiles/ITKIOXMLTestDriver.dir/ITKIOXMLTestDriver.cxx.o] Error 1

I need help getting past this issue. Thank you.

0 Kudos
6 Replies
Yuan_C_Intel
Employee
388 Views

Hi, Jonathan

Besides reset CC and CXX to icc, have you setup your environment with icc configuration script?

$ source /opt/intel/compilers_and_libraries_2017.2.174/linux/bin/compilervars.sh intel64

This will setup icc bin and library paths.

If your installation is not in default path, please make sure icc include folder is referenced correctly by adding -I or -Qlocation,cxxinc,dir.

You may also try use icc as linker by setting LD=icc

Thanks.

TimP
Black Belt
388 Views

CXX should be icpc in the usual case where c++ linking is needed.

388 Views

Thank you for the suggestion. Even after changing the CXX to icpc, I still receive the same issue on both Ubuntu and Centos systems.

ITK/ITK-IntelCompiler/Modules/Core/ImageFunction/include/itkRayCastInterpolateImageFunction.hxx(38): error: member "<unnamed>::RayCastHelper<TInputImage, TCoordRep>::InputImageDimension [with TInputImage=itk::Image<unsigned char, 3U>, TCoordRep=double]" was referenced but not defined

    itkStaticConstMacro(InputImageDimension, unsigned int,

    ^

 

388 Views

Additional information about the cmake configuration for icc/icpc flags from VTK are here

    if (${CMAKE_C_COMPILER} MATCHES "icc.*$")
      set(USING_INTEL_ICC_COMPILER TRUE)
    endif()
    if (${CMAKE_CXX_COMPILER} MATCHES "icpc.*$")
      set(USING_INTEL_ICC_COMPILER TRUE)
    endif()
    if(USING_INTEL_ICC_COMPILER)
      # NOTE -w2 is close to gcc's -Wall warning level, -w5 is intels -Wall warning level, and it is too verbose.
      set(VerboseWarningsFlag -w2 -wd1268 -wd981 -wd383 -wd1418 -wd1419 -wd2259 -wd1572 -wd424 )
      #-wd424  #Needed for Intel compilers with remarki  #424: extra ";" ignored
      #-wd383  #Needed for Intel compilers with remark   #383: value copied to temporary, reference to temporary used
      #-wd981  #Needed for Intel compilers with remark   #981: operands are evaluated in unspecified order
      #-wd1418 #Needed for Intel compilers with remark  #1418: external function definition with no prior declaration
      #-wd1419 #Needed for Intel compilers with remark  #1419: external declaration in primary source file
      #-wd1572 #Needed for Intel compilers with remark  #1572: floating-point equality and inequality comparisons are unreliable
      #-wd2259 #Needed for Intel compilers with remark  #2259: non-pointer conversion from "itk::SizeValueType={unsigned long}" to "double" may lose significant bits
      #-wd1268 #Needed for Intel compliers with warning #1268: support for exported templates is disabled
    else()
      set(VerboseWarningsFlag -Wall )
    endif ()
  endif()

 

Judith_W_Intel
Employee
388 Views

 

I can reproduce the diagnostic with this example:

namespace {
   template <class T>
   struct RayCastHelper {
     void foo(); // since this is inside unnamed namespace, it needs to be defined in the translation unit
   };
}

void f() {
   RayCastHelper<int> r;
   r.foo();
}

But I only see a warning not an error. Anything that is declared inside an unnamed namespace should be defined in that translation unit because there is  no possibility of a definition elsewhere. I don't understand why you are seeing an error and not a warning. If you could create a preprocessed file and attach it (add the -E or -P option to the compilation) then we could give you more help.

thanks

Judy

 

 

Judith_W_Intel
Employee
388 Views

 

Thanks for the reproducer.

I have recorded this bug as DPD200419770 in out internal bugs database.

Details on the problem are:

Here’s a small example below that compiles with GNU but not Intel. This looks like the problem is with a static data member called InputImageDimension declared inside class RayCastHelper.

The member is used inside a member function called Initialise.

This is an Intel compiler bug – while technically there is no static member definition (what’s inside the class is only a declaration) I don’t think the compiler should be complaining. Especially if GNU allows it.

In the meantime I see two possible workarounds:

  1. The “use” in this case is not needed, i.e. the statement  “ (void)InputImageDimension;”  doesn’t do anything. So you can remove it or comment it out. See attached diff1.txt for that solution. You would need that change on about line 302 of  /mnt/intel/ccc/tmp/ITK/ITK-IntelCompiler/Modules/Core/ImageFunction/include/itkRayCastInterpolateImageFunction.hxx.

  2. Add a static member definition. See attached diff2.txt for an example. You will need to move the initializer from the declaration to the definition.  The definition should go after the class declaration.

// this compiles with g++ but not icpc

namespace {

 

template< typename T>

struct RayCastHelper

{

static const unsigned int InputImageDimension = 0;

  void Initialise();

};

 

template< typename T>

void RayCastHelper< T>::Initialise(void)

{

  (void)InputImageDimension;

}

 

}

 

int main() {

  RayCastHelper<int> r;

  r.Initialise();

  return 0;

}

Reply