summaryrefslogtreecommitdiff
path: root/debian/tests/libgomp-link
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2019-11-19 17:35:47 +0300
committerIgor Pashev <pashev.igor@gmail.com>2019-11-19 17:35:47 +0300
commit03bebac19e6fef19299d7326d3ee41f8a7dd1316 (patch)
treebb413d22ada331790f08b7b9a592e5ab95cd8918 /debian/tests/libgomp-link
parent94a19f31b81e9e7e295414fe2ad2302e0db25a08 (diff)
parent8f6c4b0033c72f8ac14694c419a99458339dd6a9 (diff)
downloadgcc-9-03bebac19e6fef19299d7326d3ee41f8a7dd1316.tar.gz
Merge tag 'debian/9.2.1-19'
Diffstat (limited to 'debian/tests/libgomp-link')
-rwxr-xr-xdebian/tests/libgomp-link77
1 files changed, 77 insertions, 0 deletions
diff --git a/debian/tests/libgomp-link b/debian/tests/libgomp-link
new file mode 100755
index 0000000..2dad551
--- /dev/null
+++ b/debian/tests/libgomp-link
@@ -0,0 +1,77 @@
+#!/bin/sh
+# autopkgtest check: Build and run a simple program against libgfortran,
+# to verify basic compile-time and run-time linking functionality.
+
+set -e
+
+CC=gcc-9
+F95=gfortran-9
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > hello-gomp.c
+#include <omp.h>
+#include <stdio.h>
+#include <stdlib.h>
+int main (int argc, char *argv[]) {
+
+int nthreads, tid;
+
+/* Fork a team of threads giving them their own copies of variables */
+#pragma omp parallel private(nthreads, tid)
+ {
+
+ /* Obtain thread number */
+ tid = omp_get_thread_num();
+ printf("Hello World from thread = %d\n", tid);
+
+ /* Only master thread does this */
+ if (tid == 0)
+ {
+ nthreads = omp_get_num_threads();
+ printf("Number of threads = %d\n", nthreads);
+ }
+
+ } /* All threads join master thread and disband */
+}
+EOF
+
+$CC -fopenmp -o gctest hello-gomp.c
+echo "build: OK"
+ldd gctest
+[ -x gctest ]
+./gctest
+echo "run: OK"
+
+cat <<EOF > hello-gomp.f
+ program omp_par_do
+ implicit none
+
+ integer, parameter :: n = 100
+ real, dimension(n) :: dat, result
+ integer :: i
+
+ !$OMP PARALLEL DO
+ do i = 1, n
+ result(i) = my_function(dat(i))
+ end do
+ !$OMP END PARALLEL DO
+
+ contains
+
+ function my_function(d) result(y)
+ real, intent(in) :: d
+ real :: y
+
+ ! do something complex with data to calculate y
+ end function my_function
+ end program omp_par_do
+EOF
+
+$F95 -fopenmp -o gftest hello-gomp.f
+echo "build: OK"
+ldd gftest
+[ -x gftest ]
+./gftest
+echo "run: OK"