Hi, during optimization of my code I found that even simple C++ std::complex operations are not vectorized. See following code ///////////////////////////////////// #ifdef USE_CPP #include typedef std::complex cmplx16; #else #include typedef complex double cmplx16; #endif // USE_CPP #define simd_for _Pragma ("simd") for void sum(int Nx, int Ny, int Nz, cmplx16 A[Nx][Ny][Nz], cmplx16 B[Nx][Ny][Nz], cmplx16 C[Nx][Ny][Nz]) { __assume_aligned(A,32); __assume_aligned(B,32); __assume_aligned(C,32); for(int x=0; x C[x][y][z] = A[x][y][z] + B[x][y][z]; } } } } ////////////////////// Compiling with icc (or icpc) to use C (complex doubles) outputs $> icc -c vector.cpp -vec-report=2 -O3 -mavx ... outputs vector.cpp(18): (col. 54) remark: SIMD LOOP WAS VECTORIZED. However, using C++ (std::complex), outputs $> icc -c vector.cpp -vec-report=2 -complex-limited-range -O3 -mavx -DUSE_CPP vector.cpp(20): (col. 29) remark: loop was not vectorized: unsupported data type. vector.cpp(18): (col. 54) warning #13379: loop was not vectorized with "simd" Thus obviously vectorization is not supported for C++ complex numbers but for C. With -guide-vec=2 I can trace the problem to /usr/include/c++/4.4.6/complex(321): (col. 24) remark: loop was not vectorized: unsupported data type. However, is there anyway to enable proper vectorization using some kind of pragmas or a different libstdc++ implementation or MKL or ... ? If not, is this going to be fixed in the near future or is the general advice to use C complex numbers in C++ code in case of doing explicit real/imaginary part calculations is not an option ? thanks a lot ! Paul
Vectorization of complex number operations using Cilk Plus (C++)
Пожалуйста, обратитесь к странице Уведомление об оптимизации для более подробной информации относительно производительности и оптимизации в программных продуктах компании Intel.


