Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Intel c++ slow newing classes inheriting from templated class

ben5
Beginner
417 Views
Hi

Given some code like this where a class inherits from a template class, the intel c++ compiler is about 100 times slower than g++ at newing an array:

class A {
public:
};

template
class B : public T{
public:
B(){}
};

void someFunction {
int numPixels = 1000000;
B * newPixels = new B[numPixels];
}

This may seem like strange code, but unfortunately a lot of our code has to be written like this for a number of reasons. If you remove the default constructor it fixes the problem, but unfortunately in our real code we have non-default constructors as well (so we need the default one). I realise we could just do a malloc or the like, ...



0 Kudos
2 Replies
micahe
Beginner
417 Views
Hi Ben,

Is the optimizer by chance turned off (using -g)? If so, try using -O explicitly. If not, you should report this as a bug to https://premier.intel.com , where you'll be prompted for some important system parameters upon filing the ticket.

If possible, it would be helpful to have a main function to demonstrate/drive the 100x slowdown you describe.

-- MicahE
0 Kudos
ben5
Beginner
417 Views
Hi Micah,

I'm attaching a main.cpp which will exhibit the behaviour. The two compile lines are as follow:

icpc -axNP -mcpu=pentium4 -msse2 -ansi-alias -funroll-loops -static -march=pentium4 -O3 main.cpp

and

g++ -mcpu=pentium4 -msse2 -funroll-loops -static -march=pentium4 -O3 main.cpp

The intel version takes about 4.5 secs and the g++ version about 0.04. I'll take your advice and log this as a bug, but I've attached the file in case you're interested.

Thanks

Ben
0 Kudos
Reply