Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Nick_P_1
Beginner
210 Views

C++ Compiler is Hanging*

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.

0 Kudos
10 Replies
Melanie_B_Intel
Employee
210 Views

Thanks so much for the lovely test cases. I could see your first test, and the 2nd test case, but have trouble making out tests 3 and 4. If possible please attach the full test cases.

We've seen this kind of bad behavior in house as well. The problem isn't fixed in our 15.0 compiler, but it will be fixed in our 16.0 compiler which is currently in beta.  I timed 15.0 versus 16.0 beta and see 0.6 and 8.5 seconds compilation time (versus 0.2 and 0.23 for gcc) with our 16.0 compiler and 8.6 and 45 seconds for our 15.0 compiler.

The explanation for our bug numbered DPD200371615 in our internal database is described as "Performance improvements with deeply nested decltype constructs. In some cases involving many template instantiations leading to deeply nested decltype representations, the front end performed exceptionally poorly when testing whether a type is dependent or deprecated"

--Melanie

Nick_P_1
Beginner
210 Views

Hi Melanie,

See the source code attached for the four different cases. The real compile times we observe using clang++, g++, and icpc are as follows:

CASE 1: clang++ = 0.311s / g++ = 0.283s / icpc = 0.416s

CASE 2: clang++ = 0.322s / g++ = 0.303s / icpc = 19.983s

CASE 3: clang++ = 0.317s / g++ = 0.300s / icpc = 0.440s

CASE 4: clang++ = 0.320s / g++ = 0.305s / icpc = 69.621s

Note: Case 3 is the 'workaround'. 

As I mentioned in my previous post, even after applying the 'workaround' to my application, the compiler still appeared to hang. So this might only be part of the problem.

Is there any way I could try the 16.0 beta version? I have ~20 days of my evaluation license remaining. 

Thanks.

Melanie_B_Intel
Employee
210 Views

I've asked a TCE to see whether you can get a beta

I timed your test cases against gcc using a "production" build of the compiler. Here are the results (2nd number is gcc)

15.0 compiler
------------- Test 1
real    0m7.077s
real    0m0.194s
------------- Test 2
real    0m15.700s
real    0m0.202s
------------- Test 3
real    0m0.360s
real    0m0.202s
------------- Test 4
real    1m27.332s
real    0m0.215s

16.0 compiler
------------- Test 1
real    0m0.331s
real    0m0.192s
------------- Test 2
real    0m0.354s
real    0m0.203s
------------- Test 3
real    0m0.356s
real    0m0.202s
------------- Test 4
real    0m0.362s
real    0m0.202s

 

 

 

 

Kittur_G_Intel
Employee
210 Views

Hi Nick,
Thanks for your patience and feedback accordingly. Melanie asked me to respond to you on the beta and I've done so in a private email to you which you should receive separately. Appreciate if you could read that private email and you can respond to me to that as well, thanks.

_Kittur

Nick_P_1
Beginner
210 Views

Hi Melanie & Kittur,

Unfortunately I cannot replicate your results with 'icpc (ICC) 16.0.0 20150527'. For example, I'm still seeing compile times of > 1 minute for case 4.

Please advise.

Thanks.

Melanie_B_Intel
Employee
210 Views

Ok, it looks like our internal bug DPD200371615 was checked in 0624, so it  will be part of the product release, but it's not in beta.  Sorry for the runaround.  --Melanie

Kittur_G_Intel
Employee
210 Views

Thanks Melanie, that's what I presumed as well. Nick, I'll keep you updated and as soon as the product release is out I'll let you know. Appreciate your patience through this though.
_Kittur

Nick_P_1
Beginner
210 Views

No worries :)

Do you have any rough estimates on when it will be released?

Also, if I purchase an 'Intel Parallel Studio XE 2015' license now, will I have to purchase anything else in order to get the 2016 version?

Thanks.

Kittur_G_Intel
Employee
210 Views

Nick, the product should be released sometime in this quarter with what I am aware of but the schedule is subject to change as well. I'll keep you updated as soon as the release is out and again, appreciate your patience.

As long as the license hasn't expired you are allowed to upgrade to the next release. Basically, new software purchases include free product updates and support as well through the license expiration date. Of course, you can renew the software product license taht extends updates and support accordingly.  

_Kittur

 

Kittur_G_Intel
Employee
210 Views

Hi Nick,
Just letting you know that the issue is fixed in the latest 16.0 release which you can download from the Intel Registration Center (https://registrationcenter.intel.com), thx

_Kittur

Reply