문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top