Move if-statements out of the loop, comment on unrolling

parent bc8b4003
......@@ -346,20 +346,29 @@ void SWE_Block::setBoundaryType( const BoundaryEdge i_edge,
boundary[i_edge] = i_boundaryType;
neighbour[i_edge] = i_inflow;
// TODO unrolling seams to help vectorization, but only for the first 2 loops ...
// set bathymetry values in the ghost layer, if necessary
for(int j=0; j<=ny+1; j++) {
float* tmp = b.elemVector();
if( boundary[BND_LEFT] == OUTFLOW || boundary[BND_LEFT] == WALL ) {
//#pragma unroll(4)
for(int j=0; j<=ny+1; j++) {
b[0][j] = b[1][j];
}
}
if( boundary[BND_RIGHT] == OUTFLOW || boundary[BND_RIGHT] == WALL ) {
//#pragma unroll(4)
for(int j=0; j<=ny+1; j++) {
b[nx+1][j] = b[nx][j];
}
}
for(int i=0; i<=nx+1; i++) {
if( boundary[BND_BOTTOM] == OUTFLOW || boundary[BND_BOTTOM] == WALL ) {
for(int i=0; i<=nx+1; i++) {
b[i][0] = b[i][1];
}
}
if( boundary[BND_TOP] == OUTFLOW || boundary[BND_TOP] == WALL ) {
for(int i=0; i<=nx+1; i++) {
b[i][ny+1] = b[i][ny];
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment