pgc++ compile time with large header-only libraries

I am attempting to migrate a C++ application from the GNU compilers to PGI in preparation for GPU acceleration with OpenACC. I have found that the compile time for this project is significantly slower with PGI than GCC (20 minutes vs 2 minutes). The application is almost entirely header implementation and must be rebuilt from scratch regularly. Thus, this jump from 2 minutes to 20 minutes is quite painful.

Upon closer inspection it seems that a large portion of the increase comes from the inclusion of a very large (39K lines) open-source header-only library (available here:

I have demonstrated this issue with a small standalone example:

template <typename T>
void trig_function()
   typedef exprtk::symbol_table<T> symbol_table_t;
   typedef exprtk::expression<T>     expression_t;
   typedef exprtk::parser<T>             parser_t;
   const std::string expression_string =
                     "clamp(-1.0,sin(2 * pi * x) + cos(x / 2 * pi),+1.0)";
   T x;
   symbol_table_t symbol_table;
   expression_t expression;
   parser_t parser;
   for (x = T(-5); x <= T(+5); x += T(0.001))
      const T y = expression.value();
      printf("%19.15f\t%19.15f\n", x, y);
int main()
  return 0;

The time to build this with gcc4.8.5 and PGI 19.10 is:

[david@supercell build_test]$ time g++ -O2 main.cpp -I./
real 1m21.444s
user 1m19.853s
sys 0m1.547s

[david@supercell build_test]$ time pgc++ -O2 main.cpp -I./
real 7m53.520s
user 7m23.234s
sys 0m29.853s

I don’t expect g++ and pgc++ to have the same build time as there are likely different optimizations happening, but this difference is quite severe. I have seen similar issues with other proprietary codes that I have not been able to share. As this is an open source library I thought it would be worthwhile to share these results for PGI’s internal analysis.



Hi David,

Your timing is great. We’re aware of the compile time issues and our C++ team is actively working on improving this so having another example helps. I filed this as TPR #28596.

FYI, with our development compiler we’re already seeing improvements, but still have a bit to go. Hopefully we’ll have it down to an acceptable compile time in a release later this year.

HPC SDK 20.5
% time nvc++ -O2 test.cpp -I./ -V20.5
344.748u 12.985s 6:03.31 98.4% 0+0k 92152+4048272io 58pf+0w

Today’s development compiler:
% time nvc++ -O2 test.cpp -I./ -Vdev
271.439u 13.256s 4:49.21 98.4% 0+0k 86456+4036856io 57pf+0w

GNU 9.2
% time g++ -O2 test.cpp -I./
53.792u 1.101s 0:55.99 98.0% 0+0k 61968+100256io 40pf+0w