Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Coarray Fortran
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Fortran parallel programming extension}} {{Multiple issues| {{More footnotes|date=August 2011}} {{Unfocused|date=November 2021}} }} {{Infobox programming language | name =Coarray Fortran | logo = | paradigm = [[multi-paradigm programming language|multi-paradigm]]: [[parallel programming|parallel]], [[message passing]], [[imperative programming|imperative]] ([[procedural programming|procedural]], [[Object-oriented programming|object-oriented]]), [[structured programming|structured]] | year = | designer = Robert Numrich and John Reid | developer = PL22.3 Fortran Committee | latest_release_version = [[Fortran]] 2008 (ISO/IEC 1539-1:2010) | latest release date = | typing = [[strongly typed programming language|strong]], [[Type system|static]] | implementations = Cray, [[g95]], [[GNU Fortran]], [[Intel Fortran Compiler]], [[#An alternate perspective|Rice CAF 2.0]], OpenUH, [[Numerical Algorithms Group#NAG Fortran Compiler|NAG Fortran Compiler]] | dialects = | influenced_by =[[Fortran]] | influenced = | operating_system = [[Cross-platform]] | website = | file_ext = }} '''Coarray Fortran''' ('''CAF'''), formerly known as '''F--''', started as an extension of [[Fortran]] 95/2003 for [[Parallel computing|parallel processing]] created by Robert Numrich and John Reid in the 1990s. The [[Fortran 2008]] standard (ISO/IEC 1539-1:2010) now includes [[coarray]]s (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 CAF [[computer program|program]] 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 an ''image''. The [[array data structure|array]] 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 Fortran [[compiler]]s such as those from [[Cray]] (since release 3.1). Since the inclusion of coarrays in the Fortran 2008 standard, the number of implementations is growing. The first [[open-source software|open-source]] compiler which implemented coarrays as specified in the Fortran 2008 standard for [[Linux architecture]]s is [[G95]]. 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 related [[Parallel Extensions|parallel extensions]] from Fortran 2008 is available in the OpenUH compiler (a branch of [[Open64]]) developed at the [[University of Houston]]. ==Implementation in compilers== CAF is often implemented on top of a [[Message Passing Interface]] (MPI) library for portability. Some implementations, such as the ones available in the [[GNU Fortran]] and OpenUH compilers, may run on top of other low-level layers (for example, GASNet) designed for supporting [[partitioned global address space]] languages. ==Examples== A simple example is given below. CAF is used in CGPACK, an open source package for simulating polycrystalline materials developed at the [[University of Bristol]]. <ref>A. Shterenlikht, ''[http://www.pgas2013.org.uk/sites/default/files/finalpapers/Day2/R4/1_paper2.pdf Fortran coarray library for 3D cellular automata microstructure simulation] {{Webarchive|url=https://web.archive.org/web/20160304110820/http://www.pgas2013.org.uk/sites/default/files/finalpapers/Day2/R4/1_paper2.pdf |date=2016-03-04 }}'', (2013) In Proc. 7th PGAS conf, Eds. M. Weiland, A. Jackson, N. Johnson, Published by The University of Edinburgh, {{ISBN|978-0-9926615-0-2}}</ref> <syntaxhighlight lang="fortran"> program Hello_World implicit none integer :: i ! Local variable character(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 images do i = 2, num_images() name[i] = name end 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 program Hello_world </syntaxhighlight> 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 <ref>TS 18508 Additional Parallel Features in Fortran</ref> 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 <syntaxhighlight lang="fortran"> program Hello_World implicit none character(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 end if ! Distribute information to all images call co_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 program Hello_world </syntaxhighlight> 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. ==An alternate perspective== {{bias|section|date=September 2018}} {{third party|section|date=November 2021}} In 2011, [[Rice University]] pursued an alternate vision of coarray extensions for the Fortran language.<ref>{{cite web|title=CoArray Fortran 2.0|url=http://caf.rice.edu/}}</ref> 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 support [[parallel programming]]. In their view, both Numrich and Reid's original design and the coarray extensions proposed for Fortran 2008 suffer from the following shortcomings: * There is no support for [[central processing unit|processor]] subsets; for instance, coarrays must be allocated over all images. * The coarray extensions lack any notion of global pointers, which are essential for creating and manipulating any kind of linked data structure. * Reliance on named critical sections for [[mutual exclusion]] hinders [[scalable parallelism]] by associating mutual exclusion with code regions rather than data objects. * Fortran 2008's sync images statement does not provide a safe synchronization space. As a result, synchronization operations in user's code that are pending when a library call is made can interfere with synchronization in the library call. * There are no mechanisms to avoid or tolerate latency when manipulating data on remote images. * There is no support for collective communication. 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 productive [[parallel programming model]]. Compared to Fortran 2008, Rice's new coarray-based language extensions include some additional features: * process subsets known as teams, which support coarrays, collective communication, and relative indexing of process images for pair-wise operations, * topologies, which augment teams with a logical communication structure, * dynamic allocation/deallocation of coarrays and other shared data, * team-based coarray allocation and deallocation, * global pointers in support of dynamic data structures, * support for latency hiding and avoidance, and ** asynchronous copies, ** asynchronous collective operations, and ** function shipping. * enhanced support for synchronization for fine-grain control over program execution. ** safe and scalable support for mutual exclusion, including locks and lock sets, ** events, which provide a safe space for point-to-point synchronization, ** {{not a typo|cofence}}, which forces local completion of asynchronous operations, ** finish, a barrier-like SPMD construct that forces completion of asynchronous operations across a team, ==See also== * [[Array programming]] * [[Chapel (programming language)|Chapel]] * [[Fortress (programming language)|Fortress]] * [[Parallel computing]] * [[Partitioned global address space]] * [[Unified Parallel C]] * [[X10 (programming language)|X10]] ==References== {{Reflist}} ===General=== * [http://www.nag.co.uk/sc22wg5/ ISO Fortran Committee] {{Webarchive|url=https://web.archive.org/web/20110423074710/http://www.nag.co.uk/sc22wg5/ |date=2011-04-23 }} * [http://j3-fortran.org ANSI/INCITS Fortran Committee] * [http://www.nd.edu/~dbalsara/Numerical-PDE-Course Instructional videos on CAF in the Fortran Standard by John Reid (see Appendix B)] * [https://gcc.gnu.org/wiki/Coarray Coarray in GNU Fortran] * [https://gcc.gnu.org/wiki/CoarrayLib CoarrayLib in GNU Fortran] * [http://opencoarrays.org OpenCoarrays library] * [https://www.nag.com/nag-compiler NAG Fortran Compiler] [[Category:Fortran programming language family]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Bias
(
edit
)
Template:Cite web
(
edit
)
Template:ISBN
(
edit
)
Template:Infobox programming language
(
edit
)
Template:Multiple issues
(
edit
)
Template:Not a typo
(
edit
)
Template:Redirect category shell
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Third party
(
edit
)
Template:Unbalanced
(
edit
)
Template:Webarchive
(
edit
)