aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/frameworks/17 mpi
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/frameworks/17 mpi')
-rw-r--r--meson/test cases/frameworks/17 mpi/main.c27
-rw-r--r--meson/test cases/frameworks/17 mpi/main.cpp12
-rw-r--r--meson/test cases/frameworks/17 mpi/main.f9030
-rw-r--r--meson/test cases/frameworks/17 mpi/meson.build52
-rw-r--r--meson/test cases/frameworks/17 mpi/meson_options.txt6
-rw-r--r--meson/test cases/frameworks/17 mpi/test.json17
6 files changed, 144 insertions, 0 deletions
diff --git a/meson/test cases/frameworks/17 mpi/main.c b/meson/test cases/frameworks/17 mpi/main.c
new file mode 100644
index 000000000..e44357a97
--- /dev/null
+++ b/meson/test cases/frameworks/17 mpi/main.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <mpi.h>
+
+int main(int argc, char **argv)
+{
+ int ier, flag;
+ ier = MPI_Init(&argc, &argv);
+ if (ier) {
+ printf("Unable to initialize MPI: %d\n", ier);
+ return 1;
+ }
+ ier = MPI_Initialized(&flag);
+ if (ier) {
+ printf("Unable to check MPI initialization state: %d\n", ier);
+ return 1;
+ }
+ if (!flag) {
+ printf("MPI did not initialize!\n");
+ return 1;
+ }
+ ier = MPI_Finalize();
+ if (ier) {
+ printf("Unable to finalize MPI: %d\n", ier);
+ return 1;
+ }
+ return 0;
+}
diff --git a/meson/test cases/frameworks/17 mpi/main.cpp b/meson/test cases/frameworks/17 mpi/main.cpp
new file mode 100644
index 000000000..199d91343
--- /dev/null
+++ b/meson/test cases/frameworks/17 mpi/main.cpp
@@ -0,0 +1,12 @@
+#include <mpi.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ MPI::Init(argc, argv);
+ if (!MPI::Is_initialized()) {
+ printf("MPI did not initialize!\n");
+ return 1;
+ }
+ MPI::Finalize();
+}
diff --git a/meson/test cases/frameworks/17 mpi/main.f90 b/meson/test cases/frameworks/17 mpi/main.f90
new file mode 100644
index 000000000..b5666e899
--- /dev/null
+++ b/meson/test cases/frameworks/17 mpi/main.f90
@@ -0,0 +1,30 @@
+use, intrinsic :: iso_fortran_env, only: stderr=>error_unit
+use mpi
+
+implicit none
+
+logical :: flag
+integer :: ier
+
+call MPI_Init(ier)
+
+if (ier /= 0) then
+ write(stderr,*) 'Unable to initialize MPI', ier
+ stop 1
+endif
+
+call MPI_Initialized(flag, ier)
+if (ier /= 0) then
+ write(stderr,*) 'Unable to check MPI initialization state: ', ier
+ stop 1
+endif
+
+call MPI_Finalize(ier)
+if (ier /= 0) then
+ write(stderr,*) 'Unable to finalize MPI: ', ier
+ stop 1
+endif
+
+print *, "OK: Fortran MPI"
+
+end program
diff --git a/meson/test cases/frameworks/17 mpi/meson.build b/meson/test cases/frameworks/17 mpi/meson.build
new file mode 100644
index 000000000..d1d899155
--- /dev/null
+++ b/meson/test cases/frameworks/17 mpi/meson.build
@@ -0,0 +1,52 @@
+project('mpi', 'c', 'cpp', default_options: ['b_asneeded=false'])
+
+method = get_option('method')
+
+cc = meson.get_compiler('c')
+mpic = dependency('mpi', language : 'c', required : false, method : method)
+if not mpic.found()
+ error('MESON_SKIP_TEST: MPI not found, skipping.')
+endif
+exec = executable('exec',
+ 'main.c',
+ dependencies : [mpic])
+
+test('MPI C', exec, timeout: 20)
+
+
+# C++ MPI not supported by MS-MPI
+cpp = meson.get_compiler('cpp')
+mpicpp = dependency('mpi', language : 'cpp', required: false, method : method)
+if not cpp.links('''
+#include <mpi.h>
+#include <stdio.h>
+int main(int argc, char **argv) {MPI::Init(argc, argv);}
+''', dependencies: mpicpp, name: 'C++ MPI')
+ mpicpp = disabler()
+endif
+execpp = executable('execpp',
+ 'main.cpp',
+ dependencies : [mpicpp])
+
+test('MPI C++', execpp, timeout: 20)
+
+
+if add_languages('fortran', required : false)
+ fc = meson.get_compiler('fortran')
+ mpif = dependency('mpi', language : 'fortran', required: false, method : method)
+ if not fc.links('use mpi; end', dependencies: mpif, name: 'Fortran MPI')
+ mpif = disabler()
+ endif
+
+ exef = executable('exef',
+ 'main.f90',
+ dependencies : mpif)
+
+ test('MPI Fortran', exef, timeout: 20)
+endif
+
+
+# Check we can apply a version constraint
+if mpic.version() != 'unknown'
+ dependency('mpi', version: '>=@0@'.format(mpic.version()), method : method)
+endif
diff --git a/meson/test cases/frameworks/17 mpi/meson_options.txt b/meson/test cases/frameworks/17 mpi/meson_options.txt
new file mode 100644
index 000000000..7e9363eaf
--- /dev/null
+++ b/meson/test cases/frameworks/17 mpi/meson_options.txt
@@ -0,0 +1,6 @@
+option(
+ 'method',
+ type : 'combo',
+ choices : ['auto', 'pkg-config', 'config-tool', 'system'],
+ value : 'auto',
+)
diff --git a/meson/test cases/frameworks/17 mpi/test.json b/meson/test cases/frameworks/17 mpi/test.json
new file mode 100644
index 000000000..2ce66806a
--- /dev/null
+++ b/meson/test cases/frameworks/17 mpi/test.json
@@ -0,0 +1,17 @@
+{
+ "matrix": {
+ "options": {
+ "method": [
+ { "val": "auto" },
+ { "val": "pkg-config" },
+ { "val": "config-tool",
+ "skip_on_jobname": ["fedora"] },
+ {
+ "val": "system",
+ "compilers": { "c" :"msvc", "cpp": "msvc" }
+ }
+ ]
+ }
+ },
+ "skip_on_jobname": ["opensuse"]
+}