Chapter 2. Loop-Level Parallelism

Adrian Jackson, EPCC

Loops are at the heart of the key computational kernels of many applications, especially in computational simulations. Because of the nature of the data that applications or algorithms operate on, data is stored in arrays, often multidimensional in scope. This means that the majority of work in the application is in iterating over those arrays and updating them using the algorithm being employed.

The simplest method for iterating over a multidimensional array in programming languages like C, C++, and Fortran is by using nested loops. Here’s an example in C:

double particles[N][M][P]; . . . for(int i=0; i<N; i++){     for(int j=0; j<M; j++){         for(int k=0; ...

Get OpenACC for Programmers: Concepts and Strategies, First Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.