Using Coarrays

A coarray is a data sharing concept standardized in Fortran 2008 that allows parallel processing of data shared across multiple images. A Fortran program containing coarrays is interpreted as if it were replicated a fixed number of times and all copies were executed asynchronously. Each copy has its own set of data objects and is called an image. The array syntax of Fortran is extended with additional trailing subscripts in square brackets to represent access to data on other images. Any occurrence of square brackets indicates communication between images, which might be slow. References without square brackets are to local data objects, so code that can run independently is not slowed down by extra overhead.

Coarrays are not supported on Mac OS* X.

Using Correct Coarray Program Syntax

The additional syntax required by coarrays includes:

Note iconNote

ATOMIC_DEFINE and ATOMIC_REF are not supported in this version of Intel® Fortran.

Using the Coarray Compiler Options

Because of the extra overhead in executing a coarray program, you must use the /Qcoarray (Windows* OS) or -coarray (Linux* OS) compiler option to enable the compiler to recognize coarray syntax. If you do not use this compiler option, a program containing coarray declarations (codimensions in square brackets) produces a compile-time error.

Using /Qcoarrays:shared (Windows* OS) or -coarrays=shared (Linux* OS) causes the underlying Intel® Message Passing Interface (MPI) parallelization to run in a single node environment (multiple cores with shared memory). Using -coarrays=distributed (Linux* OS) requires an Intel® Cluster Toolkit license to be installed and causes the underlying Intel® MPI Library parallelization to run on multi-node environment (multiple CPUs with distributed memory). Using /Qcoarrays (Windows* OS) or -coarrays (Linux* OS) with no argument is equivalent to running on multi-node (distributed memory) if an Intel® Cluster Toolkit license is installed or on single node (shared memory) if there is no Intel® Cluster Toolkit license installed.

No special procedure is necessary to run a program that uses coarrays; you simply run the executable file. The underlying parallelization implementation is Intel® MPI Library. Installation of the compiler automatically installs the necessary Intel® MPI run-time libraries to run on shared memory. The Intel® Cluster Toolkit installs the necessary Intel® MPI Library run-time libraries to run on distributed memory. Use of coarray applications with any other MPI implementation, or with OpenMP*, is not supported.

By default, the number of images created is equal to the number of execution units on the current system. You can override that by specifying the option /Qcoarray-num-images:n (Windows* OS) or -coarray-num-images=n (Linux* OS) on the ifort command that compiles the main program. You can also specify the number of images in an environment variable FOR_COARRAY_NUM_IMAGES.

To take advantage of Intel® MPI Library features in the coarrays environment, you can put the command line segments used by "mpiexec -config filename" into a file named filename and pass it to Intel® MPI Library with the /Qcoarray-config-file:filename (Windows* OS) or -coarray-config-file=filename (Linux* OS).

Rules for using an MPI configuration file are as follows:

Examples on Windows* OS:

Examples on Linux* OS:

Optimization Notice

The Intel® MPI Library contains functions that are more highly optimized for Intel microprocessors than for other microprocessors. While the functions in the Intel® MPI library offer optimizations for both Intel and Intel-compatible microprocessors, depending on your code and other factors, you will likely get extra performance on Intel microprocessors.

While the paragraph above describes the basic optimization approach for the Intel® MPI library as a whole, the library may or may not be optimized to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include Intel® Streaming SIMD Extensions 2 (Intel® SSE2), Intel® Streaming SIMD Extensions 3 (Intel® SSE3), and Supplemental Streaming SIMD Extensions 3 (Intel® SSSE3) instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors.

Intel recommends that you evaluate other library products to determine which best meets your requirements.



Submit feedback on this help topic

Copyright © 1996-2010, Intel Corporation. All rights reserved.