I have a program dealing with multiple nested loops, operating on a 3D domain:
unsigned int sX(m_sizeZ*m_sizeY);
unsigned int b(sX+m_sizeZ);
for(unsigned int i(1);i<m_sizeX-1;i++){
for(unsigned int j(1);j<m_sizeY-1;j++){
for(unsigned int k(1);k<m_sizeZ-1;k++){
m_r[b+k]=m_func[b+k]-m_cX*(m_data[b+k-sX]+m_data[b+k+sX]-2.0*m_data[b+k])
-m_cY*(m_data[b+k-m_sizeZ]+m_data[b+k+m_sizeZ]-2.0*m_data[b+k])
-m_cZ*(m_data[b+k-1]+m_data[b+k+1]-2.0*m_data[b+k]);
}
b+=m_sizeZ;
}
b+=2*m_sizeZ;
}
Where my arrays are double of size m_sizeX*m_sizeY*m_sizeZ.
I iterate this way because I don't want to touch the boundaries of the domain.
When compiling with (g++) -msse2 -ftree-vectorizer-verbose=2, I of course get the multiple nested loops note.
Is there any way I could use instead a single loop without (more or less) complicated check operations?
Thanks!