Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

C++ Compiler is Hanging*

$
0
0

I am evaluating the Intel Parallel Studio XE 2015 - Composer Edition.

Unfortunately, when attempting to build my application with the C++ compiler (icpc (ICC) 15.0.3 20150407) the compiler appears to hang*. Here is an example of the command line:

/opt/intel/composer_xe_2015.3.187/bin/intel64/icpc -std=c++11 -O0 -DNDEBUG -w2 -Werror -diag-disable=383,981,444 -o CMakeFiles/test.cpp.o -c test.cpp

* It may just be extremely inefficient. Clang builds and links the application in ~1 minute. I left icpc for 800 minutes & it still hadn't finished building.

The compiler works fine with all of my units tests and some of the smaller applications.

I've been trying to determine what part of my design is causing the problem. Here are my findings thus far:

Consider this code:

#include <iostream>
#include <utility>

template <class Base>
struct A : public Base {
  decltype(std::declval<Base>().Do()) Do() { return Base::Do(); }
};

struct B { int Do() { return 5; } };

int main () {
  std::cout << A<A<A<A<A<A<A<A<B> > > > > > > >().Do() << std::endl;
}

This compiles in 0.428 seconds with icpc & 0.314 seconds with clang++. Now increase the 'depth' of inheritance, i.e.:

...
std::cout << A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<B> > > > > > > > > > > > > > > > >().Do() << std::endl;
...

This compiles in 19.9 seconds with icpc & 0.320 seconds with clang++!

Now, if I make the following modification (workaround):

...
  using ReturnType = decltype(std::declval<Base>().Do());
  ReturnType Do() { return Base::Do(); }
...

The icpc compile time drops back down to 0.437 seconds.

Making another modification:

...
  template <class ReturnType = decltype(std::declval<Base>().Do())>
  ReturnType Do() { return Base::Do(); }
...

The compile time now blows out to ~70 seconds! While the clang++ compile time is still ~0.3 seconds.

Obviously, icpc is struggling with something here.

Note that I've gone through my larger application and applied the above 'workaround' (i.e., 'using ReturnType...') everywhere I could. However, the compiler still hangs - perhaps this is only part of the problem. Here are a couple details related to my application design:

1. The bigger applications may have 'inheritance towers' (i.e., A -> B -> C -> ... -> Z, where '->' is 'inherits from') of over 50 classes - with each class inheriting from a base class which is a template parameter of the class itself.

2. Use of CRTP, decltype & SFINAE is 'common'.

That's all I have at the moment.

Any help would be greatly appreciated.

Thanks.


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>