summaryrefslogtreecommitdiff
path: root/test cases/common
diff options
context:
space:
mode:
authorElliott Sales de Andrade <quantum.analyst@gmail.com>2018-04-07 04:06:29 -0400
committerElliott Sales de Andrade <quantum.analyst@gmail.com>2018-04-17 02:04:37 -0400
commitdbb025a175f31dfb1c8bb3a1e3bb7030e2625329 (patch)
tree88534c032302debb17a42b4c2476013088b2405c /test cases/common
parentf7a7059250ab9cf71c68ca78812a24a35ee745f6 (diff)
downloadmeson-dbb025a175f31dfb1c8bb3a1e3bb7030e2625329.tar.gz
Add an OpenMP dependency.
This works similarly to the thread dependency which stores the various inconsistent flags in each compiler.
Diffstat (limited to 'test cases/common')
-rw-r--r--test cases/common/190 openmp/main.c16
-rw-r--r--test cases/common/190 openmp/main.cpp16
-rw-r--r--test cases/common/190 openmp/main.f908
-rw-r--r--test cases/common/190 openmp/meson.build26
4 files changed, 66 insertions, 0 deletions
diff --git a/test cases/common/190 openmp/main.c b/test cases/common/190 openmp/main.c
new file mode 100644
index 000000000..cc81f4897
--- /dev/null
+++ b/test cases/common/190 openmp/main.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <omp.h>
+
+int main(void) {
+#ifdef _OPENMP
+ if (omp_get_max_threads() == 2) {
+ return 0;
+ } else {
+ printf("Max threads is %d not 2.\n", omp_get_max_threads());
+ return 1;
+ }
+#else
+ printf("_OPENMP is not defined; is OpenMP compilation working?\n");
+ return 1;
+#endif
+}
diff --git a/test cases/common/190 openmp/main.cpp b/test cases/common/190 openmp/main.cpp
new file mode 100644
index 000000000..b12be3fd8
--- /dev/null
+++ b/test cases/common/190 openmp/main.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+#include <omp.h>
+
+int main(void) {
+#ifdef _OPENMP
+ if (omp_get_max_threads() == 2) {
+ return 0;
+ } else {
+ std::cout << "Max threads is " << omp_get_max_threads() << " not 2." << std::endl;
+ return 1;
+ }
+#else
+ printf("_OPENMP is not defined; is OpenMP compilation working?\n");
+ return 1;
+#endif
+}
diff --git a/test cases/common/190 openmp/main.f90 b/test cases/common/190 openmp/main.f90
new file mode 100644
index 000000000..c062d8691
--- /dev/null
+++ b/test cases/common/190 openmp/main.f90
@@ -0,0 +1,8 @@
+program main
+ if (omp_get_max_threads() .eq. 2) then
+ stop 0
+ else
+ print *, 'Max threads is', omp_get_max_threads(), 'not 2.'
+ stop 1
+ endif
+end program main
diff --git a/test cases/common/190 openmp/meson.build b/test cases/common/190 openmp/meson.build
new file mode 100644
index 000000000..04559550a
--- /dev/null
+++ b/test cases/common/190 openmp/meson.build
@@ -0,0 +1,26 @@
+project('openmp', 'c', 'cpp')
+
+openmp = dependency('openmp')
+
+exec = executable('exec',
+ 'main.c',
+ dependencies : [openmp])
+
+execpp = executable('execpp',
+ 'main.cpp',
+ dependencies : [openmp])
+
+env = environment()
+env.set('OMP_NUM_THREADS', '2')
+
+test('OpenMP C', exec, env : env)
+test('OpenMP C++', execpp, env : env)
+
+
+if add_languages('fortran', required : false)
+ exef = executable('exef',
+ 'main.f90',
+ dependencies : [openmp])
+
+ test('OpenMP Fortran', execpp, env : env)
+endif