diff options
author | Michael Hirsch, Ph.D <scivision@users.noreply.github.com> | 2019-02-13 14:09:18 -0500 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-02-13 21:09:18 +0200 |
commit | ebfb09f5d64b8dbb9d10ae57f71a1d7be7fd9137 (patch) | |
tree | 70bf292ef9df5c94a2a34f0202a020315802446a | |
parent | df0b734a17c15c3fb202e27b307f78e7f143c18b (diff) | |
download | meson-ebfb09f5d64b8dbb9d10ae57f71a1d7be7fd9137.zip meson-ebfb09f5d64b8dbb9d10ae57f71a1d7be7fd9137.tar.gz meson-ebfb09f5d64b8dbb9d10ae57f71a1d7be7fd9137.tar.bz2 |
Fortran 2008/2018 Coarray support
-rw-r--r-- | docs/markdown/Dependencies.md | 8 | ||||
-rw-r--r-- | docs/markdown/snippets/coarray.md | 3 | ||||
-rw-r--r-- | mesonbuild/dependencies/__init__.py | 3 | ||||
-rw-r--r-- | mesonbuild/dependencies/base.py | 4 | ||||
-rw-r--r-- | mesonbuild/dependencies/misc.py | 39 | ||||
-rw-r--r-- | test cases/fortran/13 coarray/main.f90 | 9 | ||||
-rw-r--r-- | test cases/fortran/13 coarray/meson.build | 10 |
7 files changed, 73 insertions, 3 deletions
diff --git a/docs/markdown/Dependencies.md b/docs/markdown/Dependencies.md index 259f09e..608f3b2 100644 --- a/docs/markdown/Dependencies.md +++ b/docs/markdown/Dependencies.md @@ -255,6 +255,14 @@ libraries that have been compiled for single-threaded use instead. `method` may be `auto`, `config-tool`, `pkg-config`, `cmake` or `extraframework`. +## Fortran Coarrays + +As of 0.50.0 Coarrays are a Fortran language intrinsic feature, enabled by +`dependency('coarray')`. + +GCC will use OpenCoarrays if present to implement coarrays, while Intel and NAG +use internal coarray support. + ## GL This finds the OpenGL library in a way appropriate to the platform. diff --git a/docs/markdown/snippets/coarray.md b/docs/markdown/snippets/coarray.md new file mode 100644 index 0000000..961dce4 --- /dev/null +++ b/docs/markdown/snippets/coarray.md @@ -0,0 +1,3 @@ +## Fortran Coarray + +Fortran 2008 / 2018 coarray support was added via `dependency('coarray')` diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index f5034db..71a0bb3 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -18,7 +18,7 @@ from .base import ( # noqa: F401 ExternalDependency, NotFoundDependency, ExternalLibrary, ExtraFrameworkDependency, InternalDependency, PkgConfigDependency, CMakeDependency, find_external_dependency, get_dep_identifier, packages, _packages_accept_language) from .dev import GMockDependency, GTestDependency, LLVMDependency, ValgrindDependency -from .misc import (HDF5Dependency, MPIDependency, OpenMPDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency, LibGCryptDependency) +from .misc import (CoarrayDependency, HDF5Dependency, MPIDependency, OpenMPDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency, LibGCryptDependency) from .platform import AppleFrameworks from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, VulkanDependency @@ -32,6 +32,7 @@ packages.update({ # From misc: 'boost': BoostDependency, + 'coarray': CoarrayDependency, 'mpi': MPIDependency, 'hdf5': HDF5Dependency, 'openmp': OpenMPDependency, diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 8196124..f4e47cf 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -14,7 +14,7 @@ # This file contains the detection logic for external dependencies. # Custom logic for several other packages are in separate files. - +from typing import Dict, Any import copy import functools import os @@ -2200,7 +2200,7 @@ def find_external_dependency(name, env, kwargs): return NotFoundDependency(env) -def _build_external_dependency_list(name, env, kwargs): +def _build_external_dependency_list(name, env: Environment, kwargs: Dict[str, Any]) -> list: # First check if the method is valid if 'method' in kwargs and kwargs['method'] not in [e.value for e in DependencyMethods]: raise DependencyException('method {!r} is invalid'.format(kwargs['method'])) diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index e49bdc9..db83422 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -32,6 +32,45 @@ from .base import ( ) +class CoarrayDependency(ExternalDependency): + """ + Coarrays are a Fortran 2008 feature. + + Coarrays are sometimes implemented via external library (GCC+OpenCoarrays), + while other compilers just build in support (Cray, IBM, Intel, NAG). + Coarrays may be thought of as a high-level language abstraction of + low-level MPI calls. + """ + def __init__(self, environment, kwargs): + super().__init__('coarray', environment, 'fortran', kwargs) + kwargs['required'] = False + kwargs['silent'] = True + self.is_found = False + + cid = self.get_compiler().get_id() + if cid == 'gcc': + """ OpenCoarrays is the most commonly used method for Fortran Coarray with GCC """ + self.is_found = True + kwargs['modules'] = 'OpenCoarrays::caf_mpi' + cmakedep = CMakeDependency('OpenCoarrays', environment, kwargs) + if not cmakedep.found(): + self.compile_args = ['-fcoarray=single'] + self.version = 'single image' + return + + self.compile_args = cmakedep.get_compile_args() + self.link_args = cmakedep.get_link_args() + self.version = cmakedep.get_version() + elif cid == 'intel': + """ Coarrays are built into Intel compilers, no external library needed """ + self.is_found = True + self.link_args = ['-coarray=shared'] + self.compile_args = self.link_args + elif cid == 'nagfor': + """ NAG doesn't require any special arguments for Coarray """ + self.is_found = True + + class HDF5Dependency(ExternalDependency): def __init__(self, environment, kwargs): diff --git a/test cases/fortran/13 coarray/main.f90 b/test cases/fortran/13 coarray/main.f90 new file mode 100644 index 0000000..be60552 --- /dev/null +++ b/test cases/fortran/13 coarray/main.f90 @@ -0,0 +1,9 @@ +implicit none + +if (this_image() == 1) print *, 'number of Fortran coarray images:', num_images() + +sync all ! semaphore, ensures message above is printed at top. + +print *, 'Process ', this_image() + +end program diff --git a/test cases/fortran/13 coarray/meson.build b/test cases/fortran/13 coarray/meson.build new file mode 100644 index 0000000..57aa29e --- /dev/null +++ b/test cases/fortran/13 coarray/meson.build @@ -0,0 +1,10 @@ +project('Fortran coarray', 'fortran') + +# coarray is required because single-image fallback is an intrinsic feature +coarray = dependency('coarray', required : true) + +exe = executable('hello', 'main.f90', + dependencies : coarray) + +test('Coarray hello world', exe) + |