chapter five

5 Parallel algorithms and patterns

 

This chapter covers

  • What parallel algorithms and patterns are and why they are important
  • How to compare the performance of different algorithms
  • What distinguishes parallel algorithms from algorithms in general
  • The importance of parallel patterns

Algorithms are at the core of computational science. Along with data structures, covered in the previous chapter, algorithms form the basis of all computational applications. For this reason, it is important to give careful thought to the key algorithms in your code. Let’s define what we mean by parallel algorithms and parallel patterns

Definition: Parallel Algorithm

-- a well-defined, step-by-step computational procedure that emphasizes concurrency to solve a problem. Examples of algorithms include: sorting, searching, optimization, and matrix operations.

Definition: Parallel Pattern

-- a concurrent, separable, fragment of code that occurs in diverse scenarios with some frequency. By themselves these code fragments generally do not solve complete problems of interest. Some examples are: reductions, prefix scans, and ghost cell updates.

We will show the reduction in section 5.7, the prefix scan in section 5.6, and ghost cell updates in section 8.4.2.

5.1      Algorithm analysis for parallel computing applications

5.2      Performance models versus algorithmic complexity

5.3      Parallel algorithms: what are they?

5.4      What is a hash function?

5.5      Spatial hashing: a highly-parallel algorithm

5.5.1   Using perfect hashing for spatial mesh operations

All of the source code for the examples for the four operations in 1D and 2D is available at https://github.com/lanl/PerfectHash.git under an open-source license. The source is also linked into the examples for the chapter.[1] The PerfectHash code uses cmake and tests for the availability of OpenCL. If you do not have a working OpenCL capability, it will detect that and not compile the OpenCL implementations. The rest of the cases on the CPU will still run.

5.5.2   Using compact hashing for spatial mesh operations

5.6      Prefix sum (scan) pattern and its importance in parallel computing

5.6.1   Step-efficient parallel scan operation

5.6.2   Work-efficient parallel scan operation

5.6.3   Parallel scan operations for large arrays

5.7      Parallel global sum: addressing the problem of associativity

5.8      Future of parallel algorithm research