POOMA provides different containers and processor configurations and supports different implementation styles, as described in Section 1.1. In this chapter, we present several different implementations of the Doof2d two-dimensional diffusion simulation program:
a C-style implementation omitting any use of POOMA and computing each array element individually,
a POOMA Array implementation computing each array element individually,
a POOMA Array implementation using data-parallel statements,
a POOMA Array implementation using stencils, which support local computations,
a stencil-based POOMA Array implementation supporting computation on multiple processors
a POOMA Field implementation using data-parallel statements, and
a data-parallel POOMA Field implementation for multiprocessor execution.
These illustrate the Array, Field, Engine, layout, mesh, and Domain data types. They also illustrate various immediate computation styles (element-wise accesses, data-parallel expressions, and stencil computation) and various processor configurations (one processor and multiple processors).
The Doof2d diffusion program starts with a two-dimensional grid of values. To model an initial density, all grid values are zero except for one nonzero value in the center. Each averaging, each grid element, except the outermost ones, updates its value by averaging its value and its eight neighbors. To avoid overwriting grid values before all their uses occur, we use two arrays, reading the first and writing the second and then reversing their roles within each iteration.
We illustrate the averagings in Figure 3-1. Initially, only the center element has nonzero value. To form the first averaging, each element's new value equals the average of its and its neighbors' previous values. Thus, the initial nonzero value spreads to a three-by-three grid. The averaging continues, spreading to a five-by-five grid of nonzero values. Values in the outermost grid cells are always zero.
Before presenting the various implementations of Doof2d, we explain how to install the POOMA Toolkit.