summaryrefslogtreecommitdiffstats
path: root/debian/tests/libgomp-link
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:22:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:22:56 +0000
commit3f472a4e5ca21e3ddb13737473e636b2b11a408a (patch)
tree7db1ab317884b9f6e04b6e13737c1679879cb97a /debian/tests/libgomp-link
parentAdding upstream version 13.2.0. (diff)
downloadgcc-13-debian.tar.xz
gcc-13-debian.zip
Adding debian version 13.2.0-10.debian/13.2.0-10debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests/libgomp-link')
-rwxr-xr-xdebian/tests/libgomp-link76
1 files changed, 76 insertions, 0 deletions
diff --git a/debian/tests/libgomp-link b/debian/tests/libgomp-link
new file mode 100755
index 0000000..ec7dbc4
--- /dev/null
+++ b/debian/tests/libgomp-link
@@ -0,0 +1,76 @@
+#!/bin/sh
+# autopkgtest check: Build and run a simple program against libgfortran,
+# to verify basic compile-time and run-time linking functionality.
+
+set -e
+
+BV=$(sed '/^Depends: gcc-\([0-9.]\+\).*/!d;s//\1/;q' debian/tests/control)
+CC=gcc-$BV
+F95=gfortran-$BV
+
+cd "$AUTOPKGTEST_TMP"
+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"