Skip to content

SIR Execution Model

Hannes Vogt edited this page Jun 17, 2020 · 2 revisions

Parallel Execution model

Each vertical region of the SIR spans a vertical loop over its given iteration interval with a given loop order. Every statement inside a vertical region is executed on the full ij plane before the next one is executed. We assume that individual statements of a stencil are embarrassingly parallel in the horizontal and therefore we do not guarantee a loop order in the horizontal (ij) plane. Every iteration of the k-loop a vertical region represents can only start after all the previous iterations have finished. Every vertical region will start its execution after all the previous vertical regions have been fully executed.

  • vertical_regions are executed sequentially in the order they appear,
  • statements inside vertical_regions are executed as (sequential) for-loops over the k-range, (exception: variable declarations, see below)
  • a statement inside the vertical_region is executed as a parallel for-loop over the horizontal dimension(s) with no guarantee on how statements are executed.

Example

On an applied example, this means

   1 vertical_region(k_start, k_end) // forward
   2   statement1
   3   statement2
   4 vertical_region(k_end, k_start) // backward
   5   statement3
   6   statement4

translates into the following pseudo code

   1  for k = k_start:k_end
   2    parfor ij
   3      statement1
   4    parfor ij
   5      statement2
   6  for k = k_end:k_start
   7    parfor ij
   8      statement3
   9    parfor ij
   10     statement4

where parfor ij means that there is no guarantee of the order in which horizontal points are executed.

Variable declarations

  • variable declarations inside a vertical region are grid-point-local, i.e. there is one variable per grid point

Example

   1 vertical_region(k_start, k_end)
   2   var my_var = some_expression

behaves like

   1  for k = k_start:k_end
   2    2d_temporary my_var
   3    parfor ij
   4      my_var(i,j) = some_expression

Compute Domain

If the vertical region does not specify any horizontal extent, we extend the computation of every statement to ensure that all the data is present that every statement can be executed on the compute domain.

Example

On an applied example, this means

   1 vertical_region(k_start, k_end)
   2   u[i,j,k] = 1
   3   b = u[i-2,j,k] + u[i+1,j,k] + u[i,j-1,k] + u[i,j-2,k]

translates into the following pseudo code

   1  for k = k_start:k_end
   2    parfor i = i_start-2:i_end+1
   3      parfor j = j_start-1:j_end+2
   4        u[i,j,k] = 1
   5    parfor i = i_start:i_end
   6      parfor j = j_start:j_end
   7        b = u[i-2,j,k] + u[i+1,j,k] + u[i,j-1,k] + u[i,j-2,k]