concept step in category parallel computing

appears as: steps, Step, steps, step, The steps
Parallel and High Performance Computing

This is an excerpt from Manning's book Parallel and High Performance Computing.

Computational problems are solved by developing algorithms, a set of steps to achieve a desired result. In the supermarket analogy, the algorithm is the process of checking out. In this case, it includes unloading items from a basket, scanning the items to obtain a price, and paying for the items. This algorithm is sequential, or “serial”, and must follow this order. When there are hundreds of customers that need to execute this task, the algorithm for checking out many customers contains parallelism that can be taken advantage of; theoretically, there is no dependency between any two customers going through the checkout process. By having multiple checkout lines or self-checkout stations, supermarkets have exposed parallelism to increase the rate at which customers can buy goods and leave the store. Each choice in how the parallelism is exposed results in different costs and benefits. Parallel computing is the practice of identifying and exposing parallelism in algorithms, expressing this parallelism in software, and understanding the costs, benefits, and limitations of the chosen parallel implementation.

Now, to improve the OpenMP performance, we insert pragmas in the initialization loops as shown in listing 7.8. The loops will be distributed in the same static threading partition, so the threads that touch the memory in the initialization loop will have the memory located near to them by the operating system as shown in the right side of figure 7.5.

Figure 7.10 The next steps for high-level OpenMP are to add nowait clauses to do or for loops to reduce synchronization costs. Then we calculate the loop bounds ourselves and explicitly use them in the loops to avoid even more synchronization. Here, the cheetah is on the left and hawk is on the right, identifying the changes made in both implementations. The hawk is faster than the cheetah as the overhead of the OpenMP is reduced.

Reducing thread synchronization - By default, there is a synchronization added to every for loop in OpenMP. Therefore, the easiest way to reduce synchronization cost is to add nowait clauses to all loops where it is possible while maintaining correctness. A further step is to explicitly divide the work among threads. The typical code for explicitly dividing the work is shown for C. The Fortran equivalent accounting for arrays starting at 1 is shown in figure 7.10.

tbegin = N *  threadID   /nthreads
tend   = N * (threadID+1)/nthreads