This article has multiple issues. Please helpimprove it or discuss these issues on thetalk page.(Learn how and when to remove these messages) (Learn how and when to remove this message)
|
| Coarray Fortran | |
|---|---|
| Paradigm | multi-paradigm:parallel,message passing,imperative (procedural,object-oriented),structured |
| Designed by | Robert Numrich and John Reid |
| Developer | PL22.3 Fortran Committee |
| Stable release | Fortran 2008 (ISO/IEC 1539-1:2010) |
| Typing discipline | strong,static |
| OS | Cross-platform |
| Majorimplementations | |
| Cray,g95,GNU Fortran,Intel Fortran Compiler,Rice CAF 2.0, OpenUH,NAG Fortran Compiler | |
| Influenced by | |
| Fortran | |
Coarray Fortran (CAF), formerly known asF--, started as an extension ofFortran 95/2003 forparallel processing created by Robert Numrich and John Reid in the 1990s. TheFortran 2008 standard (ISO/IEC 1539-1:2010) now includescoarrays (spelled without hyphen), as decided at the May 2005 meeting of the ISO Fortran Committee; the syntax in the Fortran 2008 standard is slightly different from the original CAF proposal.
A CAFprogram is interpreted as if it were replicated a number of times and all copies were executed asynchronously. Each copy has its own set of data objects and is termed animage. Thearray syntax of Fortran is extended with additional trailing subscripts in square brackets to provide a concise representation of references to data that is spread across images.
The CAF extension was implemented in some Fortrancompilers such as those fromCray (since release 3.1). Since the inclusion of coarrays in the Fortran 2008 standard, the number of implementations is growing. The firstopen-source compiler which implemented coarrays as specified in the Fortran 2008 standard forLinux architectures isG95. Currently,GNU Fortran provides wide coverage of Fortran's coarray features in single- and multi-image configuration (the latter based on the OpenCoarrays library). Another implementation of coarrays and relatedparallel extensions from Fortran 2008 is available in the OpenUH compiler (a branch ofOpen64) developed at theUniversity of Houston.
CAF is often implemented on top of aMessage Passing Interface (MPI) library for portability. Some implementations, such as the ones available in theGNU Fortran and OpenUH compilers, may run on top of other low-level layers (for example, GASNet) designed for supportingpartitioned global address space languages.
A simple example is given below. CAF is used in CGPACK, an open source package for simulating polycrystalline materials developed at theUniversity of Bristol.[1]
programHello_Worldimplicit noneinteger::i! Local variablecharacter(len=20)::name[*]! scalar coarray, one "name" for each image.! Note: "name" is the local variable while "name[<index>]" accesses the! variable in a specific image; "name[this_image()]" is the same as "name".! Interact with the user on Image 1; execution for all others pass by.if(this_image()==1)then write(*,'(a)',advance='no')'Enter your name: 'read(*,'(a)')name! Distribute information to other imagesdoi=2,num_images()name[i]=nameend do end if sync all! Barrier to make sure the data have arrived.! I/O from all images, executing in any order, but each record written is intact.write(*,'(3a,i0)')'Hello ',trim(name),' from image ',this_image()end programHello_world
The program above scales poorly because the loop that distributes information executes sequentially. Writing scalable programs often requires a sophisticated understanding of parallel algorithms, a detailed knowledge of the underlying network characteristics, and special tuning for application characteristics such as the size of data transfers. For most application developers, letting the compiler or runtime library decide the best algorithm proves more robust and high-performing. Fortran 2018 will offer collective communication subroutines that empower compiler and runtime library teams to encapsulate efficient parallel algorithms for collective communication and distributed computation in a set of collective subroutines. These subroutines and other new parallel programming features are summarized in a technical specification[2] that the Fortran standards committee has voted to incorporate into Fortran 2018. These enable the user to write a more efficient version of the above algorithm
programHello_Worldimplicit nonecharacter(len=20)::name[*]! scalar coarray, one "name" for each image.! Note: "name" is the local variable while "name[<index>]" accesses the! variable in a specific image; "name[this_image()]" is the same as "name".! Interact with the user on Image 1; execution for all others pass by.if(this_image()==1)then write(*,'(a)',advance='no')'Enter your name: 'read(*,'(a)')nameend if! Distribute information to all imagescallco_broadcast(name,source_image=1)! I/O from all images, executing in any order, but each record written is intact.write(*,'(3a,i0)')'Hello ',trim(name),' from image ',this_image()end programHello_world
where the lack of explicit synchronization offers the potential for higher performance due to less coordination between the images. Furthermore, TS 18508 guarantees that "A transfer from an image cannot occur before the collective subroutine has been invoked on that image." This implies some partial synchronization inside co_broadcast, but could be higher performing than the "sync all" in the prior example. TS 18508 also incorporates several other new features that address issues targeted by the CAF 2.0 effort described below. Examples include teams of images and events.
This sectionmay beunbalanced towards certain viewpoints. Please helpimprove it by adding information on neglected viewpoints. Relevant discussion may be found on thetalk page.(September 2018) |
This sectionmay rely excessively on sourcestoo closely associated with the subject, potentially preventing the article from beingverifiable andneutral. Please helpimprove it by replacing them with more appropriatecitations toreliable, independent sources.(November 2021) (Learn how and when to remove this message) |
In 2011,Rice University pursued an alternate vision of coarray extensions for the Fortran language.[3] Their perspective is that the Fortran 2008 standard committee's design choices were shaped more by the desire to introduce as few modifications to the language as possible than to assemble the best set of extensions to supportparallel programming. In their view, both Numrich and Reid's original design and the coarray extensions proposed for Fortran 2008 suffer from the following shortcomings:
To address these shortcomings, the Rice University group is developing a clean-slate redesign of the Coarray Fortran programming model. Rice's new design for Coarray Fortran, which they call Coarray Fortran 2.0, is an expressive set of coarray-based extensions to Fortran designed to provide a productiveparallel programming model. Compared to Fortran 2008, Rice's new coarray-based language extensions include some additional features: