We have a user who is getting horrible compile times from PGI C++ compilers greater than version 10.9. Under 10.9 his code compiles in about 8 seconds. For 11 and newer it takes around 13 minutes.
The following code and test.sh runscript demonstrate essentially what the user is doing.
slow_demo.cc:
#include <string>
using std::string;
enum FuncType {FUNC_};
class Function
{
public:
Function();
Function(string a, int n, string b);
string get_a() { return a; }
string get_b() { return b; }
private:
int n;
string a;
string b;
};
void init()
{
int f[32];
f[0] = 0;
f[1] = 0;
f[2] = 0;
f[3] = 0;
f[4] = 0;
f[5] = 0;
f[6] = 0;
f[7] = 0;
f[8] = 0;
f[9] = 0;
f[10] = 0;
f[11] = 0;
f[12] = 0;
f[13] = 0;
f[14] = 0;
f[15] = 0;
f[16] = 0;
f[17] = 0;
f[18] = 0;
f[19] = 0;
f[20] = 0;
f[21] = 0;
f[22] = 0;
f[23] = 0;
f[24] = 0;
f[25] = 0;
f[26] = 0;
f[27] = 0;
f[28] = 0;
f[29] = 0;
f[30] = 0;
f[31] = 0;
}
test.sh
#!/bin/bash
#
# This script demonstrates a problem with PGI 11 and 12.x (x < 4).
# Compile time increases superlinearly with the number of
# Function declarations in the init() function.
#
time pgCC -w -c slow_demo.cc
cp slow_demo.cc test.cc
for i in `seq 0 $1`
do
sed "s/ f.${i}. = 0;/ Function f${i}(\"f${i}\", 1, \"real\");/" test.cc > sed.out
mv -f sed.out test.cc
time pgCC -w -c test.cc
done
#
# All done
#
Here are the results of running this using PGI C++ v. 10.9. As you can see, the compile time remains relatively flat.
$ pgcc -V
pgcc 10.9-0 64-bit target on x86-64 Linux -tp istanbul-64
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2010, STMicroelectronics, Inc. All Rights Reserved.
$ ./test.sh 30 2>&1 | grep real
real 0m0.327s
real 0m0.347s
real 0m0.350s
real 0m0.354s
real 0m0.359s
real 0m0.358s
real 0m0.363s
real 0m0.363s
real 0m0.367s
real 0m0.370s
real 0m0.375s
real 0m0.375s
real 0m0.378s
real 0m0.380s
real 0m0.382s
real 0m0.386s
real 0m0.387s
real 0m0.391s
real 0m0.394s
real 0m0.391s
real 0m0.395s
real 0m0.399s
real 0m0.402s
real 0m0.402s
real 0m0.407s
real 0m0.411s
real 0m0.411s
real 0m0.414s
real 0m0.415s
real 0m0.419s
real 0m0.423s
real 0m0.428s
And here is what happens when we use PGI 11.10. We get similar timings for PGI 12.4 and 12.5 as well.
$ pgcc -V
pgcc 11.10-0 64-bit target on x86-64 Linux -tp istanbul
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2011, STMicroelectronics, Inc. All Rights Reserved.
./test.sh 30 2>&1 | grep real
real 0m0.317s
real 0m0.351s
real 0m0.353s
real 0m0.363s
real 0m0.372s
real 0m0.411s
real 0m0.408s
real 0m0.446s
real 0m0.501s
real 0m0.581s
real 0m0.711s
real 0m0.901s
real 0m1.187s
real 0m1.591s
real 0m2.164s
real 0m2.974s
real 0m4.068s
real 0m5.521s
real 0m7.440s
real 0m9.973s
real 0m13.222s
real 0m17.216s
real 0m22.349s
real 0m28.791s
real 0m36.798s
real 0m46.748s
real 0m58.346s
real 1m12.720s
real 1m29.976s
real 1m49.561s
real 2m13.474s
real 2m42.062s