Fortran

Guide To Learn

The final stretch

Broadcasting values to other images

While all images must execute the call to co_broadcast, the specified image acts as the sender, and all others act as receivers. Figure 12.5 illustrates an example of this functioning. Figure 12.5 A collective broadcast from image 1 to the other three images, with arrows indicating the possible data flow direction The inner workings of this procedure, […]

Collective subroutines syntax

Fortran 2018 defines a total of five collective subroutines: These cover most collective operations that you’ll likely encounter in your work. However, the language won’t stop you from implementing your own custom collectives using coarrays and synchronization, should you ever need them. The rest of this section describes co_sum and co_broadcast in more detail. To learn more about co_reduce, the […]

Computing the minimum and maximum of distributed arrays

Let’s try this out in the tsunami simulator. In our working version of the simulator so far, for every time step, we were reporting the time step count to the screen, while the program was writing raw data into files in the background: ❶ Initialization part of the program ❷ Iterates through simulation time steps ❸ If image […]

Distributed computing using collectives

In chapter 7, you learned how to use coarrays and their square bracket syntax to exchange values between parallel images. This mechanism for data exchange is simple and to the point–you as the programmer explicitly instruct the computer to send and receive data between images. For common calculations across many images, such as a global […]

Counting event posts

As you work with events, you’ll soon find it useful to query an event variable to find out how many times an event has been posted. The built-in subroutine event_query does exactly this where event_var is the input variable of type event_type, and count is the output integer number of events posted. Unlike the event wait statement, calling event _query doesn’t block execution but simply returns the […]

Waiting for an event

Images posting events is just one side of the transaction. For an image to wait for the event that it owns, it needs to execute the event wait statement. This statement has the syntax where In a nutshell, event wait blocks the image that executes it until some other image posts an event to it. If until_count is provided and greater than 1, the […]

Posting an event

The first step to any work with events is to post them using the event post statement, which takes the general form where event_var is a variable of event_type, and stat and errmsg have the same meaning as they do in the form team and change team statements. While not strictly required by the language, you’d always want to post to an event variable on another image by coindexing it (indexing a coarray); […]

A push notification example

In this section, we’ll build from our tsunami teams example and use events to post updates from the simulation team to the logging team about data being written to disk. While this is technically doable with coarrays alone, you’ll see that events are a perfect candidate for such parallel patterns. Before we jump back into […]

Posting and waiting for events

In the previous section, we used teams to distribute work among groups of images. Teams allow us to express some parallel patterns and synchronization more elegantly than we otherwise could by controlling individual images directly. Fortran 2018 introduces another new parallel concept called events, provided through the built-in derived type called event_type. In a nutshell, you can post […]

Synchronizing teams and exchanging data

We’ve learned so far, both from coarrays in chapter 7 and from developing the parallel tsunami simulator, that synchronizing images is crucial for writing correct parallel programs. Recall that when we have data dependency between parallel images, one image must wait for data from another image before proceeding with its own calculation. This subsection explains […]

Scroll to top