Further reading
Summary
Guide To Learn
Summary
If you’ve practiced using the this_image and num_images built-in functions long enough, the solution will be straightforward. For any image that calls this function, its left neighbor will be this_image() – 1, and its right neighbor this_image() + 1. (Except when this_image() is at the boundary, that is, this_image() == 1 or this_image() == num_images().) The following listing provides the solution. Listing 7.9 Calculating the index of neighbor images ❶ Two-element integer array to store the result […]
We need a function that returns a start and end index for each image, given the integer size of the global array to be decomposed. For example, for an input 100 and total number of images 2, the result should be [1, 50] on image 1 and [51, 100] on image 2. When the input is divisible by num_images(), the solution is straightforward. […]
We’re now ready to apply the parallel skills we learned in this chapter: referencing coarray elements from other images to exchange data, and synchronizing the images. Following the halo exchange pattern in figure 7.9, for both the water height and velocity arrays, we’ll copy the elements from each end into the halo cells of each […]
To allocate the water height and velocity as coarrays over appropriate sections, we need to know their start and end indices on each image. Sounds familiar? We already did this in section 7.3 and exercise 1! All we have to do here is properly call that function and store the start and end indices in […]
Looking back at figure 7.9, it’s obvious who the neighbors are for each image. For image 1, the left and right neighbors are images 3 and 2, respectively. For image 2, they’re images 1 and 3. And for image 3, they’re images 2 and 1. Let’s generalize this rule so that it works for any […]
Before we start refactoring the solver for parallel execution, let’s refresh our memory about where we left off. Relative to the top-level directory of the project, the main program is located in src/ch04/tsunami.f 90. The core of our solver is the do loop to integrate the solution in time: ❶ Iterates in time ❷ Solves for velocity ❸ Solves for […]
If you’re reading this book in order, you know that we’ve been building a tsunami simulator from scratch, and adding more to it in each chapter. In this chapter, we’ll still refactor the tsunami code and apply what we’ve just learned. However, unlike in previous chapters, this time our simulation results will be exactly the […]
When executing the program on multiple images, there’s no imposed order in which the images execute–they all run at their own pace and independently from each other. Any program that requires an exchange of data between processors will also require synchronization at one or more times during the calculation. This is true of the tsunami […]