2

Intel documentation doesn't clarify if one does e.g. multiplication and addition of arrays:

c[:] = c[:] + a[:]*b[:]

will it do the following:

for(i=0; i<N; i++) tmp[i] = a[i]*b[i];
for(i=0; i<N; i++) c[i] = c[i] + tmp[i];

OR

for(i=0; i<N; i++) c[i] = c[i] + a[i]*b[i];

For large arrays there is a significant performance difference. As far as I know when such vector operations are done using STL vectors, the former one is done.

Thank you in advance for the answers!

laszlo.endre
  • 290
  • 2
  • 14

1 Answers1

1

Array notation in icc 12.1 generated the temporary, since that is what Fortran does and it seemed safer. Then we discovered that the temporaries, as the question notes, can have a big performance impact. So array notation was revised in icc 13.0 (and in the public specification) so that no temporary is generated.

Not generating a temporary is consistent with C++'s philosophy of "abstraction with minimal penalty", and the fact that C/C++ do not generate temporaries for structure assignments.

See also slide 33 of my ISC 2012 tutorial.

Arch D. Robison
  • 3,829
  • 2
  • 16
  • 26