Caffeine

Caffeine: A parallel runtime library for supporting modern Fortran compilers - Published in JOSS (2025)

https://github.com/berkeleylab/caffeine

Science Score: 98.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 7 DOI reference(s) in README and JOSS metadata
  • Academic publication links
  • Committers with academic emails
    4 of 8 committers (50.0%) from academic institutions
  • Institutional organization owner
    Organization berkeleylab has institutional domain (www.lbl.gov)
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

coarray coarray-fortran fortran-2018 fortran-2023 parallel-computing parallel-programming parallelism partitioned-global-address-space pgas runtime-library

Scientific Fields

Materials Science Physical Sciences - 40% confidence
Last synced: 4 months ago · JSON representation

Repository

A parallel runtime library for Fortran compilers

Basic Info
  • Host: GitHub
  • Owner: BerkeleyLab
  • License: other
  • Language: Fortran
  • Default Branch: main
  • Homepage: https://go.lbl.gov/caffeine
  • Size: 2.19 MB
Statistics
  • Stars: 48
  • Watchers: 6
  • Forks: 10
  • Open Issues: 18
  • Releases: 6
Topics
coarray coarray-fortran fortran-2018 fortran-2023 parallel-computing parallel-programming parallelism partitioned-global-address-space pgas runtime-library
Created almost 4 years ago · Last pushed 4 months ago
Metadata Files
Readme Contributing License

README.md

Caffeine

CoArray Fortran Framework of Efficient Interfaces to Network Environments

Caffeine is a parallel runtime library that aims to support Fortran compilers with a programming-model-agnostic application interface to various communication libraries. Current work is on supporting the Parallel Runtime Interface for Fortran (PRIF) with the GASNet-EX exascale-ready networking middleware. Future plans include support for an alternative Message Passing Interface (MPI) back end.

Caffeine system stack diagram

Statement of need

The Fortran programming language standard added features supporting single-program, multiple-data (SPMD) parallel programming and loop parallelism beginning with Fortran 2008. In Fortran, SPMD programming involves the creation of a fixed number of images (instances) of a program that execute asynchronously in shared or distributed memory, except where a program uses specific synchronization mechanisms. Fortran's "coarray" distributed data structures offer a subscripted, multidimensional array notation defining a partitioned global address space (PGAS). One image can use this notation for one-sided access to another image's slice of a coarray.

Fortran 2018 greatly expanded this feature set to include such concepts as teams (groupings) of images, events (counting semaphores), collective subroutines and failed-image detection (fault tolerance). Fortran 2023 provided additional, minor multi-image extensions, including notified remote data access.

Several popular Fortran compilers, including LLVM flang and LFortran, currently lack support for multi-image parallel execution. These features are a mandatory part of Fortran, and thus are an important part of reaching full compliance with the 2008, 2018, or 2023 versions of the Fortran standard.

Caffeine aims to provide a portable, high-performance and open-source parallel runtime library that such compilers can target in code generation as part of their solution to support Fortran's multi-image parallel features.

Prerequisites & Dependencies

Build prerequisites

The install.sh script uses the following packages: * Fortran and C compilers * We regularly test with: gfortran v13, v14 and LLVM Flang 19, 20 * On macOS the Homebrew-installed llvm and flang packages may require some additional settings, see issue #228 for the latest information. * Fortran package manager fpm * pkg-config * realpath * make * git * curl

The script will invoke these if present in a user's PATH. If not present, the script will ask permission to use Homebrew to install the relevant package or, in some cases, ask the user to install the package.

Build dependencies

Caffeine also depends on the following packages that will be automatically installed as part of the build process.

Caffeine leverages the following non-parallel features of Fortran to simplify the writing of a portable, compact runtime-library that supports Fortran's parallel features:

| Feature | Introduced in | |-------------------------------------------|---------------| | The iso_c_binding module | Fortran 2003 | | The contiguous attribute | Fortran 2008 | | Submodule support [1] | Fortran 2008 | | The ISO_Fortran_binding.h C header file | Fortran 2018 | | Assumed-type dummy arguments: type(*) | Fortran 2018 | | Assumed-rank dummy arguments: array(..) | Fortran 2018 |

[1] This feature simplifies development but is not essential to the package

Download, build, and run an example

Here is an outline of the basic commands used to build Caffeine and run an example:

git clone https://github.com/BerkeleyLab/caffeine.git cd caffeine env FC=<Fortran-compiler> CC=<C-compiler> CXX=<C++-compiler> ./install.sh <options> env CAF_IMAGES=8 ./build/run-fpm.sh run --example hello

The provided compilers MUST be "compatible": for the best experience you are HIGHLY recommended to specify the language frontends provided by a single version of a given compiler suite installation. The C++ compiler is optional for single-node deployments (and can be disabled using command-line option --without-cxx), but C++ is required for some network backends.

The install.sh recognizes a number of command-line options and environment variables to customize behavior for your system. See the output of ./install.sh --help for full documentation, including options for how to build for a distributed memory platform.

Example Usage

The Caffeine parallel runtime is intended as an embedded compilation target library, to provide multi-image parallel runtime support to a Fortran compiler. As such, real usage of Caffeine is specific to the host Fortran compiler, and one should consult compiler-provided documentation regarding the use of Caffeine to back multi-image features.

However we provide an example hello world program, written in Fortran, simulating the PRIF calls that a theoretical source-to-source Fortran compiler might generate for a simple program written using Fortran's multi-image features to print a message from each image.

Run tests

./build/run-fpm.sh test

Recognized Environment Variables

The following environment variables control the execution of the fpm-driven Caffeine unit test suite:

  • CAF_IMAGES: integer that indicates the number of images to run
  • SUBJOB_PREFIX: command prefix to use for recursive fpm invocations in the test suite. Set SUBJOB_PREFIX=skip to disable such invocations (recommended for distributed-memory systems).

The following environment variables control the behavior of the Caffeine library:

  • CAF_HEAP_SIZE=128MB: set the size of the shared-memory heap used for coarray storage, defaults to 128 MiB
  • CAF_COMP_FRAC=0.10: set the fraction of the shared-memory heap reserved for non-symmetric allocation, defaults to 10%

Caffeine is built atop the GASNet-EX exascale networking middleware, which has its own set of environment variable knobs to control network-level behavior. Here are a few of the most useful GASNet knobs:

  • GASNET_VERBOSEENV=1: enable console output of all the envvar settings affecting GASNet operation
  • GASNET_SPAWN_VERBOSE=1: enable verbose console output of parallel job-spawning steps
  • GASNET_BACKTRACE=1: enable automatic backtrace upon fatal errors
  • GASNET_SSH_SERVERS="host1 host2": space-deliminted list of hostnames for distributed-memory job launch using the ssh-spawner

See GASNet documentation for full details on all settings.

Implementation Status

Caffeine is an implementation of the Parallel Runtime Interface for Fortran (PRIF)

PRIF system stack diagram

For details on the PRIF features that are implemented, please see the Implementation Status doc.

Publications

Citing Caffeine? Please use the following publication:

Damian Rouson, Dan Bonachea.
"Caffeine: CoArray Fortran Framework of Efficient Interfaces to Network Environments",
Proceedings of the Eighth Annual Workshop on the LLVM Compiler Infrastructure in HPC (LLVM-HPC2022), November 2022.
Paper: https://doi.org/10.25344/S4459B
Talk Slides

Citing PRIF? Please use the following publication:

Dan Bonachea, Katherine Rasmussen, Brad Richardson, Damian Rouson.
"Parallel Runtime Interface for Fortran (PRIF): A Multi-Image Solution for LLVM Flang",
Proceedings of the Tenth Annual Workshop on the LLVM Compiler Infrastructure in HPC (LLVM-HPC2024), November 2024.
Paper: https://doi.org/10.25344/S4N017
Talk Slides

PRIF Specification:

Dan Bonachea, Katherine Rasmussen, Brad Richardson, Damian Rouson.
"Parallel Runtime Interface for Fortran (PRIF) Specification, Revision 0.5",
Lawrence Berkeley National Laboratory Technical Report (LBNL-2001636), Dec 2024.
https://doi.org/10.25344/S4CG6G

Funding

The Computer Languages and Systems Software (CLaSS) Group at Berkeley Lab has developed Caffeine on funding from the Exascale Computing Project (ECP) and the Stewardship for Programming Systems and Tools (S4PST) project, part of the Consortium for the Advancement of Scientific Software (CASS).

Support and Licensing

See CONTRIBUTING.md for guidelines on reporting defects, feature requests and contributing to Caffeine.

See LICENSE.txt for usage terms and conditions.

Owner

  • Name: Berkeley Lab
  • Login: BerkeleyLab
  • Kind: organization
  • Location: Berkeley, CA

Lawrence Berkeley National Laboratory

JOSS Publication

Caffeine: A parallel runtime library for supporting modern Fortran compilers
Published
March 29, 2025
Volume 10, Issue 107, Page 7895
Authors
Dan Bonachea ORCID
Lawrence Berkeley National Laboratory, United States
Katherine Rasmussen ORCID
Lawrence Berkeley National Laboratory, United States
Brad Richardson ORCID
Lawrence Berkeley National Laboratory, United States
Damian Rouson ORCID
Lawrence Berkeley National Laboratory, United States
Editor
Daniel S. Katz ORCID
Tags
high-performance computing parallel programming compilers coarrays

GitHub Events

Total
  • Create event: 34
  • Release event: 3
  • Issues event: 81
  • Watch event: 6
  • Delete event: 29
  • Issue comment event: 55
  • Push event: 193
  • Gollum event: 7
  • Pull request review comment event: 132
  • Pull request review event: 178
  • Pull request event: 119
  • Fork event: 4
Last Year
  • Create event: 34
  • Release event: 3
  • Issues event: 81
  • Watch event: 6
  • Delete event: 29
  • Issue comment event: 55
  • Push event: 194
  • Gollum event: 7
  • Pull request review comment event: 132
  • Pull request review event: 178
  • Pull request event: 119
  • Fork event: 4

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 783
  • Total Committers: 8
  • Avg Commits per committer: 97.875
  • Development Distribution Score (DDS): 0.695
Past Year
  • Commits: 299
  • Committers: 4
  • Avg Commits per committer: 74.75
  • Development Distribution Score (DDS): 0.388
Top Committers
Name Email Commits
Damian Rouson r****n@l****v 239
Katherine Rasmussen k****n@l****v 231
Dan Bonachea d****a@l****v 199
Brad Richardson e****l@p****m 92
Wileam Yonatan Phan w****n@r****u 17
Armin Wehrfritz a****z@u****i 2
Dominick D****z 2
ArthurPV a****s@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 88
  • Total pull requests: 180
  • Average time to close issues: 3 months
  • Average time to close pull requests: 8 days
  • Total issue authors: 6
  • Total pull request authors: 7
  • Average comments per issue: 0.35
  • Average comments per pull request: 0.63
  • Merged pull requests: 154
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 44
  • Pull requests: 137
  • Average time to close issues: 22 days
  • Average time to close pull requests: 8 days
  • Issue authors: 4
  • Pull request authors: 6
  • Average comments per issue: 0.32
  • Average comments per pull request: 0.39
  • Merged pull requests: 112
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • bonachea (38)
  • ktras (37)
  • rouson (8)
  • everythingfunctional (3)
  • MichaelSiehl (1)
  • wyphan (1)
Pull Request Authors
  • bonachea (75)
  • ktras (55)
  • rouson (24)
  • everythingfunctional (18)
  • danielskatz (4)
  • ArthurPV (2)
  • Montana (2)
Top Labels
Issue Labels
enhancement (10) priority=low (9) priority=high (8) bug (7) priority=medium (6) collective subroutines (3) release-blocker (3) flang-build-blocker (2) complete-before-release (2) documentation (1)
Pull Request Labels
priority=high (2)

Dependencies

.github/workflows/CI.yml actions
  • actions/checkout v1 composite
  • fortran-lang/setup-fpm v4 composite
.github/workflows/deploy-docs.yml actions
  • JamesIves/github-pages-deploy-action 4.1.0 composite
  • actions/checkout v2 composite
  • actions/upload-artifact v2 composite
  • technote-space/broken-link-checker-action v1 composite