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: .:: C++ Mathematical Expression Library (ExprTk) - By Arash Partow ::.).
I have demonstrated this issue with a small standalone example:
#include<exprtk.hpp>
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;
symbol_table.add_variable("x",x);
symbol_table.add_constants();
expression_t expression;
expression.register_symbol_table(symbol_table);
parser_t parser;
parser.compile(expression_string,expression);
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()
{
trig_function<double>();
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.
Thanks,
-David