blob: ec7dbc4c1a6a65e6f632fe8c1dcd4892e0fd64c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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"
|