* Tests for libgomp based on OpenMP Examples 4.0.2. @ 2015-07-07 16:48 Maxim Blumental 2015-07-07 17:08 ` Maxim Blumental 0 siblings, 1 reply; 19+ messages in thread From: Maxim Blumental @ 2015-07-07 16:48 UTC (permalink / raw) To: gcc-patches [-- Attachment #1: Type: text/plain, Size: 327 bytes --] With this letter I propose a patch with tests for libgomp based on OpenMP Examples 4.0.2 both for C and Fortran. The changes are: Renamed existing tests based on OpenMP Examples to make the names more clear. Added 16 tests for simd construct and 10 for depend clause. --------------------- Sincerely yours, Maxim Blumental [-- Attachment #2: ChangeLog.txt --] [-- Type: text/plain, Size: 7099 bytes --] 2015-07-06 Maxim Blumenthal <bvmaks@gmail.com> * libgomp/testsuite/libgomp.c/examples-4/e.56.3.c: renamed to array_sections-3.c * libgomp/testsuite/libgomp.c/examples-4/e.56.4.c: renamed to array_sections-4.c * libgomp/testsuite/libgomp.c/examples-4/e.55.1.c: renamed to async_target-1.c * libgomp/testsuite/libgomp.c/examples-4/e.55.2.c: renamed to async_target-2.c * libgomp/testsuite/libgomp.c/examples-4/e.53.1.c: renamed to declare_target-1.c * libgomp/testsuite/libgomp.c/examples-4/e.53.3.c: renamed to declare_target-3.c * libgomp/testsuite/libgomp.c/examples-4/e.53.4.c: renamed to declare_target-4.c * libgomp/testsuite/libgomp.c/examples-4/e.53.5.c: renamed to declare_target-5.c * libgomp/testsuite/libgomp.c/examples-4/e.57.1.c: renamed to device-1.c * libgomp/testsuite/libgomp.c/examples-4/e.57.2.c: renamed to device-2.c * libgomp/testsuite/libgomp.c/examples-4/e.57.3.c: renamed to device-3.c * libgomp/testsuite/libgomp.c/examples-4/simd-1.c: A test for simd construct. * libgomp/testsuite/libgomp.c/examples-4/simd-2.c: Same. * libgomp/testsuite/libgomp.c/examples-4/simd-3.c: Same. * libgomp/testsuite/libgomp.c/examples-4/simd-4.c: Same. * libgomp/testsuite/libgomp.c/examples-4/simd-5.c: Same. * libgomp/testsuite/libgomp.c/examples-4/simd-6.c: Same. * libgomp/testsuite/libgomp.c/examples-4/simd-7.c: Same. * libgomp/testsuite/libgomp.c/examples-4/simd-8.c: Same. * libgomp/testsuite/libgomp.c/examples-4/e.50.1.c: renamed to target-1.c * libgomp/testsuite/libgomp.c/examples-4/e.50.2.c: renamed to target-2.c * libgomp/testsuite/libgomp.c/examples-4/e.50.3.c: renamed to target-3.c * libgomp/testsuite/libgomp.c/examples-4/e.50.4.c: renamed to target-4.c * libgomp/testsuite/libgomp.c/examples-4/e.50.5.c: renamed to target-5.c * libgomp/testsuite/libgomp.c/examples-4/e.51.1.c: renamed to target_data-1.c * libgomp/testsuite/libgomp.c/examples-4/e.51.2.c: renamed to target_data-2.c * libgomp/testsuite/libgomp.c/examples-4/e.51.3.c: renamed to target_data-3.c * libgomp/testsuite/libgomp.c/examples-4/e.51.4.c: renamed to target_data-4.c * libgomp/testsuite/libgomp.c/examples-4/e.51.6.c: renamed to target_data-6.c * libgomp/testsuite/libgomp.c/examples-4/e.51.7.c: renamed to target_data-7.c * libgomp/testsuite/libgomp.c/examples-4/e.52.1.c: renamed to target_update-1.c * libgomp/testsuite/libgomp.c/examples-4/e.52.2.c: renamed to target_update-2.c * libgomp/testsuite/libgomp.c/examples-4/task_dep-1.c: A test for task dependencies. * libgomp/testsuite/libgomp.c/examples-4/task_dep-2.c: Same. * libgomp/testsuite/libgomp.c/examples-4/task_dep-3.c: Same. * libgomp/testsuite/libgomp.c/examples-4/task_dep-4.c: Same. * libgomp/testsuite/libgomp.c/examples-4/task_dep-5.c: Same. * libgomp/testsuite/libgomp.c/examples-4/e.54.2.c: renamed to teams-2.c * libgomp/testsuite/libgomp.c/examples-4/e.54.3.c: renamed to teams-3.c * libgomp/testsuite/libgomp.c/examples-4/e.54.4.c: renamed to teams-4.c * libgomp/testsuite/libgomp.c/examples-4/e.54.5.c: renamed to teams-5.c * libgomp/testsuite/libgomp.c/examples-4/e.54.6.c: renamed to teams-6.c * libgomp/testsuite/libgomp.fortran/examples-4/e.56.3.f90: renamed to array_sections-3.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.56.4.f90: renamed to array_sections-4.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.55.1.f90: renamed to async_target-1.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.55.2.f90: renamed to async_target-2.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.53.1.f90: renamed to declare_target-1.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.53.2.f90: renamed to declare_target-2.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.53.3.f90: renamed to declare_target-3.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.53.4.f90: renamed to declare_target-4.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.53.5.f90: renamed to declare_target-5.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.57.1.f90: renamed to device-1.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.57.2.f90: renamed to device-2.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.57.3.f90: renamed to device-3.f90 * libgomp/testsuite/libgomp.fortran/examples-4/simd-1.f90: A test for simd construct. * libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/simd-4.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/simd-5.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/simd-6.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/e.50.1.f90: renamed to target-1.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.50.2.f90: renamed to target-2.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.50.3.f90: renamed to target-3.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.50.4.f90: renamed to target-4.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.50.5.f90: renamed to target-5.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.51.1.f90: renamed to target_data-1.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.51.2.f90: renamed to target_data-2.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.51.3.f90: renamed to target_data-3.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.51.4.f90: renamed to target_data-4.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.51.5.f90: renamed to target_data-5.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.51.6.f90: renamed to target_data-6.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.51.7.f90: renamed to target_data-7.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.52.1.f90: renamed to target_update-1.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.52.2.f90: renamed to target_update-2.f90 * libgomp/testsuite/libgomp.fortran/examples-4/task_dep-1.f90: A test for task dependencies. * libgomp/testsuite/libgomp.fortran/examples-4/task_dep-2.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/task_dep-3.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/task_dep-4.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90: Same. * libgomp/testsuite/libgomp.fortran/examples-4/e.54.2.f90: renamed to teams-2.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.54.3.f90: renamed to teams-3.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.54.4.f90: renamed to teams-4.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.54.5.f90: renamed to teams-5.f90 * libgomp/testsuite/libgomp.fortran/examples-4/e.54.6.f90: renamed to teams-6.f90 [-- Attachment #3: libgomp-tests.patch --] [-- Type: application/octet-stream, Size: 54565 bytes --] commit ee3c801d7404bba2adfe52e1c6b9ebf10b9e9882 Author: Maxim Blumenthal <maxim.blumenthal@intel.com> Date: Mon Jun 22 14:11:22 2015 +0300 Renamed Fortran and C for libgomp based on OpenMP Examples tests to make the names more understandable, e.g. e.55.2.f90 to async_target-2.f90. Also made minor modifications to them. Added 16 tests for simd construct and 10 for task dependencies. Those tests are based on OpenMP Examples 4.0.2. diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.56.3.c b/libgomp/testsuite/libgomp.c/examples-4/array_sections-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.56.3.c rename to libgomp/testsuite/libgomp.c/examples-4/array_sections-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.56.4.c b/libgomp/testsuite/libgomp.c/examples-4/array_sections-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.56.4.c rename to libgomp/testsuite/libgomp.c/examples-4/array_sections-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.55.1.c b/libgomp/testsuite/libgomp.c/examples-4/async_target-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.55.1.c rename to libgomp/testsuite/libgomp.c/examples-4/async_target-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.55.2.c b/libgomp/testsuite/libgomp.c/examples-4/async_target-2.c similarity index 89% rename from libgomp/testsuite/libgomp.c/examples-4/e.55.2.c rename to libgomp/testsuite/libgomp.c/examples-4/async_target-2.c index f03cae3..ce63328 100644 --- a/libgomp/testsuite/libgomp.c/examples-4/e.55.2.c +++ b/libgomp/testsuite/libgomp.c/examples-4/async_target-2.c @@ -19,8 +19,9 @@ void init (float *a, float *b, int n) } #pragma omp end declare target -void vec_mult_ref (float *p, float *v1, float *v2, int n) +void vec_mult_ref(float *p, int n) { + float *v1, *v2; int i; v1 = (float *) malloc (n * sizeof (float)); @@ -35,8 +36,9 @@ void vec_mult_ref (float *p, float *v1, float *v2, int n) free (v2); } -void vec_mult (float *p, float *v1, float *v2, int n) +void vec_mult(float *p, int n) { + float *v1, *v2; int i; #pragma omp task shared(v1, v2) depend(out: v1, v2) @@ -64,6 +66,8 @@ void vec_mult (float *p, float *v1, float *v2, int n) free (v1); free (v2); } + + #pragma omp taskwait } void check (float *a, float *b, int n) @@ -81,10 +85,9 @@ int main () { float *p1 = (float *) malloc (N * sizeof (float)); float *p2 = (float *) malloc (N * sizeof (float)); - float *v1, *v2; - vec_mult_ref (p1, v1, v2, N); - vec_mult (p2, v1, v2, N); + vec_mult_ref (p1, N); + vec_mult (p2, N); check (p1, p2, N); diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.1.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.1.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.3.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.3.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.4.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.4.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.5.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-5.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.5.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-5.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.57.1.c b/libgomp/testsuite/libgomp.c/examples-4/device-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.57.1.c rename to libgomp/testsuite/libgomp.c/examples-4/device-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.57.2.c b/libgomp/testsuite/libgomp.c/examples-4/device-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.57.2.c rename to libgomp/testsuite/libgomp.c/examples-4/device-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.57.3.c b/libgomp/testsuite/libgomp.c/examples-4/device-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.57.3.c rename to libgomp/testsuite/libgomp.c/examples-4/device-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-1.c b/libgomp/testsuite/libgomp.c/examples-4/simd-1.c new file mode 100644 index 0000000..5baaf30 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-1.c @@ -0,0 +1,65 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define OFF 32 +#define EPS 0.0000000000000001 + +#include <stdlib.h> + +void init(double *a, double *a_ref, double *b, double *c, int n, int ioff) +{ + int i; + for ( i = 0; i < n; i++ ) + { + a[i] = i*i; + a_ref[i] = a[i]; + b[i] = i+i; + } + + int s = -1; + for ( i = 0; i < n+ioff; i++ ) + { + c[i] = s*3; + s = -s; + } +} + +void star( double *a, double *b, double *c, int n, int *ioff ) +{ + int i; + #pragma omp simd + for ( i = 0; i < n; i++ ) + a[i] *= b[i] * c[i+ *ioff]; +} + +void star_ref( double *a, double *b, double *c, int n, int *ioff ) +{ + int i; + for ( i = 0; i < n; i++ ) + a[i] *= b[i] * c[i+ *ioff]; +} + +void check (double *a, double *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + +int main () +{ + double a[N], a_ref[N], b[N], c[N+OFF]; + int ioff = OFF; + + init(a, a_ref, b, c, N, ioff); + + star(a, b, c, N, &ioff); + star_ref(a_ref, b, c, N, &ioff); + + check(a, a_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-2.c b/libgomp/testsuite/libgomp.c/examples-4/simd-2.c new file mode 100644 index 0000000..c0ad30a --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-2.c @@ -0,0 +1,90 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define EPS 0.0000000000000001 + +#include <stdlib.h> + +void init(double *a, double *a_ref, double *b, int n) +{ + int i; + for ( i=0; i<N; i++ ) + { + a[i] = i; + a_ref[i] = i; + b[i] = N-i; + } +} + +#pragma omp declare simd uniform(fact) +double add1(double a, double b, double fact) +{ + double c; + c = a + b + fact; + return c; +} + +#pragma omp declare simd uniform(a,b,fact) linear(i:1) +double add2(double *a, double *b, int i, double fact) +{ + double c; + c = a[i] + b[i] + fact; + return c; +} + +#pragma omp declare simd uniform(fact) linear(a,b:1) +double add3(double *a, double *b, double fact) +{ + double c; + c = *a + *b + fact; + return c; +} + +void work( double *a, double *b, int n ) +{ + int i; + double tmp; + #pragma omp simd private(tmp) + for ( i = 0; i < n; i++ ) { + tmp = add1( a[i], b[i], 1.0); + a[i] = add2( a, b, i, 1.0) + tmp; + a[i] = add3(&a[i], &b[i], 1.0); + } +} + +void work_ref( double *a, double *b, int n ) +{ + int i; + double tmp; + for ( i = 0; i < n; i++ ) { + tmp = add1( a[i], b[i], 1.0); + a[i] = add2( a, b, i, 1.0) + tmp; + a[i] = add3(&a[i], &b[i], 1.0); + } +} + +void check (double *a, double *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + + +int main () +{ + int i; + double a[N], a_ref[N], b[N]; + + init(a, a_ref, b, N); + + work(a, b, N ); + work_ref(a_ref, b, N ); + + check(a, a_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-3.c b/libgomp/testsuite/libgomp.c/examples-4/simd-3.c new file mode 100644 index 0000000..9f33713 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-3.c @@ -0,0 +1,61 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define EPS 0.0000000000000001 + +#include <stdlib.h> + +void init(double *a, double *a_ref, double *b, int n) +{ + int i, s = -1; + for ( i = 0; i < n; i++ ) + { + a[i] = i*i*s; + a_ref[i] = a[i]; + b[i] = i+i; + s = -s; + } +} + +double work( double *a, double *b, int n ) +{ + int i; + double tmp, sum; + sum = 0.0; + #pragma omp simd private(tmp) reduction(+:sum) + for (i = 0; i < n; i++) { + tmp = a[i] + b[i]; + sum += tmp; + } + return sum; +} + +double work_ref( double *a, double *b, int n ) +{ + int i; + double tmp, sum; + sum = 0.0; + for (i = 0; i < n; i++) { + tmp = a[i] + b[i]; + sum += tmp; + } + return sum; +} + +int main () +{ + double a[N], a_ref[N], b[N]; + int res, ref; + + init(a, a_ref, b, N); + + res = work(a, b, N); + ref = work_ref(a_ref, b, N); + + if (res != ref) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-4.c b/libgomp/testsuite/libgomp.c/examples-4/simd-4.c new file mode 100644 index 0000000..1aa0425 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-4.c @@ -0,0 +1,58 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 128 +#define M 16 +#define EPS 0.0000000000000001 +#define SAFELEN 16 + +#include <stdlib.h> + +void init(double *a, double *b, int n) +{ + int i, s = -1; + for ( i = 0; i < n; i++ ) + { + a[i] = i*i*s; + b[i] = a[i]; + s = -s; + } +} + +void work( double *b, int n, int m ) +{ + int i; + #pragma omp simd safelen(SAFELEN) + for (i = m; i < n; i++) + b[i] = b[i-m] - 1.0f; +} + +void work_ref( double *b, int n, int m ) +{ + int i; + for (i = m; i < n; i++) + b[i] = b[i-m] - 1.0f; +} + +void check (double *a, double *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + +int main () +{ + double b[N], b_ref[N]; + + init(b, b_ref, N); + + work(b, N, M); + work(b_ref, N, M); + + check(b, b_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-5.c b/libgomp/testsuite/libgomp.c/examples-4/simd-5.c new file mode 100644 index 0000000..ce037ac --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-5.c @@ -0,0 +1,76 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 128 +#define M 16 +#define EPS 0.0000000000000001 +#define SAFELEN 16 + +#include <stdlib.h> + +void init(double a[N][N], double b[N][N], int n) +{ + int i, j, s = -1; + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + a[i][j] = i * j * s; + b[i][j] = i + j + s; + s = -s; + } + } +} + +void work( double a[N][N], double b[N][N], double c[N][N], int n ) +{ + int i, j; + double tmp; + #pragma omp for simd collapse(2) private(tmp) + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + tmp = a[i][j] + b[i][j]; + c[i][j] = tmp; + } + } +} + +void work_ref( double a[N][N], double b[N][N], double c[N][N], int n ) +{ + int i, j; + double tmp; + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + tmp = a[i][j] + b[i][j]; + c[i][j] = tmp; + } + } +} + +void check (double a[N][N], double b[N][N]) +{ + int i, j; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + if (a[i][j] - b[i][j] > EPS || b[i][j] - a[i][j] > EPS) + abort (); +} + +int main () +{ + double a[N][N], b[N][N], c[N][N], c_ref[N][N]; + + init(a, b, N); + + work(a, b, c, N); + work_ref(a, b, c_ref, N); + + check(c, c_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-6.c b/libgomp/testsuite/libgomp.c/examples-4/simd-6.c new file mode 100644 index 0000000..d313c70 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-6.c @@ -0,0 +1,105 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define EPS 0.000001 + +#include <stdlib.h> +#include <stdio.h> + +void init(int *b, float *y, int n) +{ + int i, s = -1; + for ( i=0; i<N; i++ ) + { + b[i] = i*i*s; + y[i] = b[i] * 0.1f; + s = -s; + } +} + +#pragma omp declare simd linear(p:1) notinbranch +int foo(int *p){ + *p = *p + 10; + return *p; +} + +int myaddint(int *a, int *b, int n) +{ +#pragma omp simd + for (int i=0; i<n; i++){ + a[i] = foo(&b[i]); /* foo is not called under a condition */ + } + return a[n-1]; +} + +int myaddint_ref(int *a, int *b, int n) +{ + for (int i=0; i<n; i++){ + a[i] = foo(&b[i]); + } + return a[n-1]; +} + +#pragma omp declare simd linear(p:1) inbranch +float goo(float *p){ + *p = *p + 18.5f; + return *p; +} + +int myaddfloat(float *x, float *y, int n) +{ +#pragma omp simd + for (int i=0; i<n; i++){ + x[i] = (x[i] > y[i]) ? goo(&y[i]) : y[i]; + /* goo is called under the condition (or within a branch) */ + } + return x[n-1]; +} + +int myaddfloat_ref(float *x, float *y, int n) +{ + for (int i=0; i<n; i++){ + x[i] = (x[i] > y[i]) ? goo(&y[i]) : y[i]; + } + return x[n-1]; +} + +void check_addint (int *a, int *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] != b[i]) + abort (); +} + +void check_addfloat (float *a, float *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + +int main () +{ + int i; + int a[N], a_ref[N], b[N]; + float x[N], x_ref[N], y[N]; + + init(a, x, N); + init(b, y, N); + myaddint(a, b, N); + myaddfloat(x, y, N); + + init(a_ref, x_ref, N); + init(b, y, N); + myaddint_ref(a_ref, b, N); + myaddfloat_ref(x_ref, y, N); + + check_addint(a, a_ref); + check_addfloat(x, x_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-7.c b/libgomp/testsuite/libgomp.c/examples-4/simd-7.c new file mode 100644 index 0000000..9c3040a --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-7.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include <stdio.h> +#include <stdlib.h> + +#define N 45 +int a[N], a_ref[N], b[N]; + +#pragma omp declare simd inbranch +int fib( int n ) +{ + if (n <= 2) + return n; + else { + return fib(n-1) + fib(n-2); + } +} + +int main(void) +{ + int i; + +#pragma omp simd + for (i=0; i < N; i++) + b[i] = i; + +#pragma omp simd + for (i=0; i < N; i++) + a[i] = fib(b[i]); + + for (i=0; i < N; i++) + a_ref[i] = fib(b[i]); + + for (i=0; i < N; i++) + if (a[i] != a_ref[i]) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-8.c b/libgomp/testsuite/libgomp.c/examples-4/simd-8.c new file mode 100644 index 0000000..397e2a3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-8.c @@ -0,0 +1,49 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include <stdlib.h> +#include <math.h> + +int P[1000]; +float A[1000]; + +float do_work(float *arr) +{ + float pri; + +#pragma omp simd lastprivate(pri) + for (int i = 0; i < 999; ++i) + { + int j = P[i]; + + pri = 0.5f; + if (j % 2 == 0) + { + pri = A[j+1] + arr[i]; + } + A[j] = pri * 1.5f; + pri = pri + A[j]; + } + + return pri; +} + +int main(void) +{ + float pri, arr[1000]; + + for (int i = 0; i < 1000; ++i) + { + P[i] = i; + A[i] = i * 1.5f; + arr[i] = i * 1.8f; + } + + pri = do_work(&arr[0]); + + if (pri != 8237.25) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.1.c b/libgomp/testsuite/libgomp.c/examples-4/target-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.1.c rename to libgomp/testsuite/libgomp.c/examples-4/target-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.2.c b/libgomp/testsuite/libgomp.c/examples-4/target-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.2.c rename to libgomp/testsuite/libgomp.c/examples-4/target-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.3.c b/libgomp/testsuite/libgomp.c/examples-4/target-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.3.c rename to libgomp/testsuite/libgomp.c/examples-4/target-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.4.c b/libgomp/testsuite/libgomp.c/examples-4/target-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.4.c rename to libgomp/testsuite/libgomp.c/examples-4/target-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.5.c b/libgomp/testsuite/libgomp.c/examples-4/target-5.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.5.c rename to libgomp/testsuite/libgomp.c/examples-4/target-5.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.1.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.1.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.2.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.2.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.3.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.3.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.4.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.4.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.6.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-6.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.6.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-6.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.7.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-7.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.7.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-7.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.52.1.c b/libgomp/testsuite/libgomp.c/examples-4/target_update-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.52.1.c rename to libgomp/testsuite/libgomp.c/examples-4/target_update-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.52.2.c b/libgomp/testsuite/libgomp.c/examples-4/target_update-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.52.2.c rename to libgomp/testsuite/libgomp.c/examples-4/target_update-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-1.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-1.c new file mode 100644 index 0000000..8d397a5 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-1.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +#include <stdlib.h> +int main() +{ + int x = 1; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(out: x) + x = 2; + #pragma omp task shared(x) depend(in: x) + if (x != 2) + abort (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-2.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-2.c new file mode 100644 index 0000000..f583f09 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-2.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +#include <stdlib.h> +int main() +{ + int x = 1; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(in: x) + if (x != 1) + abort (); + #pragma omp task shared(x) depend(out: x) + x = 2; + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-3.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-3.c new file mode 100644 index 0000000..189d5e0 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-3.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +#include <stdlib.h> + +int main() +{ + int x = 0; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(out: x) + x = 1; + #pragma omp task shared(x) depend(out: x) + x = 2; + #pragma omp taskwait + if (x != 1 && x != 2) + abort (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-4.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-4.c new file mode 100644 index 0000000..77aa57a4 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-4.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +#include <stdlib.h> +int main() +{ + int x = 1; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(out: x) + x = 2; + #pragma omp task shared(x) depend(in: x) + if (x != 2) + abort (); + #pragma omp task shared(x) depend(in: x) + if (x != 2) + abort (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-5.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-5.c new file mode 100644 index 0000000..cc2cda5 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-5.c @@ -0,0 +1,81 @@ +/* { dg-do run } */ + +#define N 128 +#define BS 16 +#define EPS 0.000001 + +#include <stdlib.h> + +void matmul_depend (float A[N][N], float B[N][N], float C[N][N]) +{ + int i, j, k, ii, jj, kk; + for (i = 0; i < N; i+=BS) + for (j = 0; j < N; j+=BS) + for (k = 0; k < N; k+=BS) +// Note 1: i, j, k, A, B, C are firstprivate by default +// Note 2: A, B and C are just pointers +#pragma omp task private(ii, jj, kk) \ + depend ( in: A[i:BS][k:BS], B[k:BS][j:BS] ) \ + depend ( inout: C[i:BS][j:BS] ) + for (ii = i; ii < i+BS; ii++ ) + for (jj = j; jj < j+BS; jj++ ) + for (kk = k; kk < k+BS; kk++ ) + C[ii][jj] = C[ii][jj] + A[ii][kk] * B[kk][jj]; +} + +void matmul_ref (float A[N][N], float B[N][N], float C[N][N]) +{ + int i, j, k; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + for (k = 0; k < N; k++) + C[i][j] += A[i][k] * B[k][j]; +} + +void init (float A[N][N], float B[N][N]) +{ + int i, j, s = -1; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + A[i][j] = i * j * s; + B[i][j] = i + j; + s = -s; + } +} + +void init_zero (float A[N][N], float B[N][N]) +{ + int i, j, s = -1; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + A[i][j] = 0; + B[i][j] = 0; + } +} + +void check (float A[N][N], float B[N][N]) +{ + int i, j; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + if (A[i][j] - B[i][j] > EPS || B[i][j] - A[i][j] > EPS) + abort (); +} + +int main () +{ + float A[N][N], B[N][N], C[N][N], C_ref[N][N]; + + init (A, B); + init_zero (C, C_ref); + + matmul_depend (A, B, C); + matmul_ref (A, B, C_ref); + + check (C, C_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.2.c b/libgomp/testsuite/libgomp.c/examples-4/teams-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.2.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.3.c b/libgomp/testsuite/libgomp.c/examples-4/teams-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.3.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.4.c b/libgomp/testsuite/libgomp.c/examples-4/teams-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.4.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.5.c b/libgomp/testsuite/libgomp.c/examples-4/teams-5.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.5.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-5.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.6.c b/libgomp/testsuite/libgomp.c/examples-4/teams-6.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.6.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-6.c diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.56.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/array_sections-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.56.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/array_sections-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.56.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/array_sections-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.56.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/array_sections-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.55.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/async_target-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.55.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/async_target-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.55.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/async_target-2.f90 similarity index 98% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.55.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/async_target-2.f90 index dfcb5f4..b12b0ea 100644 --- a/libgomp/testsuite/libgomp.fortran/examples-4/e.55.2.f90 +++ b/libgomp/testsuite/libgomp.fortran/examples-4/async_target-2.f90 @@ -46,6 +46,8 @@ subroutine vec_mult (p, N) !$omp end target !$omp end task !$omp end target data + + !$omp taskwait call check (p, N) end subroutine diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.57.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/device-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.57.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/device-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.57.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/device-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.57.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/device-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.57.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/device-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.57.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/device-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-1.f90 new file mode 100644 index 0000000..b1af859 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-1.f90 @@ -0,0 +1,67 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD1_mod +contains + subroutine init (a, a_ref, b, c, n, ioff_ptr) + double precision :: a(*), a_ref(*), b(*), c(*) + integer :: n, i, s + integer, pointer :: ioff_ptr + + s = -1 + do i = 1, n + a(i) = i * i * s + a_ref(i) = a(i) + b(i) = i + i + end do + + do i = 1, n+ioff_ptr + c(i) = i * 3 + end do + + end subroutine + + subroutine check (a, b, n) + integer :: i, n + double precision, parameter :: EPS = 0.0000000000001 + double precision :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine + + subroutine star(a, a_ref, b, c, n, ioff_ptr) + double precision :: a(*), a_ref(*), b(*), c(*) + integer :: n, i + integer, pointer :: ioff_ptr + + call init (a, a_ref, b, c, n, ioff_ptr) + + !$omp simd + do i = 1,n + a(i) = a(i) * b(i) * c(i+ioff_ptr) + end do + + do i = 1,n + a_ref(i) = a_ref(i) * b(i) * c(i+ioff_ptr) + end do + + call check (a, a_ref, n) + + end subroutine +end module + +program SIMD1 + use SIMD1_mod, only : star + double precision :: a(128), a_ref(128), b(128), c(144) + integer, pointer:: ioff_ptr + integer, target:: offset + + offset = 16 + ioff_ptr => offset + + call star (a, a_ref, b, c, 128, ioff_ptr) + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90 new file mode 100644 index 0000000..dd6433d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90 @@ -0,0 +1,72 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD2_mod +contains + function add1(a,b,fact) result(c) + !$omp declare simd(add1) uniform(fact) + double precision :: a,b,fact, c + c = a + b + fact + end function + + function add2(a,b,i, fact) result(c) + !$omp declare simd(add2) uniform(a,b,fact) linear(i:1) + integer, value :: i + double precision, dimension(:) :: a, b + double precision :: fact, c + c = a(i) + b(i) + fact + end function + + subroutine work(a, b, n ) + implicit none + double precision :: a(n),b(n), tmp + integer :: n, i + + !$omp simd private(tmp) + do i = 1,n + tmp = add1(a(i), b(i), 1.0d0) + a(i) = add2(a, b, i, 1.0d0) + tmp + a(i) = a(i) + b(i) + 1.0d0 + end do + end subroutine + + subroutine work_ref(a, b, n ) + implicit none + double precision :: a(n),b(n), tmp + integer :: n, i + + do i = 1,n + tmp = add1(a(i), b(i), 1.0d0) + a(i) = add2(a, b, i, 1.0d0) + tmp + a(i) = a(i) + b(i) + 1.0d0 + end do + end subroutine + + subroutine check (a, b, n) + integer :: i, n + double precision, parameter :: EPS = 0.0000000000001 + double precision :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine +end module + +program main + use SIMD2_mod + integer, parameter :: N=32 + integer :: i + double precision :: a(N), b(N), a_ref(N) + do i = 1,N + a(i) = i-1 + a_ref(i) = a(i) + b(i) = N-(i-1) + end do + + call work(a, b, N ) + call work_ref(a_ref, b, N ) + + call check(a, a_ref, N ) +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 new file mode 100644 index 0000000..f2e0047 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 @@ -0,0 +1,59 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD3_mod +contains + subroutine work( a, b, n, sum ) + implicit none + integer :: i, n + double precision :: a(n), b(n), sum, tmp + + sum = 0.0d0 + call init(a, b, n) + !$omp simd private(tmp) reduction(+:sum) + do i = 1,n + tmp = a(i) + b(i) + sum = sum + tmp + end do + + end subroutine work + + subroutine work_ref( a, b, n, sum ) + implicit none + integer :: i, n + double precision :: a(n), b(n), sum, tmp + + sum = 0.0d0 + call init(a, b, n) + do i = 1,n + tmp = a(i) + b(i) + sum = sum + tmp + end do + + end subroutine work_ref + + subroutine init (a, b, n) + double precision :: a(*), b(*) + integer :: n, i, s + + s = -1 + do i = 1, n + a(i) = i * i * s + b(i) = i + i + s = -s + end do + + end subroutine +end module + +program SIMD3 + use SIMD3_mod + double precision :: a(128), b(128), sum, sum_ref + + call work(a, b, 128, sum) + call work_ref(a, b, 128, sum_ref) + + if (sum .ne. sum_ref) call abort + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-4.f90 new file mode 100644 index 0000000..1100edc --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-4.f90 @@ -0,0 +1,64 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD4_mod +contains + subroutine work( b, n, m ) + implicit none + real :: b(n) + integer :: i,n,m + + call init(b, n) + + !$omp simd safelen(16) + do i = m+1, n + b(i) = b(i-m) - 1.0 + end do + end subroutine work + + subroutine work_ref( b, n, m ) + implicit none + real :: b(n) + integer :: i,n,m + + call init(b, n) + + do i = m+1, n + b(i) = b(i-m) - 1.0 + end do + end subroutine work_ref + + subroutine init (b, n) + real :: b(*) + integer :: n, i, s + + s = -1 + do i = 1, n + b(i) = i * i * s + s = -s + end do + + end subroutine + + subroutine check (a, b, n) + integer :: i, n + real, parameter :: EPS = 0.000001 + real :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine + +end module + +program SIMD4 + use SIMD4_mod + real :: b(128), b_ref(128) + + call work(b, 128, 32) + call work_ref(b_ref, 128, 32) + + call check(b, b_ref, 128) +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-5.f90 new file mode 100644 index 0000000..63cf024 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-5.f90 @@ -0,0 +1,76 @@ +! { dg-do compile } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD5_mod +contains + subroutine work( a, b, c, n ) + implicit none + integer :: i,j,n + double precision :: a(n,n), b(n,n), c(n,n), tmp + + !$omp for simd collapse(2) private(tmp) !{ dg-excess-errors "Unclassifiable OpenMP directive" } + do j = 1,n + do i = 1,n + tmp = a(i,j) + b(i,j) + c(i,j) = tmp + end do + end do + + end subroutine work + + subroutine work_ref( a, b, c, n ) + implicit none + integer :: i,j,n + double precision :: a(n,n), b(n,n), c(n,n), tmp + + do j = 1,n + do i = 1,n + tmp = a(i,j) + b(i,j) + c(i,j) = tmp + end do + end do + + end subroutine work_ref + + subroutine init (a, b, n) + integer :: i,j,n,s + double precision :: a(n,n), b(n,n) + + s = -1 + + do j = 1,n + do i = 1,n + a(i,j) = i*j*s + b(i,j) = i+j + s = -s + end do + end do + + end subroutine + + subroutine check (a, b, n) + integer :: i, j, n + double precision, parameter :: EPS = 0.0000000000000001 + double precision :: diff, a(n,n), b(n,n) + do j = 1, n + do i = 1, n + diff = a(i,j) - b(i,j) + if (diff > EPS .or. -diff > EPS) call abort + end do + end do + end subroutine + +end module + +program SIMD5 + use SIMD5_mod !{ dg-excess-errors "Can't open module file" } + double precision, dimension(32, 32) :: a, b, c, c_ref + + call init(a, b, 32) + + call work(a, b, c, 32) + call work_ref(a, b, c_ref, 32) + + call check(c, c_ref, 32) +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-6.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-6.f90 new file mode 100644 index 0000000..9a227cd --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-6.f90 @@ -0,0 +1,151 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD6_mod +contains + function foo(p) result(r) + !$omp declare simd(foo) notinbranch + integer :: p, r + p = p + 10 + r = p + end function foo + + function myaddint(a, b, n) result(r) + implicit none + integer :: a(*), b(*), n, r + integer :: i + + !$omp simd + do i=1, n + a(i) = foo(b(i)) ! foo is not called under a condition + end do + r = a(n) + + end function myaddint + + function myaddint_ref(a, b, n) result(r) + implicit none + integer :: a(*), b(*), n, r + integer :: i + + do i=1, n + a(i) = foo(b(i)) + end do + r = a(n) + + end function myaddint_ref + + function goo(p) result(r) + !$omp declare simd(goo) inbranch + real :: p, r + p = p + 18.5 + r = p + end function goo + + function myaddfloat(x, y, n) result(r) + implicit none + real :: x(*), y(*), r + integer :: n + integer :: i + + !$omp simd + do i=1, n + if (x(i) > y(i)) then + x(i) = goo(y(i)) + ! goo is called under the condition (or within a branch) + else + x(i) = y(i) + endif + end do + + r = x(n) + end function myaddfloat + + function myaddfloat_ref(x, y, n) result(r) + implicit none + real :: x(*), y(*), r + integer :: n + integer :: i + + do i=1, n + if (x(i) > y(i)) then + x(i) = goo(y(i)) + else + x(i) = y(i) + endif + end do + + r = x(n) + end function myaddfloat_ref + + subroutine init (b, y, n) + integer :: b(128) + real :: y(128) + + s = -1 + do i = 1, n + b(i) = i*i*s + y(i) = i*i*s + s = -s + end do + + end subroutine + + subroutine init2 (b, y, n) + integer :: b(128) + real :: y(128) + + do i = 1, n + b(i) = i + y(i) = i + end do + + end subroutine + + subroutine checkfloat (a, b, n) + integer :: i, n + real, parameter :: EPS = 0.000001 + real :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine + + subroutine checkint (a, b, n) + integer :: i, n, a(*), b(*) + do i = 1, n + if (a(i) .ne. b(i)) call abort + end do + end subroutine + + subroutine test () + integer :: a(128), a_ref(128), b(128), ri, ri_ref + real :: x(128), x_ref(128), y(128), rf, rf_ref + + call init2(a, x, 128) + call init2(a_ref, x_ref, 128) + + call init(b, y, 128) + + ri = myaddint (a, b, 128) + rf = myaddfloat (x, y, 128) + + call init(b, y, 128) + + ri_ref = myaddint_ref (a_ref, b, 128) + rf_ref = myaddfloat_ref (x_ref, y, 128) + + call checkint (a, a_ref, 128) + call checkfloat (x, x_ref, 128) + end subroutine + +end module + +program SIMD6 + use SIMD6_mod, only: test + + call test () + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 new file mode 100644 index 0000000..e64107d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 @@ -0,0 +1,49 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +program fibonacci + implicit none + integer,parameter :: N=45 + integer :: a(0:N-1), b(0:N-1) + integer :: a_ref(0:N-1), b_ref(0:N-1) + integer :: i + integer, external :: fib + + !$omp simd + do i = 0,N-1 + b(i) = i + end do + + do i = 0,N-1 + b_ref(i) = i + end do + + !$omp simd + do i=0,N-1 + a(i) = fib(b(i)) + end do + + do i=0,N-1 + a_ref(i) = fib(b_ref(i)) + end do + + do i = 0, N-1 + if (a(i) .ne. a_ref(i)) call abort () + end do + + if (a(44) .ne. 1134903170) call abort() + +end program + +recursive function fib(n) result(r) +!$omp declare simd(fib) inbranch + integer :: n, r + + if (n <= 2) then + r = n + else + r = fib(n-1) + fib(n-2) + endif + +end function fib diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 new file mode 100644 index 0000000..743bdcc --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 @@ -0,0 +1,48 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module work + +integer :: P(1000) +real :: A(1000) + +contains +function do_work(arr) result(pri) + implicit none + real, dimension(*) :: arr + + real :: pri + integer :: i, j + + !$omp simd private(j) lastprivate(pri) + do i = 1, 999 + j = P(i) + + pri = 0.5 + if (mod(j-1, 2) == 0) then + pri = A(j+1) + arr(i) + endif + A(j) = pri * 1.5 + pri = pri + A(j) + end do + +end function do_work + +end module work + +program simd_8f + use work + implicit none + real :: pri, arr(1000) + integer :: i + + do i = 1, 1000 + P(i) = i + A(i) = (i-1) * 1.5 + arr(i) = (i-1) * 1.8 + end do + pri = do_work(arr) + if (pri .ne. 8237.25) call abort () + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.6.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-6.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.6.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-6.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.7.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-7.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.7.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-7.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.52.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_update-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.52.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_update-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.52.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_update-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.52.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_update-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-1.f90 new file mode 100644 index 0000000..78201ea --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-1.f90 @@ -0,0 +1,16 @@ +! { dg-do run } + +program example + integer :: x + x = 1 + !$omp parallel + !$omp single + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp task shared(x) depend(in: x) + if (x .ne. 2) call abort () + !$omp end task + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-2.f90 new file mode 100644 index 0000000..5afd76d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-2.f90 @@ -0,0 +1,16 @@ +! { dg-do run } + +program example + integer :: x + x = 1 + !$omp parallel + !$omp single + !$omp task shared(x) depend(in: x) + if (x .ne. 1) call abort () + !$omp end task + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-3.f90 new file mode 100644 index 0000000..c8d5820 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-3.f90 @@ -0,0 +1,18 @@ +! { dg-do run } + +program example + integer :: x + x = 0 + !$omp parallel + !$omp single + !$omp task shared(x) depend(out: x) + x = 1 + !$omp end task + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp taskwait + if ((x .ne. 1) .and. (x .ne. 2)) call abort() + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-4.f90 new file mode 100644 index 0000000..7fe24c3 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-4.f90 @@ -0,0 +1,19 @@ +! { dg-do run } + +program example + integer :: x + x = 1 + !$omp parallel + !$omp single + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp task shared(x) depend(in: x) + if (x .ne. 2) call abort () + !$omp end task + !$omp task shared(x) depend(in: x) + if (x .ne. 2) call abort () + !$omp end task + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 new file mode 100644 index 0000000..12dd9e1 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 @@ -0,0 +1,100 @@ +! { dg-do run } + +module task_dep5_mod +contains + subroutine matmul_depend (N, BS, A, B, C) + implicit none + integer :: N, BS, BM + real, dimension(N, N) :: A, B, C + integer :: i, j, k, ii, jj, kk + BM = BS - 1 + do i = 1, N, BS + do j = 1, N, BS + do k = 1, N, BS + !$omp task shared(A,B,C) private(ii,jj,kk) & ! I,J,K are firstprivate by default + !$omp depend ( in: A(i:i+BM, k:k+BM), B(k:k+BM, j:j+BM) ) & + !$omp depend ( inout: C(i:i+BM, j:j+BM) ) + do ii = i, i+BM + do jj = j, j+BM + do kk = k, k+BM + C(jj,ii) = C(jj,ii) + A(kk,ii) * B(jj,kk) + end do + end do + end do + !$omp end task + end do + end do + end do + end subroutine + + subroutine matmul_ref (N, A, B, C) + implicit none + integer :: N + real, dimension(N, N) :: A, B, C + integer :: i, j, k + do i = 1, N + do j = 1, N + do k = 1, N + C(j,i) = C(j,i) + A(k,i) * B(j,k) + end do + end do + end do + end subroutine + + subroutine check (N, A, B) + integer :: N + integer :: i, j + integer, parameter :: EPS = 0.000001 + real, dimension(N,N) :: A, B + real :: diff + do i = 1, N + do j = 1, N + diff = A(i, j) - B(i, j) + if (diff > EPS .or. -diff > EPS) then + call abort () + end if + end do + end do + end subroutine + + subroutine init (N, A, B) + integer :: N + integer :: i, j, s + real, dimension(N,N) :: A, B + s = -1 + do i = 1, N + do j = 1, N + A(i, j) = i*j*s + B(i, j) = i+j + s = -s + end do + end do + end subroutine + + subroutine zero_init (N, A, B) + integer :: N + integer :: i, j + real, dimension(N,N) :: A, B + do i = 1, N + do j = 1, N + A(i, j) = 0 + B(i, j) = 0 + end do + end do + end subroutine + +end module + +program main + use task_dep5_mod + real, dimension(32, 32) :: A, B, C, C_ref + + call init (32, A, B) + call zero_init (32, C, C_ref) + + call matmul_depend(32, 4, A, B, C) + call matmul_ref(32, A, B, C_ref) + + call check (32, C, C_ref) + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.6.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-6.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.6.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-6.f90 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-07 16:48 Tests for libgomp based on OpenMP Examples 4.0.2 Maxim Blumental @ 2015-07-07 17:08 ` Maxim Blumental 2015-07-07 18:17 ` Jakub Jelinek 0 siblings, 1 reply; 19+ messages in thread From: Maxim Blumental @ 2015-07-07 17:08 UTC (permalink / raw) To: gcc-patches Comment on the patch: simd-5.f90 file is marked as xfail since the test fails because 'simd collapse' is an unsupported combination for Fortran (which though is valid in OpenMP API). 2015-07-07 19:48 GMT+03:00 Maxim Blumental <bvmaks@gmail.com>: > With this letter I propose a patch with tests for libgomp based on > OpenMP Examples 4.0.2 both for C and Fortran. > > The changes are: > > Renamed existing tests based on OpenMP Examples to make the names more clear. > Added 16 tests for simd construct and 10 for depend clause. > > --------------------- > Sincerely yours, > Maxim Blumental -- --------------------- Sincerely yours, Maxim Blumental ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-07 17:08 ` Maxim Blumental @ 2015-07-07 18:17 ` Jakub Jelinek 2015-07-07 18:30 ` Ilya Verbin 0 siblings, 1 reply; 19+ messages in thread From: Jakub Jelinek @ 2015-07-07 18:17 UTC (permalink / raw) To: Maxim Blumental; +Cc: gcc-patches On Tue, Jul 07, 2015 at 08:08:16PM +0300, Maxim Blumental wrote: > Comment on the patch: > > simd-5.f90 file is marked as xfail since the test fails because 'simd > collapse' is an unsupported combination for Fortran (which though is > valid in OpenMP API). I'll have a look, that is supposed to work. > 2015-07-07 19:48 GMT+03:00 Maxim Blumental <bvmaks@gmail.com>: > > With this letter I propose a patch with tests for libgomp based on > > OpenMP Examples 4.0.2 both for C and Fortran. > > > > The changes are: > > > > Renamed existing tests based on OpenMP Examples to make the names more clear. If anything, the test could be renamed to match https://github.com/OpenMP/Examples/tree/master/sources/ filenames, but certainly not to made up names. The Examples-4/ directory is supposed to only contain the tests from the 4.0.* examples document and no other tests. > > Added 16 tests for simd construct and 10 for depend clause. Any new tests that aren't in Examples 4.0.* document should go one level higher, to libgomp.{c,c++,fortran}/ directly. Jakub ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-07 18:17 ` Jakub Jelinek @ 2015-07-07 18:30 ` Ilya Verbin 2015-07-08 12:51 ` Maxim Blumental 0 siblings, 1 reply; 19+ messages in thread From: Ilya Verbin @ 2015-07-07 18:30 UTC (permalink / raw) To: Jakub Jelinek, Maxim Blumental; +Cc: gcc-patches, Kirill Yukhin On Tue, Jul 07, 2015 at 20:17:48 +0200, Jakub Jelinek wrote: > On Tue, Jul 07, 2015 at 08:08:16PM +0300, Maxim Blumental wrote: > > > Added 16 tests for simd construct and 10 for depend clause. > > Any new tests that aren't in Examples 4.0.* document should go one level > higher, to libgomp.{c,c++,fortran}/ directly. Actually, the examples 4.0.2 document contains simd-* and task_dep-* tests, they are new in terms of examples-4 directory. -- Ilya ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-07 18:30 ` Ilya Verbin @ 2015-07-08 12:51 ` Maxim Blumental 2015-07-08 13:00 ` Maxim Blumental 0 siblings, 1 reply; 19+ messages in thread From: Maxim Blumental @ 2015-07-08 12:51 UTC (permalink / raw) To: Ilya Verbin; +Cc: Jakub Jelinek, gcc-patches, Kirill Yukhin [-- Attachment #1: Type: text/plain, Size: 676 bytes --] Updated the attached files: renamed also libgomp.c++ tests, corrected ChangeLog. 2015-07-07 21:29 GMT+03:00 Ilya Verbin <iverbin@gmail.com>: > On Tue, Jul 07, 2015 at 20:17:48 +0200, Jakub Jelinek wrote: >> On Tue, Jul 07, 2015 at 08:08:16PM +0300, Maxim Blumental wrote: >> > > Added 16 tests for simd construct and 10 for depend clause. >> >> Any new tests that aren't in Examples 4.0.* document should go one level >> higher, to libgomp.{c,c++,fortran}/ directly. > > Actually, the examples 4.0.2 document contains simd-* and task_dep-* tests, they > are new in terms of examples-4 directory. > > -- Ilya -- --------------------- Sincerely yours, Maxim Blumental [-- Attachment #2: ChangeLog.txt --] [-- Type: text/plain, Size: 9946 bytes --] 2015-07-06 Maxim Blumenthal <maxim.blumenthal@intel.com> * testsuite/libgomp.c++/examples-4/e.53.2.C: Renamed to... * testsuite/libgomp.c++/examples-4/declare_target-2.C: ...this. * testsuite/libgomp.c++/examples-4/e.51.5.C: Renamed to... * testsuite/libgomp.c++/examples-4/target_data-5.C: ...this. * testsuite/libgomp.c/examples-4/e.56.3.c: Renamed to... * testsuite/libgomp.c/examples-4/array_sections-3.c: ...this. * testsuite/libgomp.c/examples-4/e.56.4.c: Renamed to... * testsuite/libgomp.c/examples-4/array_sections-4.c: ...this. * testsuite/libgomp.c/examples-4/e.55.1.c: Renamed to... * testsuite/libgomp.c/examples-4/async_target-1.c: ...this. * testsuite/libgomp.c/examples-4/e.55.2.c: Renamed to... * testsuite/libgomp.c/examples-4/async_target-2.c: ...this. * testsuite/libgomp.c/examples-4/e.53.1.c: Renamed to... * testsuite/libgomp.c/examples-4/declare_target-1.c: ...this. * testsuite/libgomp.c/examples-4/e.53.3.c: Renamed to... * testsuite/libgomp.c/examples-4/declare_target-3.c: ...this. * testsuite/libgomp.c/examples-4/e.53.4.c: Renamed to... * testsuite/libgomp.c/examples-4/declare_target-4.c: ...this. * testsuite/libgomp.c/examples-4/e.53.5.c: Renamed to... * testsuite/libgomp.c/examples-4/declare_target-5.c: ...this. * testsuite/libgomp.c/examples-4/e.57.1.c: Renamed to... * testsuite/libgomp.c/examples-4/device-1.c: ...this. * testsuite/libgomp.c/examples-4/e.57.2.c: Renamed to... * testsuite/libgomp.c/examples-4/device-2.c: ...this. * testsuite/libgomp.c/examples-4/e.57.3.c: Renamed to... * testsuite/libgomp.c/examples-4/device-3.c: ...this. * testsuite/libgomp.c/examples-4/simd-1.c: A test for simd construct. * testsuite/libgomp.c/examples-4/simd-2.c: Same. * testsuite/libgomp.c/examples-4/simd-3.c: Same. * testsuite/libgomp.c/examples-4/simd-4.c: Same. * testsuite/libgomp.c/examples-4/simd-5.c: Same. * testsuite/libgomp.c/examples-4/simd-6.c: Same. * testsuite/libgomp.c/examples-4/simd-7.c: Same. * testsuite/libgomp.c/examples-4/simd-8.c: Same. * testsuite/libgomp.c/examples-4/e.50.1.c: Renamed to... * testsuite/libgomp.c/examples-4/target-1.c: ...this. * testsuite/libgomp.c/examples-4/e.50.2.c: Renamed to... * testsuite/libgomp.c/examples-4/target-2.c: ...this. * testsuite/libgomp.c/examples-4/e.50.3.c: Renamed to... * testsuite/libgomp.c/examples-4/target-3.c: ...this. * testsuite/libgomp.c/examples-4/e.50.4.c: Renamed to... * testsuite/libgomp.c/examples-4/target-4.c: ...this. * testsuite/libgomp.c/examples-4/e.50.5.c: Renamed to... * testsuite/libgomp.c/examples-4/target-5.c: ...this. * testsuite/libgomp.c/examples-4/e.51.1.c: Renamed to... * testsuite/libgomp.c/examples-4/target_data-1.c: ...this. * testsuite/libgomp.c/examples-4/e.51.2.c: Renamed to... * testsuite/libgomp.c/examples-4/target_data-2.c: ...this. * testsuite/libgomp.c/examples-4/e.51.3.c: Renamed to... * testsuite/libgomp.c/examples-4/target_data-3.c: ...this. * testsuite/libgomp.c/examples-4/e.51.4.c: Renamed to... * testsuite/libgomp.c/examples-4/target_data-4.c: ...this. * testsuite/libgomp.c/examples-4/e.51.6.c: Renamed to... * testsuite/libgomp.c/examples-4/target_data-6.c: ...this. * testsuite/libgomp.c/examples-4/e.51.7.c: Renamed to... * testsuite/libgomp.c/examples-4/target_data-7.c: ...this. * testsuite/libgomp.c/examples-4/e.52.1.c: Renamed to... * testsuite/libgomp.c/examples-4/target_update-1.c: ...this. * testsuite/libgomp.c/examples-4/e.52.2.c: Renamed to... * testsuite/libgomp.c/examples-4/target_update-2.c: ...this. * testsuite/libgomp.c/examples-4/task_dep-1.c: A test for task dependencies. * testsuite/libgomp.c/examples-4/task_dep-2.c: Same. * testsuite/libgomp.c/examples-4/task_dep-3.c: Same. * testsuite/libgomp.c/examples-4/task_dep-4.c: Same. * testsuite/libgomp.c/examples-4/task_dep-5.c: Same. * testsuite/libgomp.c/examples-4/e.54.2.c: Renamed to... * testsuite/libgomp.c/examples-4/teams-2.c: ...this. * testsuite/libgomp.c/examples-4/e.54.3.c: Renamed to... * testsuite/libgomp.c/examples-4/teams-3.c: ...this. * testsuite/libgomp.c/examples-4/e.54.4.c: Renamed to... * testsuite/libgomp.c/examples-4/teams-4.c: ...this. * testsuite/libgomp.c/examples-4/e.54.5.c: Renamed to... * testsuite/libgomp.c/examples-4/teams-5.c: ...this. * testsuite/libgomp.c/examples-4/e.54.6.c: Renamed to... * testsuite/libgomp.c/examples-4/teams-6.c: ...this. * testsuite/libgomp.fortran/examples-4/e.56.3.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/array_sections-3.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.56.4.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/array_sections-4.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.55.1.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/async_target-1.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.55.2.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/async_target-2.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.53.1.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/declare_target-1.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.53.2.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/declare_target-2.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.53.3.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/declare_target-3.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.53.4.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/declare_target-4.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.53.5.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/declare_target-5.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.57.1.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/device-1.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.57.2.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/device-2.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.57.3.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/device-3.f90: ...this. * testsuite/libgomp.fortran/examples-4/simd-1.f90: A test for simd construct. * testsuite/libgomp.fortran/examples-4/simd-2.f90: Same. * testsuite/libgomp.fortran/examples-4/simd-3.f90: Same. * testsuite/libgomp.fortran/examples-4/simd-4.f90: Same. * testsuite/libgomp.fortran/examples-4/simd-5.f90: Same. * testsuite/libgomp.fortran/examples-4/simd-6.f90: Same. * testsuite/libgomp.fortran/examples-4/simd-7.f90: Same. * testsuite/libgomp.fortran/examples-4/simd-8.f90: Same. * testsuite/libgomp.fortran/examples-4/e.50.1.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target-1.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.50.2.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target-2.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.50.3.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target-3.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.50.4.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target-4.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.50.5.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target-5.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.51.1.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target_data-1.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.51.2.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target_data-2.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.51.3.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target_data-3.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.51.4.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target_data-4.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.51.5.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target_data-5.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.51.6.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target_data-6.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.51.7.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target_data-7.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.52.1.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target_update-1.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.52.2.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/target_update-2.f90: ...this. * testsuite/libgomp.fortran/examples-4/task_dep-1.f90: A test for task dependencies. * testsuite/libgomp.fortran/examples-4/task_dep-2.f90: Same. * testsuite/libgomp.fortran/examples-4/task_dep-3.f90: Same. * testsuite/libgomp.fortran/examples-4/task_dep-4.f90: Same. * testsuite/libgomp.fortran/examples-4/task_dep-5.f90: Same. * testsuite/libgomp.fortran/examples-4/e.54.2.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/teams-2.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.54.3.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/teams-3.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.54.4.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/teams-4.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.54.5.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/teams-5.f90: ...this. * testsuite/libgomp.fortran/examples-4/e.54.6.f90: Renamed to... * testsuite/libgomp.fortran/examples-4/teams-6.f90: ...this. [-- Attachment #3: libgomp-tests.patch --] [-- Type: application/octet-stream, Size: 55128 bytes --] commit 5a20d77911f6159de0d0e08a74c0c26382673c58 Author: Maxim Blumenthal <maxim.blumenthal@intel.com> Date: Mon Jun 22 14:11:22 2015 +0300 Renamed Fortran, C and C++ tests for libgomp based on OpenMP Examples tests to make the names more understandable, e.g. e.55.2.f90 to async_target-2.f90. Also made minor modifications to them. Added 16 tests for simd construct and 10 for task dependencies. Those tests are based on OpenMP Examples 4.0.2. diff --git a/libgomp/testsuite/libgomp.c++/examples-4/e.53.2.C b/libgomp/testsuite/libgomp.c++/examples-4/declare_target-2.C similarity index 100% rename from libgomp/testsuite/libgomp.c++/examples-4/e.53.2.C rename to libgomp/testsuite/libgomp.c++/examples-4/declare_target-2.C diff --git a/libgomp/testsuite/libgomp.c++/examples-4/e.51.5.C b/libgomp/testsuite/libgomp.c++/examples-4/target_data-5.C similarity index 100% rename from libgomp/testsuite/libgomp.c++/examples-4/e.51.5.C rename to libgomp/testsuite/libgomp.c++/examples-4/target_data-5.C diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.56.3.c b/libgomp/testsuite/libgomp.c/examples-4/array_sections-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.56.3.c rename to libgomp/testsuite/libgomp.c/examples-4/array_sections-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.56.4.c b/libgomp/testsuite/libgomp.c/examples-4/array_sections-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.56.4.c rename to libgomp/testsuite/libgomp.c/examples-4/array_sections-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.55.1.c b/libgomp/testsuite/libgomp.c/examples-4/async_target-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.55.1.c rename to libgomp/testsuite/libgomp.c/examples-4/async_target-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.55.2.c b/libgomp/testsuite/libgomp.c/examples-4/async_target-2.c similarity index 89% rename from libgomp/testsuite/libgomp.c/examples-4/e.55.2.c rename to libgomp/testsuite/libgomp.c/examples-4/async_target-2.c index f03cae3..ce63328 100644 --- a/libgomp/testsuite/libgomp.c/examples-4/e.55.2.c +++ b/libgomp/testsuite/libgomp.c/examples-4/async_target-2.c @@ -19,8 +19,9 @@ void init (float *a, float *b, int n) } #pragma omp end declare target -void vec_mult_ref (float *p, float *v1, float *v2, int n) +void vec_mult_ref(float *p, int n) { + float *v1, *v2; int i; v1 = (float *) malloc (n * sizeof (float)); @@ -35,8 +36,9 @@ void vec_mult_ref (float *p, float *v1, float *v2, int n) free (v2); } -void vec_mult (float *p, float *v1, float *v2, int n) +void vec_mult(float *p, int n) { + float *v1, *v2; int i; #pragma omp task shared(v1, v2) depend(out: v1, v2) @@ -64,6 +66,8 @@ void vec_mult (float *p, float *v1, float *v2, int n) free (v1); free (v2); } + + #pragma omp taskwait } void check (float *a, float *b, int n) @@ -81,10 +85,9 @@ int main () { float *p1 = (float *) malloc (N * sizeof (float)); float *p2 = (float *) malloc (N * sizeof (float)); - float *v1, *v2; - vec_mult_ref (p1, v1, v2, N); - vec_mult (p2, v1, v2, N); + vec_mult_ref (p1, N); + vec_mult (p2, N); check (p1, p2, N); diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.1.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.1.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.3.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.3.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.4.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.4.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.5.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-5.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.5.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-5.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.57.1.c b/libgomp/testsuite/libgomp.c/examples-4/device-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.57.1.c rename to libgomp/testsuite/libgomp.c/examples-4/device-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.57.2.c b/libgomp/testsuite/libgomp.c/examples-4/device-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.57.2.c rename to libgomp/testsuite/libgomp.c/examples-4/device-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.57.3.c b/libgomp/testsuite/libgomp.c/examples-4/device-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.57.3.c rename to libgomp/testsuite/libgomp.c/examples-4/device-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-1.c b/libgomp/testsuite/libgomp.c/examples-4/simd-1.c new file mode 100644 index 0000000..5baaf30 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-1.c @@ -0,0 +1,65 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define OFF 32 +#define EPS 0.0000000000000001 + +#include <stdlib.h> + +void init(double *a, double *a_ref, double *b, double *c, int n, int ioff) +{ + int i; + for ( i = 0; i < n; i++ ) + { + a[i] = i*i; + a_ref[i] = a[i]; + b[i] = i+i; + } + + int s = -1; + for ( i = 0; i < n+ioff; i++ ) + { + c[i] = s*3; + s = -s; + } +} + +void star( double *a, double *b, double *c, int n, int *ioff ) +{ + int i; + #pragma omp simd + for ( i = 0; i < n; i++ ) + a[i] *= b[i] * c[i+ *ioff]; +} + +void star_ref( double *a, double *b, double *c, int n, int *ioff ) +{ + int i; + for ( i = 0; i < n; i++ ) + a[i] *= b[i] * c[i+ *ioff]; +} + +void check (double *a, double *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + +int main () +{ + double a[N], a_ref[N], b[N], c[N+OFF]; + int ioff = OFF; + + init(a, a_ref, b, c, N, ioff); + + star(a, b, c, N, &ioff); + star_ref(a_ref, b, c, N, &ioff); + + check(a, a_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-2.c b/libgomp/testsuite/libgomp.c/examples-4/simd-2.c new file mode 100644 index 0000000..c0ad30a --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-2.c @@ -0,0 +1,90 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define EPS 0.0000000000000001 + +#include <stdlib.h> + +void init(double *a, double *a_ref, double *b, int n) +{ + int i; + for ( i=0; i<N; i++ ) + { + a[i] = i; + a_ref[i] = i; + b[i] = N-i; + } +} + +#pragma omp declare simd uniform(fact) +double add1(double a, double b, double fact) +{ + double c; + c = a + b + fact; + return c; +} + +#pragma omp declare simd uniform(a,b,fact) linear(i:1) +double add2(double *a, double *b, int i, double fact) +{ + double c; + c = a[i] + b[i] + fact; + return c; +} + +#pragma omp declare simd uniform(fact) linear(a,b:1) +double add3(double *a, double *b, double fact) +{ + double c; + c = *a + *b + fact; + return c; +} + +void work( double *a, double *b, int n ) +{ + int i; + double tmp; + #pragma omp simd private(tmp) + for ( i = 0; i < n; i++ ) { + tmp = add1( a[i], b[i], 1.0); + a[i] = add2( a, b, i, 1.0) + tmp; + a[i] = add3(&a[i], &b[i], 1.0); + } +} + +void work_ref( double *a, double *b, int n ) +{ + int i; + double tmp; + for ( i = 0; i < n; i++ ) { + tmp = add1( a[i], b[i], 1.0); + a[i] = add2( a, b, i, 1.0) + tmp; + a[i] = add3(&a[i], &b[i], 1.0); + } +} + +void check (double *a, double *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + + +int main () +{ + int i; + double a[N], a_ref[N], b[N]; + + init(a, a_ref, b, N); + + work(a, b, N ); + work_ref(a_ref, b, N ); + + check(a, a_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-3.c b/libgomp/testsuite/libgomp.c/examples-4/simd-3.c new file mode 100644 index 0000000..9f33713 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-3.c @@ -0,0 +1,61 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define EPS 0.0000000000000001 + +#include <stdlib.h> + +void init(double *a, double *a_ref, double *b, int n) +{ + int i, s = -1; + for ( i = 0; i < n; i++ ) + { + a[i] = i*i*s; + a_ref[i] = a[i]; + b[i] = i+i; + s = -s; + } +} + +double work( double *a, double *b, int n ) +{ + int i; + double tmp, sum; + sum = 0.0; + #pragma omp simd private(tmp) reduction(+:sum) + for (i = 0; i < n; i++) { + tmp = a[i] + b[i]; + sum += tmp; + } + return sum; +} + +double work_ref( double *a, double *b, int n ) +{ + int i; + double tmp, sum; + sum = 0.0; + for (i = 0; i < n; i++) { + tmp = a[i] + b[i]; + sum += tmp; + } + return sum; +} + +int main () +{ + double a[N], a_ref[N], b[N]; + int res, ref; + + init(a, a_ref, b, N); + + res = work(a, b, N); + ref = work_ref(a_ref, b, N); + + if (res != ref) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-4.c b/libgomp/testsuite/libgomp.c/examples-4/simd-4.c new file mode 100644 index 0000000..1aa0425 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-4.c @@ -0,0 +1,58 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 128 +#define M 16 +#define EPS 0.0000000000000001 +#define SAFELEN 16 + +#include <stdlib.h> + +void init(double *a, double *b, int n) +{ + int i, s = -1; + for ( i = 0; i < n; i++ ) + { + a[i] = i*i*s; + b[i] = a[i]; + s = -s; + } +} + +void work( double *b, int n, int m ) +{ + int i; + #pragma omp simd safelen(SAFELEN) + for (i = m; i < n; i++) + b[i] = b[i-m] - 1.0f; +} + +void work_ref( double *b, int n, int m ) +{ + int i; + for (i = m; i < n; i++) + b[i] = b[i-m] - 1.0f; +} + +void check (double *a, double *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + +int main () +{ + double b[N], b_ref[N]; + + init(b, b_ref, N); + + work(b, N, M); + work(b_ref, N, M); + + check(b, b_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-5.c b/libgomp/testsuite/libgomp.c/examples-4/simd-5.c new file mode 100644 index 0000000..ce037ac --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-5.c @@ -0,0 +1,76 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 128 +#define M 16 +#define EPS 0.0000000000000001 +#define SAFELEN 16 + +#include <stdlib.h> + +void init(double a[N][N], double b[N][N], int n) +{ + int i, j, s = -1; + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + a[i][j] = i * j * s; + b[i][j] = i + j + s; + s = -s; + } + } +} + +void work( double a[N][N], double b[N][N], double c[N][N], int n ) +{ + int i, j; + double tmp; + #pragma omp for simd collapse(2) private(tmp) + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + tmp = a[i][j] + b[i][j]; + c[i][j] = tmp; + } + } +} + +void work_ref( double a[N][N], double b[N][N], double c[N][N], int n ) +{ + int i, j; + double tmp; + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + tmp = a[i][j] + b[i][j]; + c[i][j] = tmp; + } + } +} + +void check (double a[N][N], double b[N][N]) +{ + int i, j; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + if (a[i][j] - b[i][j] > EPS || b[i][j] - a[i][j] > EPS) + abort (); +} + +int main () +{ + double a[N][N], b[N][N], c[N][N], c_ref[N][N]; + + init(a, b, N); + + work(a, b, c, N); + work_ref(a, b, c_ref, N); + + check(c, c_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-6.c b/libgomp/testsuite/libgomp.c/examples-4/simd-6.c new file mode 100644 index 0000000..d313c70 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-6.c @@ -0,0 +1,105 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define EPS 0.000001 + +#include <stdlib.h> +#include <stdio.h> + +void init(int *b, float *y, int n) +{ + int i, s = -1; + for ( i=0; i<N; i++ ) + { + b[i] = i*i*s; + y[i] = b[i] * 0.1f; + s = -s; + } +} + +#pragma omp declare simd linear(p:1) notinbranch +int foo(int *p){ + *p = *p + 10; + return *p; +} + +int myaddint(int *a, int *b, int n) +{ +#pragma omp simd + for (int i=0; i<n; i++){ + a[i] = foo(&b[i]); /* foo is not called under a condition */ + } + return a[n-1]; +} + +int myaddint_ref(int *a, int *b, int n) +{ + for (int i=0; i<n; i++){ + a[i] = foo(&b[i]); + } + return a[n-1]; +} + +#pragma omp declare simd linear(p:1) inbranch +float goo(float *p){ + *p = *p + 18.5f; + return *p; +} + +int myaddfloat(float *x, float *y, int n) +{ +#pragma omp simd + for (int i=0; i<n; i++){ + x[i] = (x[i] > y[i]) ? goo(&y[i]) : y[i]; + /* goo is called under the condition (or within a branch) */ + } + return x[n-1]; +} + +int myaddfloat_ref(float *x, float *y, int n) +{ + for (int i=0; i<n; i++){ + x[i] = (x[i] > y[i]) ? goo(&y[i]) : y[i]; + } + return x[n-1]; +} + +void check_addint (int *a, int *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] != b[i]) + abort (); +} + +void check_addfloat (float *a, float *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + +int main () +{ + int i; + int a[N], a_ref[N], b[N]; + float x[N], x_ref[N], y[N]; + + init(a, x, N); + init(b, y, N); + myaddint(a, b, N); + myaddfloat(x, y, N); + + init(a_ref, x_ref, N); + init(b, y, N); + myaddint_ref(a_ref, b, N); + myaddfloat_ref(x_ref, y, N); + + check_addint(a, a_ref); + check_addfloat(x, x_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-7.c b/libgomp/testsuite/libgomp.c/examples-4/simd-7.c new file mode 100644 index 0000000..9c3040a --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-7.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include <stdio.h> +#include <stdlib.h> + +#define N 45 +int a[N], a_ref[N], b[N]; + +#pragma omp declare simd inbranch +int fib( int n ) +{ + if (n <= 2) + return n; + else { + return fib(n-1) + fib(n-2); + } +} + +int main(void) +{ + int i; + +#pragma omp simd + for (i=0; i < N; i++) + b[i] = i; + +#pragma omp simd + for (i=0; i < N; i++) + a[i] = fib(b[i]); + + for (i=0; i < N; i++) + a_ref[i] = fib(b[i]); + + for (i=0; i < N; i++) + if (a[i] != a_ref[i]) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-8.c b/libgomp/testsuite/libgomp.c/examples-4/simd-8.c new file mode 100644 index 0000000..397e2a3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-8.c @@ -0,0 +1,49 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include <stdlib.h> +#include <math.h> + +int P[1000]; +float A[1000]; + +float do_work(float *arr) +{ + float pri; + +#pragma omp simd lastprivate(pri) + for (int i = 0; i < 999; ++i) + { + int j = P[i]; + + pri = 0.5f; + if (j % 2 == 0) + { + pri = A[j+1] + arr[i]; + } + A[j] = pri * 1.5f; + pri = pri + A[j]; + } + + return pri; +} + +int main(void) +{ + float pri, arr[1000]; + + for (int i = 0; i < 1000; ++i) + { + P[i] = i; + A[i] = i * 1.5f; + arr[i] = i * 1.8f; + } + + pri = do_work(&arr[0]); + + if (pri != 8237.25) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.1.c b/libgomp/testsuite/libgomp.c/examples-4/target-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.1.c rename to libgomp/testsuite/libgomp.c/examples-4/target-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.2.c b/libgomp/testsuite/libgomp.c/examples-4/target-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.2.c rename to libgomp/testsuite/libgomp.c/examples-4/target-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.3.c b/libgomp/testsuite/libgomp.c/examples-4/target-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.3.c rename to libgomp/testsuite/libgomp.c/examples-4/target-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.4.c b/libgomp/testsuite/libgomp.c/examples-4/target-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.4.c rename to libgomp/testsuite/libgomp.c/examples-4/target-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.5.c b/libgomp/testsuite/libgomp.c/examples-4/target-5.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.5.c rename to libgomp/testsuite/libgomp.c/examples-4/target-5.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.1.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.1.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.2.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.2.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.3.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.3.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.4.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.4.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.6.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-6.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.6.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-6.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.7.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-7.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.7.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-7.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.52.1.c b/libgomp/testsuite/libgomp.c/examples-4/target_update-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.52.1.c rename to libgomp/testsuite/libgomp.c/examples-4/target_update-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.52.2.c b/libgomp/testsuite/libgomp.c/examples-4/target_update-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.52.2.c rename to libgomp/testsuite/libgomp.c/examples-4/target_update-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-1.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-1.c new file mode 100644 index 0000000..8d397a5 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-1.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +#include <stdlib.h> +int main() +{ + int x = 1; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(out: x) + x = 2; + #pragma omp task shared(x) depend(in: x) + if (x != 2) + abort (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-2.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-2.c new file mode 100644 index 0000000..f583f09 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-2.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +#include <stdlib.h> +int main() +{ + int x = 1; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(in: x) + if (x != 1) + abort (); + #pragma omp task shared(x) depend(out: x) + x = 2; + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-3.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-3.c new file mode 100644 index 0000000..189d5e0 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-3.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +#include <stdlib.h> + +int main() +{ + int x = 0; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(out: x) + x = 1; + #pragma omp task shared(x) depend(out: x) + x = 2; + #pragma omp taskwait + if (x != 1 && x != 2) + abort (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-4.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-4.c new file mode 100644 index 0000000..77aa57a4 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-4.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +#include <stdlib.h> +int main() +{ + int x = 1; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(out: x) + x = 2; + #pragma omp task shared(x) depend(in: x) + if (x != 2) + abort (); + #pragma omp task shared(x) depend(in: x) + if (x != 2) + abort (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-5.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-5.c new file mode 100644 index 0000000..cc2cda5 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-5.c @@ -0,0 +1,81 @@ +/* { dg-do run } */ + +#define N 128 +#define BS 16 +#define EPS 0.000001 + +#include <stdlib.h> + +void matmul_depend (float A[N][N], float B[N][N], float C[N][N]) +{ + int i, j, k, ii, jj, kk; + for (i = 0; i < N; i+=BS) + for (j = 0; j < N; j+=BS) + for (k = 0; k < N; k+=BS) +// Note 1: i, j, k, A, B, C are firstprivate by default +// Note 2: A, B and C are just pointers +#pragma omp task private(ii, jj, kk) \ + depend ( in: A[i:BS][k:BS], B[k:BS][j:BS] ) \ + depend ( inout: C[i:BS][j:BS] ) + for (ii = i; ii < i+BS; ii++ ) + for (jj = j; jj < j+BS; jj++ ) + for (kk = k; kk < k+BS; kk++ ) + C[ii][jj] = C[ii][jj] + A[ii][kk] * B[kk][jj]; +} + +void matmul_ref (float A[N][N], float B[N][N], float C[N][N]) +{ + int i, j, k; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + for (k = 0; k < N; k++) + C[i][j] += A[i][k] * B[k][j]; +} + +void init (float A[N][N], float B[N][N]) +{ + int i, j, s = -1; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + A[i][j] = i * j * s; + B[i][j] = i + j; + s = -s; + } +} + +void init_zero (float A[N][N], float B[N][N]) +{ + int i, j, s = -1; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + A[i][j] = 0; + B[i][j] = 0; + } +} + +void check (float A[N][N], float B[N][N]) +{ + int i, j; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + if (A[i][j] - B[i][j] > EPS || B[i][j] - A[i][j] > EPS) + abort (); +} + +int main () +{ + float A[N][N], B[N][N], C[N][N], C_ref[N][N]; + + init (A, B); + init_zero (C, C_ref); + + matmul_depend (A, B, C); + matmul_ref (A, B, C_ref); + + check (C, C_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.2.c b/libgomp/testsuite/libgomp.c/examples-4/teams-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.2.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.3.c b/libgomp/testsuite/libgomp.c/examples-4/teams-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.3.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.4.c b/libgomp/testsuite/libgomp.c/examples-4/teams-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.4.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.5.c b/libgomp/testsuite/libgomp.c/examples-4/teams-5.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.5.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-5.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.6.c b/libgomp/testsuite/libgomp.c/examples-4/teams-6.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.6.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-6.c diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.56.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/array_sections-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.56.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/array_sections-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.56.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/array_sections-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.56.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/array_sections-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.55.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/async_target-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.55.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/async_target-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.55.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/async_target-2.f90 similarity index 98% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.55.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/async_target-2.f90 index dfcb5f4..b12b0ea 100644 --- a/libgomp/testsuite/libgomp.fortran/examples-4/e.55.2.f90 +++ b/libgomp/testsuite/libgomp.fortran/examples-4/async_target-2.f90 @@ -46,6 +46,8 @@ subroutine vec_mult (p, N) !$omp end target !$omp end task !$omp end target data + + !$omp taskwait call check (p, N) end subroutine diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.57.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/device-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.57.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/device-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.57.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/device-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.57.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/device-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.57.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/device-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.57.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/device-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-1.f90 new file mode 100644 index 0000000..b1af859 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-1.f90 @@ -0,0 +1,67 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD1_mod +contains + subroutine init (a, a_ref, b, c, n, ioff_ptr) + double precision :: a(*), a_ref(*), b(*), c(*) + integer :: n, i, s + integer, pointer :: ioff_ptr + + s = -1 + do i = 1, n + a(i) = i * i * s + a_ref(i) = a(i) + b(i) = i + i + end do + + do i = 1, n+ioff_ptr + c(i) = i * 3 + end do + + end subroutine + + subroutine check (a, b, n) + integer :: i, n + double precision, parameter :: EPS = 0.0000000000001 + double precision :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine + + subroutine star(a, a_ref, b, c, n, ioff_ptr) + double precision :: a(*), a_ref(*), b(*), c(*) + integer :: n, i + integer, pointer :: ioff_ptr + + call init (a, a_ref, b, c, n, ioff_ptr) + + !$omp simd + do i = 1,n + a(i) = a(i) * b(i) * c(i+ioff_ptr) + end do + + do i = 1,n + a_ref(i) = a_ref(i) * b(i) * c(i+ioff_ptr) + end do + + call check (a, a_ref, n) + + end subroutine +end module + +program SIMD1 + use SIMD1_mod, only : star + double precision :: a(128), a_ref(128), b(128), c(144) + integer, pointer:: ioff_ptr + integer, target:: offset + + offset = 16 + ioff_ptr => offset + + call star (a, a_ref, b, c, 128, ioff_ptr) + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90 new file mode 100644 index 0000000..dd6433d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90 @@ -0,0 +1,72 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD2_mod +contains + function add1(a,b,fact) result(c) + !$omp declare simd(add1) uniform(fact) + double precision :: a,b,fact, c + c = a + b + fact + end function + + function add2(a,b,i, fact) result(c) + !$omp declare simd(add2) uniform(a,b,fact) linear(i:1) + integer, value :: i + double precision, dimension(:) :: a, b + double precision :: fact, c + c = a(i) + b(i) + fact + end function + + subroutine work(a, b, n ) + implicit none + double precision :: a(n),b(n), tmp + integer :: n, i + + !$omp simd private(tmp) + do i = 1,n + tmp = add1(a(i), b(i), 1.0d0) + a(i) = add2(a, b, i, 1.0d0) + tmp + a(i) = a(i) + b(i) + 1.0d0 + end do + end subroutine + + subroutine work_ref(a, b, n ) + implicit none + double precision :: a(n),b(n), tmp + integer :: n, i + + do i = 1,n + tmp = add1(a(i), b(i), 1.0d0) + a(i) = add2(a, b, i, 1.0d0) + tmp + a(i) = a(i) + b(i) + 1.0d0 + end do + end subroutine + + subroutine check (a, b, n) + integer :: i, n + double precision, parameter :: EPS = 0.0000000000001 + double precision :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine +end module + +program main + use SIMD2_mod + integer, parameter :: N=32 + integer :: i + double precision :: a(N), b(N), a_ref(N) + do i = 1,N + a(i) = i-1 + a_ref(i) = a(i) + b(i) = N-(i-1) + end do + + call work(a, b, N ) + call work_ref(a_ref, b, N ) + + call check(a, a_ref, N ) +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 new file mode 100644 index 0000000..f2e0047 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 @@ -0,0 +1,59 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD3_mod +contains + subroutine work( a, b, n, sum ) + implicit none + integer :: i, n + double precision :: a(n), b(n), sum, tmp + + sum = 0.0d0 + call init(a, b, n) + !$omp simd private(tmp) reduction(+:sum) + do i = 1,n + tmp = a(i) + b(i) + sum = sum + tmp + end do + + end subroutine work + + subroutine work_ref( a, b, n, sum ) + implicit none + integer :: i, n + double precision :: a(n), b(n), sum, tmp + + sum = 0.0d0 + call init(a, b, n) + do i = 1,n + tmp = a(i) + b(i) + sum = sum + tmp + end do + + end subroutine work_ref + + subroutine init (a, b, n) + double precision :: a(*), b(*) + integer :: n, i, s + + s = -1 + do i = 1, n + a(i) = i * i * s + b(i) = i + i + s = -s + end do + + end subroutine +end module + +program SIMD3 + use SIMD3_mod + double precision :: a(128), b(128), sum, sum_ref + + call work(a, b, 128, sum) + call work_ref(a, b, 128, sum_ref) + + if (sum .ne. sum_ref) call abort + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-4.f90 new file mode 100644 index 0000000..1100edc --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-4.f90 @@ -0,0 +1,64 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD4_mod +contains + subroutine work( b, n, m ) + implicit none + real :: b(n) + integer :: i,n,m + + call init(b, n) + + !$omp simd safelen(16) + do i = m+1, n + b(i) = b(i-m) - 1.0 + end do + end subroutine work + + subroutine work_ref( b, n, m ) + implicit none + real :: b(n) + integer :: i,n,m + + call init(b, n) + + do i = m+1, n + b(i) = b(i-m) - 1.0 + end do + end subroutine work_ref + + subroutine init (b, n) + real :: b(*) + integer :: n, i, s + + s = -1 + do i = 1, n + b(i) = i * i * s + s = -s + end do + + end subroutine + + subroutine check (a, b, n) + integer :: i, n + real, parameter :: EPS = 0.000001 + real :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine + +end module + +program SIMD4 + use SIMD4_mod + real :: b(128), b_ref(128) + + call work(b, 128, 32) + call work_ref(b_ref, 128, 32) + + call check(b, b_ref, 128) +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-5.f90 new file mode 100644 index 0000000..63cf024 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-5.f90 @@ -0,0 +1,76 @@ +! { dg-do compile } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD5_mod +contains + subroutine work( a, b, c, n ) + implicit none + integer :: i,j,n + double precision :: a(n,n), b(n,n), c(n,n), tmp + + !$omp for simd collapse(2) private(tmp) !{ dg-excess-errors "Unclassifiable OpenMP directive" } + do j = 1,n + do i = 1,n + tmp = a(i,j) + b(i,j) + c(i,j) = tmp + end do + end do + + end subroutine work + + subroutine work_ref( a, b, c, n ) + implicit none + integer :: i,j,n + double precision :: a(n,n), b(n,n), c(n,n), tmp + + do j = 1,n + do i = 1,n + tmp = a(i,j) + b(i,j) + c(i,j) = tmp + end do + end do + + end subroutine work_ref + + subroutine init (a, b, n) + integer :: i,j,n,s + double precision :: a(n,n), b(n,n) + + s = -1 + + do j = 1,n + do i = 1,n + a(i,j) = i*j*s + b(i,j) = i+j + s = -s + end do + end do + + end subroutine + + subroutine check (a, b, n) + integer :: i, j, n + double precision, parameter :: EPS = 0.0000000000000001 + double precision :: diff, a(n,n), b(n,n) + do j = 1, n + do i = 1, n + diff = a(i,j) - b(i,j) + if (diff > EPS .or. -diff > EPS) call abort + end do + end do + end subroutine + +end module + +program SIMD5 + use SIMD5_mod !{ dg-excess-errors "Can't open module file" } + double precision, dimension(32, 32) :: a, b, c, c_ref + + call init(a, b, 32) + + call work(a, b, c, 32) + call work_ref(a, b, c_ref, 32) + + call check(c, c_ref, 32) +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-6.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-6.f90 new file mode 100644 index 0000000..9a227cd --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-6.f90 @@ -0,0 +1,151 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD6_mod +contains + function foo(p) result(r) + !$omp declare simd(foo) notinbranch + integer :: p, r + p = p + 10 + r = p + end function foo + + function myaddint(a, b, n) result(r) + implicit none + integer :: a(*), b(*), n, r + integer :: i + + !$omp simd + do i=1, n + a(i) = foo(b(i)) ! foo is not called under a condition + end do + r = a(n) + + end function myaddint + + function myaddint_ref(a, b, n) result(r) + implicit none + integer :: a(*), b(*), n, r + integer :: i + + do i=1, n + a(i) = foo(b(i)) + end do + r = a(n) + + end function myaddint_ref + + function goo(p) result(r) + !$omp declare simd(goo) inbranch + real :: p, r + p = p + 18.5 + r = p + end function goo + + function myaddfloat(x, y, n) result(r) + implicit none + real :: x(*), y(*), r + integer :: n + integer :: i + + !$omp simd + do i=1, n + if (x(i) > y(i)) then + x(i) = goo(y(i)) + ! goo is called under the condition (or within a branch) + else + x(i) = y(i) + endif + end do + + r = x(n) + end function myaddfloat + + function myaddfloat_ref(x, y, n) result(r) + implicit none + real :: x(*), y(*), r + integer :: n + integer :: i + + do i=1, n + if (x(i) > y(i)) then + x(i) = goo(y(i)) + else + x(i) = y(i) + endif + end do + + r = x(n) + end function myaddfloat_ref + + subroutine init (b, y, n) + integer :: b(128) + real :: y(128) + + s = -1 + do i = 1, n + b(i) = i*i*s + y(i) = i*i*s + s = -s + end do + + end subroutine + + subroutine init2 (b, y, n) + integer :: b(128) + real :: y(128) + + do i = 1, n + b(i) = i + y(i) = i + end do + + end subroutine + + subroutine checkfloat (a, b, n) + integer :: i, n + real, parameter :: EPS = 0.000001 + real :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine + + subroutine checkint (a, b, n) + integer :: i, n, a(*), b(*) + do i = 1, n + if (a(i) .ne. b(i)) call abort + end do + end subroutine + + subroutine test () + integer :: a(128), a_ref(128), b(128), ri, ri_ref + real :: x(128), x_ref(128), y(128), rf, rf_ref + + call init2(a, x, 128) + call init2(a_ref, x_ref, 128) + + call init(b, y, 128) + + ri = myaddint (a, b, 128) + rf = myaddfloat (x, y, 128) + + call init(b, y, 128) + + ri_ref = myaddint_ref (a_ref, b, 128) + rf_ref = myaddfloat_ref (x_ref, y, 128) + + call checkint (a, a_ref, 128) + call checkfloat (x, x_ref, 128) + end subroutine + +end module + +program SIMD6 + use SIMD6_mod, only: test + + call test () + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 new file mode 100644 index 0000000..e64107d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 @@ -0,0 +1,49 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +program fibonacci + implicit none + integer,parameter :: N=45 + integer :: a(0:N-1), b(0:N-1) + integer :: a_ref(0:N-1), b_ref(0:N-1) + integer :: i + integer, external :: fib + + !$omp simd + do i = 0,N-1 + b(i) = i + end do + + do i = 0,N-1 + b_ref(i) = i + end do + + !$omp simd + do i=0,N-1 + a(i) = fib(b(i)) + end do + + do i=0,N-1 + a_ref(i) = fib(b_ref(i)) + end do + + do i = 0, N-1 + if (a(i) .ne. a_ref(i)) call abort () + end do + + if (a(44) .ne. 1134903170) call abort() + +end program + +recursive function fib(n) result(r) +!$omp declare simd(fib) inbranch + integer :: n, r + + if (n <= 2) then + r = n + else + r = fib(n-1) + fib(n-2) + endif + +end function fib diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 new file mode 100644 index 0000000..743bdcc --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 @@ -0,0 +1,48 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module work + +integer :: P(1000) +real :: A(1000) + +contains +function do_work(arr) result(pri) + implicit none + real, dimension(*) :: arr + + real :: pri + integer :: i, j + + !$omp simd private(j) lastprivate(pri) + do i = 1, 999 + j = P(i) + + pri = 0.5 + if (mod(j-1, 2) == 0) then + pri = A(j+1) + arr(i) + endif + A(j) = pri * 1.5 + pri = pri + A(j) + end do + +end function do_work + +end module work + +program simd_8f + use work + implicit none + real :: pri, arr(1000) + integer :: i + + do i = 1, 1000 + P(i) = i + A(i) = (i-1) * 1.5 + arr(i) = (i-1) * 1.8 + end do + pri = do_work(arr) + if (pri .ne. 8237.25) call abort () + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.6.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-6.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.6.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-6.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.7.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-7.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.7.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-7.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.52.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_update-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.52.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_update-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.52.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_update-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.52.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_update-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-1.f90 new file mode 100644 index 0000000..78201ea --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-1.f90 @@ -0,0 +1,16 @@ +! { dg-do run } + +program example + integer :: x + x = 1 + !$omp parallel + !$omp single + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp task shared(x) depend(in: x) + if (x .ne. 2) call abort () + !$omp end task + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-2.f90 new file mode 100644 index 0000000..5afd76d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-2.f90 @@ -0,0 +1,16 @@ +! { dg-do run } + +program example + integer :: x + x = 1 + !$omp parallel + !$omp single + !$omp task shared(x) depend(in: x) + if (x .ne. 1) call abort () + !$omp end task + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-3.f90 new file mode 100644 index 0000000..c8d5820 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-3.f90 @@ -0,0 +1,18 @@ +! { dg-do run } + +program example + integer :: x + x = 0 + !$omp parallel + !$omp single + !$omp task shared(x) depend(out: x) + x = 1 + !$omp end task + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp taskwait + if ((x .ne. 1) .and. (x .ne. 2)) call abort() + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-4.f90 new file mode 100644 index 0000000..7fe24c3 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-4.f90 @@ -0,0 +1,19 @@ +! { dg-do run } + +program example + integer :: x + x = 1 + !$omp parallel + !$omp single + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp task shared(x) depend(in: x) + if (x .ne. 2) call abort () + !$omp end task + !$omp task shared(x) depend(in: x) + if (x .ne. 2) call abort () + !$omp end task + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 new file mode 100644 index 0000000..12dd9e1 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 @@ -0,0 +1,100 @@ +! { dg-do run } + +module task_dep5_mod +contains + subroutine matmul_depend (N, BS, A, B, C) + implicit none + integer :: N, BS, BM + real, dimension(N, N) :: A, B, C + integer :: i, j, k, ii, jj, kk + BM = BS - 1 + do i = 1, N, BS + do j = 1, N, BS + do k = 1, N, BS + !$omp task shared(A,B,C) private(ii,jj,kk) & ! I,J,K are firstprivate by default + !$omp depend ( in: A(i:i+BM, k:k+BM), B(k:k+BM, j:j+BM) ) & + !$omp depend ( inout: C(i:i+BM, j:j+BM) ) + do ii = i, i+BM + do jj = j, j+BM + do kk = k, k+BM + C(jj,ii) = C(jj,ii) + A(kk,ii) * B(jj,kk) + end do + end do + end do + !$omp end task + end do + end do + end do + end subroutine + + subroutine matmul_ref (N, A, B, C) + implicit none + integer :: N + real, dimension(N, N) :: A, B, C + integer :: i, j, k + do i = 1, N + do j = 1, N + do k = 1, N + C(j,i) = C(j,i) + A(k,i) * B(j,k) + end do + end do + end do + end subroutine + + subroutine check (N, A, B) + integer :: N + integer :: i, j + integer, parameter :: EPS = 0.000001 + real, dimension(N,N) :: A, B + real :: diff + do i = 1, N + do j = 1, N + diff = A(i, j) - B(i, j) + if (diff > EPS .or. -diff > EPS) then + call abort () + end if + end do + end do + end subroutine + + subroutine init (N, A, B) + integer :: N + integer :: i, j, s + real, dimension(N,N) :: A, B + s = -1 + do i = 1, N + do j = 1, N + A(i, j) = i*j*s + B(i, j) = i+j + s = -s + end do + end do + end subroutine + + subroutine zero_init (N, A, B) + integer :: N + integer :: i, j + real, dimension(N,N) :: A, B + do i = 1, N + do j = 1, N + A(i, j) = 0 + B(i, j) = 0 + end do + end do + end subroutine + +end module + +program main + use task_dep5_mod + real, dimension(32, 32) :: A, B, C, C_ref + + call init (32, A, B) + call zero_init (32, C, C_ref) + + call matmul_depend(32, 4, A, B, C) + call matmul_ref(32, A, B, C_ref) + + call check (32, C, C_ref) + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.6.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-6.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.6.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-6.f90 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-08 12:51 ` Maxim Blumental @ 2015-07-08 13:00 ` Maxim Blumental 2015-07-09 12:57 ` Maxim Blumental 0 siblings, 1 reply; 19+ messages in thread From: Maxim Blumental @ 2015-07-08 13:00 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches, Kirill Yukhin >The Examples-4/ >directory is supposed to only contain the tests from the 4.0.* examples >document and no other tests. All right: everything I added in it was only tests from the examples document. Renamings were made in accordance with filenames from GitHub. > Any new tests that aren't in Examples 4.0.* document should go one level > higher, to libgomp.{c,c++,fortran}/ directly. There are no any such tests. 2015-07-08 15:50 GMT+03:00 Maxim Blumental <bvmaks@gmail.com>: > Updated the attached files: renamed also libgomp.c++ tests, corrected > ChangeLog. > > 2015-07-07 21:29 GMT+03:00 Ilya Verbin <iverbin@gmail.com>: >> On Tue, Jul 07, 2015 at 20:17:48 +0200, Jakub Jelinek wrote: >>> On Tue, Jul 07, 2015 at 08:08:16PM +0300, Maxim Blumental wrote: >>> > > Added 16 tests for simd construct and 10 for depend clause. >>> >>> Any new tests that aren't in Examples 4.0.* document should go one level >>> higher, to libgomp.{c,c++,fortran}/ directly. >> >> Actually, the examples 4.0.2 document contains simd-* and task_dep-* tests, they >> are new in terms of examples-4 directory. >> >> -- Ilya > > > > -- > > > --------------------- > Sincerely yours, > Maxim Blumental -- --------------------- Sincerely yours, Maxim Blumental ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-08 13:00 ` Maxim Blumental @ 2015-07-09 12:57 ` Maxim Blumental 2015-07-09 14:23 ` Maxim Blumental 0 siblings, 1 reply; 19+ messages in thread From: Maxim Blumental @ 2015-07-09 12:57 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches, Kirill Yukhin > I'll have a look, that is supposed to work. I checked the case with 'simd collapse' and found out that the problem was in a typo in the directive in OpenMP Examples whose code I used. There was a redundant 'for' word in it which the parser detected and considered to be an unclassifiable OpenMP directive. Sorry about the false alarm. 2015-07-08 16:00 GMT+03:00 Maxim Blumental <bvmaks@gmail.com>: >>The Examples-4/ >>directory is supposed to only contain the tests from the 4.0.* examples >>document and no other tests. > All right: everything I added in it was only tests from the examples > document. Renamings were made in accordance with filenames from > GitHub. >> Any new tests that aren't in Examples 4.0.* document should go one level >> higher, to libgomp.{c,c++,fortran}/ directly. > There are no any such tests. > > 2015-07-08 15:50 GMT+03:00 Maxim Blumental <bvmaks@gmail.com>: >> Updated the attached files: renamed also libgomp.c++ tests, corrected >> ChangeLog. >> >> 2015-07-07 21:29 GMT+03:00 Ilya Verbin <iverbin@gmail.com>: >>> On Tue, Jul 07, 2015 at 20:17:48 +0200, Jakub Jelinek wrote: >>>> On Tue, Jul 07, 2015 at 08:08:16PM +0300, Maxim Blumental wrote: >>>> > > Added 16 tests for simd construct and 10 for depend clause. >>>> >>>> Any new tests that aren't in Examples 4.0.* document should go one level >>>> higher, to libgomp.{c,c++,fortran}/ directly. >>> >>> Actually, the examples 4.0.2 document contains simd-* and task_dep-* tests, they >>> are new in terms of examples-4 directory. >>> >>> -- Ilya >> >> >> >> -- >> >> >> --------------------- >> Sincerely yours, >> Maxim Blumental > > > > -- > > > --------------------- > Sincerely yours, > Maxim Blumental -- --------------------- Sincerely yours, Maxim Blumental ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-09 12:57 ` Maxim Blumental @ 2015-07-09 14:23 ` Maxim Blumental 2015-07-09 20:14 ` Jakub Jelinek 0 siblings, 1 reply; 19+ messages in thread From: Maxim Blumental @ 2015-07-09 14:23 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches, Kirill Yukhin [-- Attachment #1: Type: text/plain, Size: 2091 bytes --] Now the patch is corrected (according to the previous letter) and ready to be reviewed. I'm looking forward to your feedback. 2015-07-09 15:56 GMT+03:00 Maxim Blumental <bvmaks@gmail.com>: > > I'll have a look, that is supposed to work. > I checked the case with 'simd collapse' and found out that the problem > was in a typo in the directive in OpenMP Examples whose code I used. > There was a redundant 'for' word in it which the parser detected and > considered to be an unclassifiable OpenMP directive. Sorry about the > false alarm. > > 2015-07-08 16:00 GMT+03:00 Maxim Blumental <bvmaks@gmail.com>: >>>The Examples-4/ >>>directory is supposed to only contain the tests from the 4.0.* examples >>>document and no other tests. >> All right: everything I added in it was only tests from the examples >> document. Renamings were made in accordance with filenames from >> GitHub. >>> Any new tests that aren't in Examples 4.0.* document should go one level >>> higher, to libgomp.{c,c++,fortran}/ directly. >> There are no any such tests. >> >> 2015-07-08 15:50 GMT+03:00 Maxim Blumental <bvmaks@gmail.com>: >>> Updated the attached files: renamed also libgomp.c++ tests, corrected >>> ChangeLog. >>> >>> 2015-07-07 21:29 GMT+03:00 Ilya Verbin <iverbin@gmail.com>: >>>> On Tue, Jul 07, 2015 at 20:17:48 +0200, Jakub Jelinek wrote: >>>>> On Tue, Jul 07, 2015 at 08:08:16PM +0300, Maxim Blumental wrote: >>>>> > > Added 16 tests for simd construct and 10 for depend clause. >>>>> >>>>> Any new tests that aren't in Examples 4.0.* document should go one level >>>>> higher, to libgomp.{c,c++,fortran}/ directly. >>>> >>>> Actually, the examples 4.0.2 document contains simd-* and task_dep-* tests, they >>>> are new in terms of examples-4 directory. >>>> >>>> -- Ilya >>> >>> >>> >>> -- >>> >>> >>> --------------------- >>> Sincerely yours, >>> Maxim Blumental >> >> >> >> -- >> >> >> --------------------- >> Sincerely yours, >> Maxim Blumental > > > > -- > > > --------------------- > Sincerely yours, > Maxim Blumental -- --------------------- Sincerely yours, Maxim Blumental [-- Attachment #2: libgomp-tests.patch --] [-- Type: application/octet-stream, Size: 55017 bytes --] commit 357628f81f231d896f543ae2fdd93bd6ee057f3d Author: Maxim Blumenthal <maxim.blumenthal@intel.com> Date: Mon Jun 22 14:11:22 2015 +0300 Renamed Fortran, C and C++ tests for libgomp based on OpenMP Examples tests to make the names more understandable, e.g. e.55.2.f90 to async_target-2.f90. Also made minor modifications to them. Added 16 tests for simd construct and 10 for task dependencies. Those tests are based on OpenMP Examples 4.0.2. diff --git a/libgomp/testsuite/libgomp.c++/examples-4/e.53.2.C b/libgomp/testsuite/libgomp.c++/examples-4/declare_target-2.C similarity index 100% rename from libgomp/testsuite/libgomp.c++/examples-4/e.53.2.C rename to libgomp/testsuite/libgomp.c++/examples-4/declare_target-2.C diff --git a/libgomp/testsuite/libgomp.c++/examples-4/e.51.5.C b/libgomp/testsuite/libgomp.c++/examples-4/target_data-5.C similarity index 100% rename from libgomp/testsuite/libgomp.c++/examples-4/e.51.5.C rename to libgomp/testsuite/libgomp.c++/examples-4/target_data-5.C diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.56.3.c b/libgomp/testsuite/libgomp.c/examples-4/array_sections-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.56.3.c rename to libgomp/testsuite/libgomp.c/examples-4/array_sections-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.56.4.c b/libgomp/testsuite/libgomp.c/examples-4/array_sections-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.56.4.c rename to libgomp/testsuite/libgomp.c/examples-4/array_sections-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.55.1.c b/libgomp/testsuite/libgomp.c/examples-4/async_target-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.55.1.c rename to libgomp/testsuite/libgomp.c/examples-4/async_target-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.55.2.c b/libgomp/testsuite/libgomp.c/examples-4/async_target-2.c similarity index 89% rename from libgomp/testsuite/libgomp.c/examples-4/e.55.2.c rename to libgomp/testsuite/libgomp.c/examples-4/async_target-2.c index f03cae3..ce63328 100644 --- a/libgomp/testsuite/libgomp.c/examples-4/e.55.2.c +++ b/libgomp/testsuite/libgomp.c/examples-4/async_target-2.c @@ -19,8 +19,9 @@ void init (float *a, float *b, int n) } #pragma omp end declare target -void vec_mult_ref (float *p, float *v1, float *v2, int n) +void vec_mult_ref(float *p, int n) { + float *v1, *v2; int i; v1 = (float *) malloc (n * sizeof (float)); @@ -35,8 +36,9 @@ void vec_mult_ref (float *p, float *v1, float *v2, int n) free (v2); } -void vec_mult (float *p, float *v1, float *v2, int n) +void vec_mult(float *p, int n) { + float *v1, *v2; int i; #pragma omp task shared(v1, v2) depend(out: v1, v2) @@ -64,6 +66,8 @@ void vec_mult (float *p, float *v1, float *v2, int n) free (v1); free (v2); } + + #pragma omp taskwait } void check (float *a, float *b, int n) @@ -81,10 +85,9 @@ int main () { float *p1 = (float *) malloc (N * sizeof (float)); float *p2 = (float *) malloc (N * sizeof (float)); - float *v1, *v2; - vec_mult_ref (p1, v1, v2, N); - vec_mult (p2, v1, v2, N); + vec_mult_ref (p1, N); + vec_mult (p2, N); check (p1, p2, N); diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.1.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.1.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.3.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.3.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.4.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.4.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.53.5.c b/libgomp/testsuite/libgomp.c/examples-4/declare_target-5.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.53.5.c rename to libgomp/testsuite/libgomp.c/examples-4/declare_target-5.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.57.1.c b/libgomp/testsuite/libgomp.c/examples-4/device-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.57.1.c rename to libgomp/testsuite/libgomp.c/examples-4/device-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.57.2.c b/libgomp/testsuite/libgomp.c/examples-4/device-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.57.2.c rename to libgomp/testsuite/libgomp.c/examples-4/device-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.57.3.c b/libgomp/testsuite/libgomp.c/examples-4/device-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.57.3.c rename to libgomp/testsuite/libgomp.c/examples-4/device-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-1.c b/libgomp/testsuite/libgomp.c/examples-4/simd-1.c new file mode 100644 index 0000000..5baaf30 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-1.c @@ -0,0 +1,65 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define OFF 32 +#define EPS 0.0000000000000001 + +#include <stdlib.h> + +void init(double *a, double *a_ref, double *b, double *c, int n, int ioff) +{ + int i; + for ( i = 0; i < n; i++ ) + { + a[i] = i*i; + a_ref[i] = a[i]; + b[i] = i+i; + } + + int s = -1; + for ( i = 0; i < n+ioff; i++ ) + { + c[i] = s*3; + s = -s; + } +} + +void star( double *a, double *b, double *c, int n, int *ioff ) +{ + int i; + #pragma omp simd + for ( i = 0; i < n; i++ ) + a[i] *= b[i] * c[i+ *ioff]; +} + +void star_ref( double *a, double *b, double *c, int n, int *ioff ) +{ + int i; + for ( i = 0; i < n; i++ ) + a[i] *= b[i] * c[i+ *ioff]; +} + +void check (double *a, double *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + +int main () +{ + double a[N], a_ref[N], b[N], c[N+OFF]; + int ioff = OFF; + + init(a, a_ref, b, c, N, ioff); + + star(a, b, c, N, &ioff); + star_ref(a_ref, b, c, N, &ioff); + + check(a, a_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-2.c b/libgomp/testsuite/libgomp.c/examples-4/simd-2.c new file mode 100644 index 0000000..c0ad30a --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-2.c @@ -0,0 +1,90 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define EPS 0.0000000000000001 + +#include <stdlib.h> + +void init(double *a, double *a_ref, double *b, int n) +{ + int i; + for ( i=0; i<N; i++ ) + { + a[i] = i; + a_ref[i] = i; + b[i] = N-i; + } +} + +#pragma omp declare simd uniform(fact) +double add1(double a, double b, double fact) +{ + double c; + c = a + b + fact; + return c; +} + +#pragma omp declare simd uniform(a,b,fact) linear(i:1) +double add2(double *a, double *b, int i, double fact) +{ + double c; + c = a[i] + b[i] + fact; + return c; +} + +#pragma omp declare simd uniform(fact) linear(a,b:1) +double add3(double *a, double *b, double fact) +{ + double c; + c = *a + *b + fact; + return c; +} + +void work( double *a, double *b, int n ) +{ + int i; + double tmp; + #pragma omp simd private(tmp) + for ( i = 0; i < n; i++ ) { + tmp = add1( a[i], b[i], 1.0); + a[i] = add2( a, b, i, 1.0) + tmp; + a[i] = add3(&a[i], &b[i], 1.0); + } +} + +void work_ref( double *a, double *b, int n ) +{ + int i; + double tmp; + for ( i = 0; i < n; i++ ) { + tmp = add1( a[i], b[i], 1.0); + a[i] = add2( a, b, i, 1.0) + tmp; + a[i] = add3(&a[i], &b[i], 1.0); + } +} + +void check (double *a, double *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + + +int main () +{ + int i; + double a[N], a_ref[N], b[N]; + + init(a, a_ref, b, N); + + work(a, b, N ); + work_ref(a_ref, b, N ); + + check(a, a_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-3.c b/libgomp/testsuite/libgomp.c/examples-4/simd-3.c new file mode 100644 index 0000000..9f33713 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-3.c @@ -0,0 +1,61 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define EPS 0.0000000000000001 + +#include <stdlib.h> + +void init(double *a, double *a_ref, double *b, int n) +{ + int i, s = -1; + for ( i = 0; i < n; i++ ) + { + a[i] = i*i*s; + a_ref[i] = a[i]; + b[i] = i+i; + s = -s; + } +} + +double work( double *a, double *b, int n ) +{ + int i; + double tmp, sum; + sum = 0.0; + #pragma omp simd private(tmp) reduction(+:sum) + for (i = 0; i < n; i++) { + tmp = a[i] + b[i]; + sum += tmp; + } + return sum; +} + +double work_ref( double *a, double *b, int n ) +{ + int i; + double tmp, sum; + sum = 0.0; + for (i = 0; i < n; i++) { + tmp = a[i] + b[i]; + sum += tmp; + } + return sum; +} + +int main () +{ + double a[N], a_ref[N], b[N]; + int res, ref; + + init(a, a_ref, b, N); + + res = work(a, b, N); + ref = work_ref(a_ref, b, N); + + if (res != ref) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-4.c b/libgomp/testsuite/libgomp.c/examples-4/simd-4.c new file mode 100644 index 0000000..1aa0425 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-4.c @@ -0,0 +1,58 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 128 +#define M 16 +#define EPS 0.0000000000000001 +#define SAFELEN 16 + +#include <stdlib.h> + +void init(double *a, double *b, int n) +{ + int i, s = -1; + for ( i = 0; i < n; i++ ) + { + a[i] = i*i*s; + b[i] = a[i]; + s = -s; + } +} + +void work( double *b, int n, int m ) +{ + int i; + #pragma omp simd safelen(SAFELEN) + for (i = m; i < n; i++) + b[i] = b[i-m] - 1.0f; +} + +void work_ref( double *b, int n, int m ) +{ + int i; + for (i = m; i < n; i++) + b[i] = b[i-m] - 1.0f; +} + +void check (double *a, double *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + +int main () +{ + double b[N], b_ref[N]; + + init(b, b_ref, N); + + work(b, N, M); + work(b_ref, N, M); + + check(b, b_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-5.c b/libgomp/testsuite/libgomp.c/examples-4/simd-5.c new file mode 100644 index 0000000..ce037ac --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-5.c @@ -0,0 +1,76 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 128 +#define M 16 +#define EPS 0.0000000000000001 +#define SAFELEN 16 + +#include <stdlib.h> + +void init(double a[N][N], double b[N][N], int n) +{ + int i, j, s = -1; + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + a[i][j] = i * j * s; + b[i][j] = i + j + s; + s = -s; + } + } +} + +void work( double a[N][N], double b[N][N], double c[N][N], int n ) +{ + int i, j; + double tmp; + #pragma omp for simd collapse(2) private(tmp) + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + tmp = a[i][j] + b[i][j]; + c[i][j] = tmp; + } + } +} + +void work_ref( double a[N][N], double b[N][N], double c[N][N], int n ) +{ + int i, j; + double tmp; + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + tmp = a[i][j] + b[i][j]; + c[i][j] = tmp; + } + } +} + +void check (double a[N][N], double b[N][N]) +{ + int i, j; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + if (a[i][j] - b[i][j] > EPS || b[i][j] - a[i][j] > EPS) + abort (); +} + +int main () +{ + double a[N][N], b[N][N], c[N][N], c_ref[N][N]; + + init(a, b, N); + + work(a, b, c, N); + work_ref(a, b, c_ref, N); + + check(c, c_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-6.c b/libgomp/testsuite/libgomp.c/examples-4/simd-6.c new file mode 100644 index 0000000..d313c70 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-6.c @@ -0,0 +1,105 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define N 100 +#define EPS 0.000001 + +#include <stdlib.h> +#include <stdio.h> + +void init(int *b, float *y, int n) +{ + int i, s = -1; + for ( i=0; i<N; i++ ) + { + b[i] = i*i*s; + y[i] = b[i] * 0.1f; + s = -s; + } +} + +#pragma omp declare simd linear(p:1) notinbranch +int foo(int *p){ + *p = *p + 10; + return *p; +} + +int myaddint(int *a, int *b, int n) +{ +#pragma omp simd + for (int i=0; i<n; i++){ + a[i] = foo(&b[i]); /* foo is not called under a condition */ + } + return a[n-1]; +} + +int myaddint_ref(int *a, int *b, int n) +{ + for (int i=0; i<n; i++){ + a[i] = foo(&b[i]); + } + return a[n-1]; +} + +#pragma omp declare simd linear(p:1) inbranch +float goo(float *p){ + *p = *p + 18.5f; + return *p; +} + +int myaddfloat(float *x, float *y, int n) +{ +#pragma omp simd + for (int i=0; i<n; i++){ + x[i] = (x[i] > y[i]) ? goo(&y[i]) : y[i]; + /* goo is called under the condition (or within a branch) */ + } + return x[n-1]; +} + +int myaddfloat_ref(float *x, float *y, int n) +{ + for (int i=0; i<n; i++){ + x[i] = (x[i] > y[i]) ? goo(&y[i]) : y[i]; + } + return x[n-1]; +} + +void check_addint (int *a, int *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] != b[i]) + abort (); +} + +void check_addfloat (float *a, float *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] - b[i] > EPS || b[i] - a[i] > EPS) + abort (); +} + +int main () +{ + int i; + int a[N], a_ref[N], b[N]; + float x[N], x_ref[N], y[N]; + + init(a, x, N); + init(b, y, N); + myaddint(a, b, N); + myaddfloat(x, y, N); + + init(a_ref, x_ref, N); + init(b, y, N); + myaddint_ref(a_ref, b, N); + myaddfloat_ref(x_ref, y, N); + + check_addint(a, a_ref); + check_addfloat(x, x_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-7.c b/libgomp/testsuite/libgomp.c/examples-4/simd-7.c new file mode 100644 index 0000000..9c3040a --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-7.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include <stdio.h> +#include <stdlib.h> + +#define N 45 +int a[N], a_ref[N], b[N]; + +#pragma omp declare simd inbranch +int fib( int n ) +{ + if (n <= 2) + return n; + else { + return fib(n-1) + fib(n-2); + } +} + +int main(void) +{ + int i; + +#pragma omp simd + for (i=0; i < N; i++) + b[i] = i; + +#pragma omp simd + for (i=0; i < N; i++) + a[i] = fib(b[i]); + + for (i=0; i < N; i++) + a_ref[i] = fib(b[i]); + + for (i=0; i < N; i++) + if (a[i] != a_ref[i]) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-8.c b/libgomp/testsuite/libgomp.c/examples-4/simd-8.c new file mode 100644 index 0000000..397e2a3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-8.c @@ -0,0 +1,49 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include <stdlib.h> +#include <math.h> + +int P[1000]; +float A[1000]; + +float do_work(float *arr) +{ + float pri; + +#pragma omp simd lastprivate(pri) + for (int i = 0; i < 999; ++i) + { + int j = P[i]; + + pri = 0.5f; + if (j % 2 == 0) + { + pri = A[j+1] + arr[i]; + } + A[j] = pri * 1.5f; + pri = pri + A[j]; + } + + return pri; +} + +int main(void) +{ + float pri, arr[1000]; + + for (int i = 0; i < 1000; ++i) + { + P[i] = i; + A[i] = i * 1.5f; + arr[i] = i * 1.8f; + } + + pri = do_work(&arr[0]); + + if (pri != 8237.25) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.1.c b/libgomp/testsuite/libgomp.c/examples-4/target-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.1.c rename to libgomp/testsuite/libgomp.c/examples-4/target-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.2.c b/libgomp/testsuite/libgomp.c/examples-4/target-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.2.c rename to libgomp/testsuite/libgomp.c/examples-4/target-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.3.c b/libgomp/testsuite/libgomp.c/examples-4/target-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.3.c rename to libgomp/testsuite/libgomp.c/examples-4/target-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.4.c b/libgomp/testsuite/libgomp.c/examples-4/target-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.4.c rename to libgomp/testsuite/libgomp.c/examples-4/target-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.50.5.c b/libgomp/testsuite/libgomp.c/examples-4/target-5.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.50.5.c rename to libgomp/testsuite/libgomp.c/examples-4/target-5.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.1.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.1.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.2.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.2.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.3.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.3.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.4.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.4.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.6.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-6.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.6.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-6.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.51.7.c b/libgomp/testsuite/libgomp.c/examples-4/target_data-7.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.51.7.c rename to libgomp/testsuite/libgomp.c/examples-4/target_data-7.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.52.1.c b/libgomp/testsuite/libgomp.c/examples-4/target_update-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.52.1.c rename to libgomp/testsuite/libgomp.c/examples-4/target_update-1.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.52.2.c b/libgomp/testsuite/libgomp.c/examples-4/target_update-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.52.2.c rename to libgomp/testsuite/libgomp.c/examples-4/target_update-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-1.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-1.c new file mode 100644 index 0000000..8d397a5 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-1.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +#include <stdlib.h> +int main() +{ + int x = 1; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(out: x) + x = 2; + #pragma omp task shared(x) depend(in: x) + if (x != 2) + abort (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-2.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-2.c new file mode 100644 index 0000000..f583f09 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-2.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +#include <stdlib.h> +int main() +{ + int x = 1; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(in: x) + if (x != 1) + abort (); + #pragma omp task shared(x) depend(out: x) + x = 2; + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-3.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-3.c new file mode 100644 index 0000000..189d5e0 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-3.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +#include <stdlib.h> + +int main() +{ + int x = 0; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(out: x) + x = 1; + #pragma omp task shared(x) depend(out: x) + x = 2; + #pragma omp taskwait + if (x != 1 && x != 2) + abort (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-4.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-4.c new file mode 100644 index 0000000..77aa57a4 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-4.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +#include <stdlib.h> +int main() +{ + int x = 1; + #pragma omp parallel + #pragma omp single + { + #pragma omp task shared(x) depend(out: x) + x = 2; + #pragma omp task shared(x) depend(in: x) + if (x != 2) + abort (); + #pragma omp task shared(x) depend(in: x) + if (x != 2) + abort (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/task_dep-5.c b/libgomp/testsuite/libgomp.c/examples-4/task_dep-5.c new file mode 100644 index 0000000..cc2cda5 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/examples-4/task_dep-5.c @@ -0,0 +1,81 @@ +/* { dg-do run } */ + +#define N 128 +#define BS 16 +#define EPS 0.000001 + +#include <stdlib.h> + +void matmul_depend (float A[N][N], float B[N][N], float C[N][N]) +{ + int i, j, k, ii, jj, kk; + for (i = 0; i < N; i+=BS) + for (j = 0; j < N; j+=BS) + for (k = 0; k < N; k+=BS) +// Note 1: i, j, k, A, B, C are firstprivate by default +// Note 2: A, B and C are just pointers +#pragma omp task private(ii, jj, kk) \ + depend ( in: A[i:BS][k:BS], B[k:BS][j:BS] ) \ + depend ( inout: C[i:BS][j:BS] ) + for (ii = i; ii < i+BS; ii++ ) + for (jj = j; jj < j+BS; jj++ ) + for (kk = k; kk < k+BS; kk++ ) + C[ii][jj] = C[ii][jj] + A[ii][kk] * B[kk][jj]; +} + +void matmul_ref (float A[N][N], float B[N][N], float C[N][N]) +{ + int i, j, k; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + for (k = 0; k < N; k++) + C[i][j] += A[i][k] * B[k][j]; +} + +void init (float A[N][N], float B[N][N]) +{ + int i, j, s = -1; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + A[i][j] = i * j * s; + B[i][j] = i + j; + s = -s; + } +} + +void init_zero (float A[N][N], float B[N][N]) +{ + int i, j, s = -1; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + A[i][j] = 0; + B[i][j] = 0; + } +} + +void check (float A[N][N], float B[N][N]) +{ + int i, j; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + if (A[i][j] - B[i][j] > EPS || B[i][j] - A[i][j] > EPS) + abort (); +} + +int main () +{ + float A[N][N], B[N][N], C[N][N], C_ref[N][N]; + + init (A, B); + init_zero (C, C_ref); + + matmul_depend (A, B, C); + matmul_ref (A, B, C_ref); + + check (C, C_ref); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.2.c b/libgomp/testsuite/libgomp.c/examples-4/teams-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.2.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-2.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.3.c b/libgomp/testsuite/libgomp.c/examples-4/teams-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.3.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-3.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.4.c b/libgomp/testsuite/libgomp.c/examples-4/teams-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.4.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-4.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.5.c b/libgomp/testsuite/libgomp.c/examples-4/teams-5.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.5.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-5.c diff --git a/libgomp/testsuite/libgomp.c/examples-4/e.54.6.c b/libgomp/testsuite/libgomp.c/examples-4/teams-6.c similarity index 100% rename from libgomp/testsuite/libgomp.c/examples-4/e.54.6.c rename to libgomp/testsuite/libgomp.c/examples-4/teams-6.c diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.56.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/array_sections-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.56.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/array_sections-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.56.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/array_sections-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.56.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/array_sections-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.55.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/async_target-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.55.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/async_target-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.55.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/async_target-2.f90 similarity index 98% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.55.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/async_target-2.f90 index dfcb5f4..b12b0ea 100644 --- a/libgomp/testsuite/libgomp.fortran/examples-4/e.55.2.f90 +++ b/libgomp/testsuite/libgomp.fortran/examples-4/async_target-2.f90 @@ -46,6 +46,8 @@ subroutine vec_mult (p, N) !$omp end target !$omp end task !$omp end target data + + !$omp taskwait call check (p, N) end subroutine diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.53.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/declare_target-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.53.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/declare_target-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.57.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/device-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.57.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/device-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.57.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/device-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.57.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/device-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.57.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/device-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.57.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/device-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-1.f90 new file mode 100644 index 0000000..b1af859 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-1.f90 @@ -0,0 +1,67 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD1_mod +contains + subroutine init (a, a_ref, b, c, n, ioff_ptr) + double precision :: a(*), a_ref(*), b(*), c(*) + integer :: n, i, s + integer, pointer :: ioff_ptr + + s = -1 + do i = 1, n + a(i) = i * i * s + a_ref(i) = a(i) + b(i) = i + i + end do + + do i = 1, n+ioff_ptr + c(i) = i * 3 + end do + + end subroutine + + subroutine check (a, b, n) + integer :: i, n + double precision, parameter :: EPS = 0.0000000000001 + double precision :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine + + subroutine star(a, a_ref, b, c, n, ioff_ptr) + double precision :: a(*), a_ref(*), b(*), c(*) + integer :: n, i + integer, pointer :: ioff_ptr + + call init (a, a_ref, b, c, n, ioff_ptr) + + !$omp simd + do i = 1,n + a(i) = a(i) * b(i) * c(i+ioff_ptr) + end do + + do i = 1,n + a_ref(i) = a_ref(i) * b(i) * c(i+ioff_ptr) + end do + + call check (a, a_ref, n) + + end subroutine +end module + +program SIMD1 + use SIMD1_mod, only : star + double precision :: a(128), a_ref(128), b(128), c(144) + integer, pointer:: ioff_ptr + integer, target:: offset + + offset = 16 + ioff_ptr => offset + + call star (a, a_ref, b, c, 128, ioff_ptr) + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90 new file mode 100644 index 0000000..dd6433d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90 @@ -0,0 +1,72 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD2_mod +contains + function add1(a,b,fact) result(c) + !$omp declare simd(add1) uniform(fact) + double precision :: a,b,fact, c + c = a + b + fact + end function + + function add2(a,b,i, fact) result(c) + !$omp declare simd(add2) uniform(a,b,fact) linear(i:1) + integer, value :: i + double precision, dimension(:) :: a, b + double precision :: fact, c + c = a(i) + b(i) + fact + end function + + subroutine work(a, b, n ) + implicit none + double precision :: a(n),b(n), tmp + integer :: n, i + + !$omp simd private(tmp) + do i = 1,n + tmp = add1(a(i), b(i), 1.0d0) + a(i) = add2(a, b, i, 1.0d0) + tmp + a(i) = a(i) + b(i) + 1.0d0 + end do + end subroutine + + subroutine work_ref(a, b, n ) + implicit none + double precision :: a(n),b(n), tmp + integer :: n, i + + do i = 1,n + tmp = add1(a(i), b(i), 1.0d0) + a(i) = add2(a, b, i, 1.0d0) + tmp + a(i) = a(i) + b(i) + 1.0d0 + end do + end subroutine + + subroutine check (a, b, n) + integer :: i, n + double precision, parameter :: EPS = 0.0000000000001 + double precision :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine +end module + +program main + use SIMD2_mod + integer, parameter :: N=32 + integer :: i + double precision :: a(N), b(N), a_ref(N) + do i = 1,N + a(i) = i-1 + a_ref(i) = a(i) + b(i) = N-(i-1) + end do + + call work(a, b, N ) + call work_ref(a_ref, b, N ) + + call check(a, a_ref, N ) +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 new file mode 100644 index 0000000..f2e0047 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 @@ -0,0 +1,59 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD3_mod +contains + subroutine work( a, b, n, sum ) + implicit none + integer :: i, n + double precision :: a(n), b(n), sum, tmp + + sum = 0.0d0 + call init(a, b, n) + !$omp simd private(tmp) reduction(+:sum) + do i = 1,n + tmp = a(i) + b(i) + sum = sum + tmp + end do + + end subroutine work + + subroutine work_ref( a, b, n, sum ) + implicit none + integer :: i, n + double precision :: a(n), b(n), sum, tmp + + sum = 0.0d0 + call init(a, b, n) + do i = 1,n + tmp = a(i) + b(i) + sum = sum + tmp + end do + + end subroutine work_ref + + subroutine init (a, b, n) + double precision :: a(*), b(*) + integer :: n, i, s + + s = -1 + do i = 1, n + a(i) = i * i * s + b(i) = i + i + s = -s + end do + + end subroutine +end module + +program SIMD3 + use SIMD3_mod + double precision :: a(128), b(128), sum, sum_ref + + call work(a, b, 128, sum) + call work_ref(a, b, 128, sum_ref) + + if (sum .ne. sum_ref) call abort + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-4.f90 new file mode 100644 index 0000000..1100edc --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-4.f90 @@ -0,0 +1,64 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD4_mod +contains + subroutine work( b, n, m ) + implicit none + real :: b(n) + integer :: i,n,m + + call init(b, n) + + !$omp simd safelen(16) + do i = m+1, n + b(i) = b(i-m) - 1.0 + end do + end subroutine work + + subroutine work_ref( b, n, m ) + implicit none + real :: b(n) + integer :: i,n,m + + call init(b, n) + + do i = m+1, n + b(i) = b(i-m) - 1.0 + end do + end subroutine work_ref + + subroutine init (b, n) + real :: b(*) + integer :: n, i, s + + s = -1 + do i = 1, n + b(i) = i * i * s + s = -s + end do + + end subroutine + + subroutine check (a, b, n) + integer :: i, n + real, parameter :: EPS = 0.000001 + real :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine + +end module + +program SIMD4 + use SIMD4_mod + real :: b(128), b_ref(128) + + call work(b, 128, 32) + call work_ref(b_ref, 128, 32) + + call check(b, b_ref, 128) +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-5.f90 new file mode 100644 index 0000000..2989521 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-5.f90 @@ -0,0 +1,76 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD5_mod +contains + subroutine work( a, b, c, n ) + implicit none + integer :: i,j,n + double precision :: a(n,n), b(n,n), c(n,n), tmp + + !$omp simd collapse(2) private(tmp) + do j = 1,n + do i = 1,n + tmp = a(i,j) + b(i,j) + c(i,j) = tmp + end do + end do + + end subroutine work + + subroutine work_ref( a, b, c, n ) + implicit none + integer :: i,j,n + double precision :: a(n,n), b(n,n), c(n,n), tmp + + do j = 1,n + do i = 1,n + tmp = a(i,j) + b(i,j) + c(i,j) = tmp + end do + end do + + end subroutine work_ref + + subroutine init (a, b, n) + integer :: i,j,n,s + double precision :: a(n,n), b(n,n) + + s = -1 + + do j = 1,n + do i = 1,n + a(i,j) = i*j*s + b(i,j) = i+j + s = -s + end do + end do + + end subroutine + + subroutine check (a, b, n) + integer :: i, j, n + double precision, parameter :: EPS = 0.0000000000000001 + double precision :: diff, a(n,n), b(n,n) + do j = 1, n + do i = 1, n + diff = a(i,j) - b(i,j) + if (diff > EPS .or. -diff > EPS) call abort + end do + end do + end subroutine + +end module + +program SIMD5 + use SIMD5_mod + double precision, dimension(32, 32) :: a, b, c, c_ref + + call init(a, b, 32) + + call work(a, b, c, 32) + call work_ref(a, b, c_ref, 32) + + call check(c, c_ref, 32) +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-6.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-6.f90 new file mode 100644 index 0000000..9a227cd --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-6.f90 @@ -0,0 +1,151 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module SIMD6_mod +contains + function foo(p) result(r) + !$omp declare simd(foo) notinbranch + integer :: p, r + p = p + 10 + r = p + end function foo + + function myaddint(a, b, n) result(r) + implicit none + integer :: a(*), b(*), n, r + integer :: i + + !$omp simd + do i=1, n + a(i) = foo(b(i)) ! foo is not called under a condition + end do + r = a(n) + + end function myaddint + + function myaddint_ref(a, b, n) result(r) + implicit none + integer :: a(*), b(*), n, r + integer :: i + + do i=1, n + a(i) = foo(b(i)) + end do + r = a(n) + + end function myaddint_ref + + function goo(p) result(r) + !$omp declare simd(goo) inbranch + real :: p, r + p = p + 18.5 + r = p + end function goo + + function myaddfloat(x, y, n) result(r) + implicit none + real :: x(*), y(*), r + integer :: n + integer :: i + + !$omp simd + do i=1, n + if (x(i) > y(i)) then + x(i) = goo(y(i)) + ! goo is called under the condition (or within a branch) + else + x(i) = y(i) + endif + end do + + r = x(n) + end function myaddfloat + + function myaddfloat_ref(x, y, n) result(r) + implicit none + real :: x(*), y(*), r + integer :: n + integer :: i + + do i=1, n + if (x(i) > y(i)) then + x(i) = goo(y(i)) + else + x(i) = y(i) + endif + end do + + r = x(n) + end function myaddfloat_ref + + subroutine init (b, y, n) + integer :: b(128) + real :: y(128) + + s = -1 + do i = 1, n + b(i) = i*i*s + y(i) = i*i*s + s = -s + end do + + end subroutine + + subroutine init2 (b, y, n) + integer :: b(128) + real :: y(128) + + do i = 1, n + b(i) = i + y(i) = i + end do + + end subroutine + + subroutine checkfloat (a, b, n) + integer :: i, n + real, parameter :: EPS = 0.000001 + real :: diff, a(*), b(*) + do i = 1, n + diff = a(i) - b(i) + if (diff > EPS .or. -diff > EPS) call abort + end do + end subroutine + + subroutine checkint (a, b, n) + integer :: i, n, a(*), b(*) + do i = 1, n + if (a(i) .ne. b(i)) call abort + end do + end subroutine + + subroutine test () + integer :: a(128), a_ref(128), b(128), ri, ri_ref + real :: x(128), x_ref(128), y(128), rf, rf_ref + + call init2(a, x, 128) + call init2(a_ref, x_ref, 128) + + call init(b, y, 128) + + ri = myaddint (a, b, 128) + rf = myaddfloat (x, y, 128) + + call init(b, y, 128) + + ri_ref = myaddint_ref (a_ref, b, 128) + rf_ref = myaddfloat_ref (x_ref, y, 128) + + call checkint (a, a_ref, 128) + call checkfloat (x, x_ref, 128) + end subroutine + +end module + +program SIMD6 + use SIMD6_mod, only: test + + call test () + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 new file mode 100644 index 0000000..e64107d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 @@ -0,0 +1,49 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +program fibonacci + implicit none + integer,parameter :: N=45 + integer :: a(0:N-1), b(0:N-1) + integer :: a_ref(0:N-1), b_ref(0:N-1) + integer :: i + integer, external :: fib + + !$omp simd + do i = 0,N-1 + b(i) = i + end do + + do i = 0,N-1 + b_ref(i) = i + end do + + !$omp simd + do i=0,N-1 + a(i) = fib(b(i)) + end do + + do i=0,N-1 + a_ref(i) = fib(b_ref(i)) + end do + + do i = 0, N-1 + if (a(i) .ne. a_ref(i)) call abort () + end do + + if (a(44) .ne. 1134903170) call abort() + +end program + +recursive function fib(n) result(r) +!$omp declare simd(fib) inbranch + integer :: n, r + + if (n <= 2) then + r = n + else + r = fib(n-1) + fib(n-2) + endif + +end function fib diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 new file mode 100644 index 0000000..743bdcc --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 @@ -0,0 +1,48 @@ +! { dg-do run } +! { dg-additional-options "-msse2" { target sse2_runtime } } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module work + +integer :: P(1000) +real :: A(1000) + +contains +function do_work(arr) result(pri) + implicit none + real, dimension(*) :: arr + + real :: pri + integer :: i, j + + !$omp simd private(j) lastprivate(pri) + do i = 1, 999 + j = P(i) + + pri = 0.5 + if (mod(j-1, 2) == 0) then + pri = A(j+1) + arr(i) + endif + A(j) = pri * 1.5 + pri = pri + A(j) + end do + +end function do_work + +end module work + +program simd_8f + use work + implicit none + real :: pri, arr(1000) + integer :: i + + do i = 1, 1000 + P(i) = i + A(i) = (i-1) * 1.5 + arr(i) = (i-1) * 1.8 + end do + pri = do_work(arr) + if (pri .ne. 8237.25) call abort () + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.50.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.50.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.6.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-6.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.6.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-6.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.51.7.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_data-7.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.51.7.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_data-7.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.52.1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_update-1.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.52.1.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_update-1.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.52.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/target_update-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.52.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/target_update-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-1.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-1.f90 new file mode 100644 index 0000000..78201ea --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-1.f90 @@ -0,0 +1,16 @@ +! { dg-do run } + +program example + integer :: x + x = 1 + !$omp parallel + !$omp single + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp task shared(x) depend(in: x) + if (x .ne. 2) call abort () + !$omp end task + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-2.f90 new file mode 100644 index 0000000..5afd76d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-2.f90 @@ -0,0 +1,16 @@ +! { dg-do run } + +program example + integer :: x + x = 1 + !$omp parallel + !$omp single + !$omp task shared(x) depend(in: x) + if (x .ne. 1) call abort () + !$omp end task + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-3.f90 new file mode 100644 index 0000000..c8d5820 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-3.f90 @@ -0,0 +1,18 @@ +! { dg-do run } + +program example + integer :: x + x = 0 + !$omp parallel + !$omp single + !$omp task shared(x) depend(out: x) + x = 1 + !$omp end task + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp taskwait + if ((x .ne. 1) .and. (x .ne. 2)) call abort() + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-4.f90 new file mode 100644 index 0000000..7fe24c3 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-4.f90 @@ -0,0 +1,19 @@ +! { dg-do run } + +program example + integer :: x + x = 1 + !$omp parallel + !$omp single + !$omp task shared(x) depend(out: x) + x = 2 + !$omp end task + !$omp task shared(x) depend(in: x) + if (x .ne. 2) call abort () + !$omp end task + !$omp task shared(x) depend(in: x) + if (x .ne. 2) call abort () + !$omp end task + !$omp end single + !$omp end parallel +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 new file mode 100644 index 0000000..12dd9e1 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 @@ -0,0 +1,100 @@ +! { dg-do run } + +module task_dep5_mod +contains + subroutine matmul_depend (N, BS, A, B, C) + implicit none + integer :: N, BS, BM + real, dimension(N, N) :: A, B, C + integer :: i, j, k, ii, jj, kk + BM = BS - 1 + do i = 1, N, BS + do j = 1, N, BS + do k = 1, N, BS + !$omp task shared(A,B,C) private(ii,jj,kk) & ! I,J,K are firstprivate by default + !$omp depend ( in: A(i:i+BM, k:k+BM), B(k:k+BM, j:j+BM) ) & + !$omp depend ( inout: C(i:i+BM, j:j+BM) ) + do ii = i, i+BM + do jj = j, j+BM + do kk = k, k+BM + C(jj,ii) = C(jj,ii) + A(kk,ii) * B(jj,kk) + end do + end do + end do + !$omp end task + end do + end do + end do + end subroutine + + subroutine matmul_ref (N, A, B, C) + implicit none + integer :: N + real, dimension(N, N) :: A, B, C + integer :: i, j, k + do i = 1, N + do j = 1, N + do k = 1, N + C(j,i) = C(j,i) + A(k,i) * B(j,k) + end do + end do + end do + end subroutine + + subroutine check (N, A, B) + integer :: N + integer :: i, j + integer, parameter :: EPS = 0.000001 + real, dimension(N,N) :: A, B + real :: diff + do i = 1, N + do j = 1, N + diff = A(i, j) - B(i, j) + if (diff > EPS .or. -diff > EPS) then + call abort () + end if + end do + end do + end subroutine + + subroutine init (N, A, B) + integer :: N + integer :: i, j, s + real, dimension(N,N) :: A, B + s = -1 + do i = 1, N + do j = 1, N + A(i, j) = i*j*s + B(i, j) = i+j + s = -s + end do + end do + end subroutine + + subroutine zero_init (N, A, B) + integer :: N + integer :: i, j + real, dimension(N,N) :: A, B + do i = 1, N + do j = 1, N + A(i, j) = 0 + B(i, j) = 0 + end do + end do + end subroutine + +end module + +program main + use task_dep5_mod + real, dimension(32, 32) :: A, B, C, C_ref + + call init (32, A, B) + call zero_init (32, C, C_ref) + + call matmul_depend(32, 4, A, B, C) + call matmul_ref(32, A, B, C_ref) + + call check (32, C, C_ref) + +end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.2.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-2.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.2.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-2.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-3.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.3.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-3.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.4.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-4.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.4.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-4.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-5.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.5.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-5.f90 diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/e.54.6.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/teams-6.f90 similarity index 100% rename from libgomp/testsuite/libgomp.fortran/examples-4/e.54.6.f90 rename to libgomp/testsuite/libgomp.fortran/examples-4/teams-6.f90 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-09 14:23 ` Maxim Blumental @ 2015-07-09 20:14 ` Jakub Jelinek 2015-07-14 13:41 ` Jakub Jelinek 0 siblings, 1 reply; 19+ messages in thread From: Jakub Jelinek @ 2015-07-09 20:14 UTC (permalink / raw) To: Maxim Blumental; +Cc: gcc-patches, Kirill Yukhin On Thu, Jul 09, 2015 at 05:23:36PM +0300, Maxim Blumental wrote: > Now the patch is corrected (according to the previous letter) and > ready to be reviewed. I'm looking forward to your feedback. Ok, I guess while the filenames are still different, it is quite easily possible to find corresponding test in the Examples git repo. So, what remains is write proper ChangeLog entry, for all the renames and other changes, like: * testsuite/libgomp.c/examples-4/e.55.1.c: Renamed to... * testsuite/libgomp.c/examples-4/async_target-1.c: ... this. * testsuite/libgomp.c/examples-4/e.55.2.c: Renamed to... * testsuite/libgomp.c/examples-4/async_target-2.c: ... this. (vec_mult_ref): Remove v1 and v2 arguments, turn them into local variables. (vec_mult): Likewise. Add #pragma omp taskwait. (main): Adjust caller. ... * testsuite/libgomp.c/examples-4/simd-1.c: New file. * testsuite/libgomp.c/examples-4/simd-2.c: New file. ... etc. Also, in all dg-do run tests that use #pragma omp declare simd please use { dg-do run { target vect_simd_clones } } instead of { dg-do run }, so that it does not fail miserably on darwin or other OSes with less capable assemblers? Have you reported that !$omp for simd collapse(2) private(tmp) -> !$omp simd collapse(2) private(tmp) to omp-lang (or created ticket for it etc.)? Jakub ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-09 20:14 ` Jakub Jelinek @ 2015-07-14 13:41 ` Jakub Jelinek [not found] ` <CACy_Q+xw79aVfMxHg00LX7OWRqLUKS4LE4QtV=RSqMSS8vV=Vw@mail.gmail.com> 0 siblings, 1 reply; 19+ messages in thread From: Jakub Jelinek @ 2015-07-14 13:41 UTC (permalink / raw) To: Maxim Blumental, Ilya Verbin; +Cc: gcc-patches, Kirill Yukhin Hi! Note Richard reported that simd-8.c and simd-8.f90 tests fail on i686, can you please adjust them so that they don't perform direct comparison of floating point values, but allow some small epsilon (0.00390625 or something similar)? The last iteration multiplies 998 by 1.8, adds that to 1498.5, then on the sum performs sum + sum * 1.5, so with i?86 excess precision it might compute slightly different result. Jakub ^ permalink raw reply [flat|nested] 19+ messages in thread
[parent not found: <CACy_Q+xw79aVfMxHg00LX7OWRqLUKS4LE4QtV=RSqMSS8vV=Vw@mail.gmail.com>]
[parent not found: <20150714172935.GM1788@tucnak.redhat.com>]
[parent not found: <CACy_Q+x4JiHm_=BaSDmxCXqFJmChh=vvTv+22Xh-9x2br1HUAQ@mail.gmail.com>]
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. [not found] ` <CACy_Q+x4JiHm_=BaSDmxCXqFJmChh=vvTv+22Xh-9x2br1HUAQ@mail.gmail.com> @ 2015-07-14 17:46 ` Maxim Blumental 2015-07-14 18:28 ` Jakub Jelinek 0 siblings, 1 reply; 19+ messages in thread From: Maxim Blumental @ 2015-07-14 17:46 UTC (permalink / raw) To: Jakub Jelinek, gcc-patches, Ilya Verbin [-- Attachment #1: Type: text/plain, Size: 756 bytes --] The patch replaces all FP comparisons with inequalities and epsilons in those tests for libgomp. 2015-07-14 20:37 GMT+03:00 Maxim Blumental <bvmaks@gmail.com>: > Sorry, a little misunderstanding between me and Ilya ) I'll send the > new patch now. > > 2015-07-14 20:29 GMT+03:00 Jakub Jelinek <jakub@redhat.com>: >> On Tue, Jul 14, 2015 at 08:26:49PM +0300, Maxim Blumental wrote: >>> I replaced all FP comparisons in my tests with inequalities and >>> epsilons. Ilya commited the patch. >> >> Even in latest trunk I see >> if (pri != 8237.25) >> and >> if (pri .ne. 8237.25) call abort () >> >> Jakub > > > > -- > > > --------------------- > Sincerely yours, > Maxim Blumental -- --------------------- Sincerely yours, Maxim Blumental [-- Attachment #2: ChangeLog.txt --] [-- Type: text/plain, Size: 719 bytes --] 2015-07-14 Maxim Blumenthal <maxim.blumenthal@intel.com> * testsuite/libgomp.c/examples-4/simd-3.c: (main): Change type of res and ref from int to double. Replaced their comparison with an inequality of their difference and EPS. * testsuite/libgomp.c/examples-4/simd-8.c: (main): Replace the comparison of pri and a reference number with an inequality of their difference and EPS. * testsuite/libgomp.fortran/examples-4/simd-3.f90: (main): Replaced the comparison of sum and sum_ref with an inequality of their difference and EPS. * testsuite/libgomp.fortran/examples-4/simd-8.f90: (main): Replace the comparison of pri and a reference number with an inequality of their difference and EPS. [-- Attachment #3: fp_compar.patch --] [-- Type: application/octet-stream, Size: 2979 bytes --] commit cab6888d7e8d5d766a336670fe60f58dca657298 Author: Maxim Blumenthal <maxim.blumenthal@intel.com> Date: Tue Jul 14 19:40:13 2015 +0300 Replaced FP comparisons with inequalities in libgomp tests. diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-3.c b/libgomp/testsuite/libgomp.c/examples-4/simd-3.c index 9f33713..9082e49 100644 --- a/libgomp/testsuite/libgomp.c/examples-4/simd-3.c +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-3.c @@ -46,15 +46,16 @@ double work_ref( double *a, double *b, int n ) int main () { - double a[N], a_ref[N], b[N]; - int res, ref; + double a[N], a_ref[N], b[N], res, ref, diff; init(a, a_ref, b, N); res = work(a, b, N); ref = work_ref(a_ref, b, N); - if (res != ref) + diff = res - ref; + + if (diff > EPS || -diff > EPS) abort (); return 0; diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-8.c b/libgomp/testsuite/libgomp.c/examples-4/simd-8.c index 397e2a3..bbef778 100644 --- a/libgomp/testsuite/libgomp.c/examples-4/simd-8.c +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-8.c @@ -5,6 +5,8 @@ #include <stdlib.h> #include <math.h> +#define EPS 0.005 + int P[1000]; float A[1000]; @@ -31,7 +33,7 @@ float do_work(float *arr) int main(void) { - float pri, arr[1000]; + float pri, arr[1000], diff; for (int i = 0; i < 1000; ++i) { @@ -42,7 +44,9 @@ int main(void) pri = do_work(&arr[0]); - if (pri != 8237.25) + diff = pri - 8237.25; + + if (diff > EPS || -diff > EPS) abort (); return 0; diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 index f2e0047..2c02945 100644 --- a/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-3.f90 @@ -49,11 +49,14 @@ end module program SIMD3 use SIMD3_mod - double precision :: a(128), b(128), sum, sum_ref + double precision :: a(128), b(128), sum, sum_ref, diff + double precision, parameter :: EPS = 0.0000000000000001 call work(a, b, 128, sum) call work_ref(a, b, 128, sum_ref) - if (sum .ne. sum_ref) call abort + diff = sum - sum_ref + + if (diff > EPS .or. -diff > EPS) call abort end program diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 index a580937..ba7b0f9 100644 --- a/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 @@ -34,8 +34,9 @@ end module work program simd_8f use work implicit none - real :: pri, arr(1000) + real :: pri, arr(1000), diff integer :: i + integer, parameter :: EPS = 0.005 do i = 1, 1000 P(i) = i @@ -43,6 +44,9 @@ program simd_8f arr(i) = (i-1) * 1.8 end do pri = do_work(arr) - if (pri .ne. 8237.25) call abort () + + diff = pri - 8237.25 + + if (diff > EPS .or. -diff > EPS) call abort end program ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-14 17:46 ` Maxim Blumental @ 2015-07-14 18:28 ` Jakub Jelinek 2015-07-20 19:58 ` H.J. Lu 0 siblings, 1 reply; 19+ messages in thread From: Jakub Jelinek @ 2015-07-14 18:28 UTC (permalink / raw) To: Maxim Blumental; +Cc: gcc-patches, Ilya Verbin On Tue, Jul 14, 2015 at 08:40:50PM +0300, Maxim Blumental wrote: > The patch replaces all FP comparisons with inequalities and epsilons > in those tests for libgomp. Ok, thanks. Jakub ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-14 18:28 ` Jakub Jelinek @ 2015-07-20 19:58 ` H.J. Lu 2015-07-22 13:57 ` Maxim Blumental 0 siblings, 1 reply; 19+ messages in thread From: H.J. Lu @ 2015-07-20 19:58 UTC (permalink / raw) To: Jakub Jelinek; +Cc: Maxim Blumental, gcc-patches, Ilya Verbin On Tue, Jul 14, 2015 at 11:04 AM, Jakub Jelinek <jakub@redhat.com> wrote: > On Tue, Jul 14, 2015 at 08:40:50PM +0300, Maxim Blumental wrote: >> The patch replaces all FP comparisons with inequalities and epsilons >> in those tests for libgomp. > libgomp.fortran/examples-4/simd-7.f90 takes a very long time to run on Linux/ia32. I get random: FAIL: libgomp.fortran/examples-4/simd-7.f90 -O0 execution test https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66950 -- H.J. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-20 19:58 ` H.J. Lu @ 2015-07-22 13:57 ` Maxim Blumental 2015-07-22 14:16 ` Jakub Jelinek 0 siblings, 1 reply; 19+ messages in thread From: Maxim Blumental @ 2015-07-22 13:57 UTC (permalink / raw) To: H.J. Lu; +Cc: Jakub Jelinek, gcc-patches, Ilya Verbin [-- Attachment #1: Type: text/plain, Size: 947 bytes --] Changed simd-7 test for C and Fortran to lower the execution time to ~0.6 and ~1 second respectively while keeping the test representative. Measured the time like: $ time make check-target-libgomp RUNTESTFLAGS="c.exp"=simd-7.c on a Linux x86-64 machine. (Without the patch I also had a very long time: ~7.5 and ~60 seconds) 2015-07-20 22:40 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>: > On Tue, Jul 14, 2015 at 11:04 AM, Jakub Jelinek <jakub@redhat.com> wrote: >> On Tue, Jul 14, 2015 at 08:40:50PM +0300, Maxim Blumental wrote: >>> The patch replaces all FP comparisons with inequalities and epsilons >>> in those tests for libgomp. >> > > libgomp.fortran/examples-4/simd-7.f90 takes a very long time to > run on Linux/ia32. I get random: > > FAIL: libgomp.fortran/examples-4/simd-7.f90 -O0 execution test > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66950 > > > -- > H.J. -- --------------------- Sincerely yours, Maxim Blumental [-- Attachment #2: ChangeLog.txt --] [-- Type: text/plain, Size: 788 bytes --] 2015-07-22 Maxim Blumenthal <maxim.blumenthal@intel.com> PR libgomp/66950 * testsuite/libgomp.c/examples-4/simd-7.c: Lower the defined constant N to 30. Add iterative reference function for Fibonacci numbers - fib_ref. (fib): Correct corner cases in the recursion. (main): Replace the non-simd loop with fib_ref call. * testsuite/libgomp.fortran/examples-4/simd-7.f90: Add iterative reference subroutine for Fibonacci numbers - fib_ref. (fibonacci): Lower the parameter N to 30. Correct accordingly check for the last array element value. Replace the non-simd loop with fib_ref call. Remove redundant b_ref array. Remove the comparison of the last array element with according Fibbonacci sequence element. (fib): Correct corner cases in the recursion. [-- Attachment #3: fib_fix.patch --] [-- Type: application/octet-stream, Size: 2727 bytes --] commit 42ac6a9b4aef2e08746becd19554e07830f4ed1e Author: Maxim Blumenthal <maxim.blumenthal@intel.com> Date: Tue Jul 21 10:16:25 2015 +0300 Reduced computation complexity in tests for simd pragma to make the execution time reasonable. diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-7.c b/libgomp/testsuite/libgomp.c/examples-4/simd-7.c index 4aab962..884642e 100644 --- a/libgomp/testsuite/libgomp.c/examples-4/simd-7.c +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-7.c @@ -5,17 +5,30 @@ #include <stdio.h> #include <stdlib.h> -#define N 45 +#define N 30 int a[N], a_ref[N], b[N]; #pragma omp declare simd inbranch int fib( int n ) { - if (n <= 2) - return n; - else { - return fib(n-1) + fib(n-2); - } + if (n <= 1) + return n; + else if (n == 2) + return 1; + else + return fib(n-1) + fib(n-2); +} + +void fib_ref() +{ + int i; + + a_ref[0] = 0; + a_ref[1] = 1; + a_ref[2] = 1; + + for (i=3; i < N; i++) + a_ref[i] = a_ref[i-2] + a_ref[i-1]; } int main(void) @@ -30,8 +43,7 @@ int main(void) for (i=0; i < N; i++) a[i] = fib(b[i]); - for (i=0; i < N; i++) - a_ref[i] = fib(b[i]); + fib_ref (); for (i=0; i < N; i++) if (a[i] != a_ref[i]) diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 index a61bb03..e8e960d 100644 --- a/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 @@ -4,9 +4,9 @@ program fibonacci implicit none - integer,parameter :: N=45 + integer,parameter :: N=30 integer :: a(0:N-1), b(0:N-1) - integer :: a_ref(0:N-1), b_ref(0:N-1) + integer :: a_ref(0:N-1) integer :: i integer, external :: fib @@ -15,35 +15,42 @@ program fibonacci b(i) = i end do - do i = 0,N-1 - b_ref(i) = i - end do - !$omp simd do i=0,N-1 a(i) = fib(b(i)) end do - do i=0,N-1 - a_ref(i) = fib(b_ref(i)) - end do + call fib_ref (a_ref, N) do i = 0, N-1 if (a(i) .ne. a_ref(i)) call abort () end do - if (a(44) .ne. 1134903170) call abort() - end program recursive function fib(n) result(r) !$omp declare simd(fib) inbranch integer :: n, r - if (n <= 2) then - r = n + if (n <= 1) then + r = n + else if (n == 2) then + r = 1 else r = fib(n-1) + fib(n-2) endif end function fib + +subroutine fib_ref(a_ref, n) + integer :: n, a_ref(0:n-1) + + a_ref(0) = 0 + a_ref(1) = 1 + a_ref(2) = 1 + + do i = 3, n-1 + a_ref(i) = a_ref(i-1) + a_ref(i-2) + end do + +end subroutine fib_ref ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-22 13:57 ` Maxim Blumental @ 2015-07-22 14:16 ` Jakub Jelinek 2015-07-22 15:12 ` Maxim Blumental 0 siblings, 1 reply; 19+ messages in thread From: Jakub Jelinek @ 2015-07-22 14:16 UTC (permalink / raw) To: Maxim Blumental; +Cc: H.J. Lu, gcc-patches, Ilya Verbin On Wed, Jul 22, 2015 at 04:55:09PM +0300, Maxim Blumental wrote: > 2015-07-22 Maxim Blumenthal <maxim.blumenthal@intel.com> > > PR libgomp/66950 > * testsuite/libgomp.c/examples-4/simd-7.c: Lower the defined constant > N to 30. Add iterative reference function for Fibonacci numbers > - fib_ref. Incorrect changelog. It should be: * testsuite/libgomp.c/examples-4/simd-7.c (N): Change to 30 from 45. (fib_ref): New function. > (fib): Correct corner cases in the recursion. Why the n == 2 special case? I think only the if (n <= 1) return n; case is really needed. > (main): Replace the non-simd loop with fib_ref call. > * testsuite/libgomp.fortran/examples-4/simd-7.f90: Add iterative > reference subroutine for Fibonacci numbers - fib_ref. See above for ChangeLog entry issue. > (fibonacci): Lower the parameter N to 30. Correct accordingly check for > the last array element value. Replace the non-simd loop with fib_ref > call. Remove redundant b_ref array. Remove the comparison of the last > array element with according Fibbonacci sequence element. > (fib): Correct corner cases in the recursion. See above for n == 2 special case. Jakub ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-22 14:16 ` Jakub Jelinek @ 2015-07-22 15:12 ` Maxim Blumental 2015-07-22 15:30 ` Jakub Jelinek 0 siblings, 1 reply; 19+ messages in thread From: Maxim Blumental @ 2015-07-22 15:12 UTC (permalink / raw) To: Jakub Jelinek; +Cc: H.J. Lu, gcc-patches, Ilya Verbin [-- Attachment #1: Type: text/plain, Size: 1457 bytes --] Corrected log and patch. 2015-07-22 17:12 GMT+03:00 Jakub Jelinek <jakub@redhat.com>: > On Wed, Jul 22, 2015 at 04:55:09PM +0300, Maxim Blumental wrote: >> 2015-07-22 Maxim Blumenthal <maxim.blumenthal@intel.com> >> >> PR libgomp/66950 >> * testsuite/libgomp.c/examples-4/simd-7.c: Lower the defined constant >> N to 30. Add iterative reference function for Fibonacci numbers >> - fib_ref. > > Incorrect changelog. It should be: > * testsuite/libgomp.c/examples-4/simd-7.c (N): Change to 30 from 45. > (fib_ref): New function. > >> (fib): Correct corner cases in the recursion. > > Why the n == 2 special case? I think only the if (n <= 1) return n; > case is really needed. > >> (main): Replace the non-simd loop with fib_ref call. >> * testsuite/libgomp.fortran/examples-4/simd-7.f90: Add iterative >> reference subroutine for Fibonacci numbers - fib_ref. > > See above for ChangeLog entry issue. > >> (fibonacci): Lower the parameter N to 30. Correct accordingly check for >> the last array element value. Replace the non-simd loop with fib_ref >> call. Remove redundant b_ref array. Remove the comparison of the last >> array element with according Fibbonacci sequence element. >> (fib): Correct corner cases in the recursion. > > See above for n == 2 special case. > > Jakub -- --------------------- Sincerely yours, Maxim Blumental [-- Attachment #2: ChangeLog.txt --] [-- Type: text/plain, Size: 692 bytes --] 2015-07-22 Maxim Blumenthal <maxim.blumenthal@intel.com> PR libgomp/66950 * testsuite/libgomp.c/examples-4/simd-7.c(N): Change to 30 from 45. (fib_ref): New function. (fib): Correct corner cases in the recursion. (main): Replace the non-simd loop with fib_ref call. * testsuite/libgomp.fortran/examples-4/simd-7.f90: (fib_ref): New subroutine. (fibonacci): Lower the parameter N to 30. Correct accordingly check for the last array element value. Replace the non-simd loop with fib_ref call. Remove redundant b_ref array. Remove the comparison of the last array element with according Fibbonacci sequence element. (fib): Correct corner cases in the recursion. [-- Attachment #3: fib_fix.patch --] [-- Type: application/octet-stream, Size: 2619 bytes --] commit 98914990eab010c977c21958e317de76e11b9c7a Author: Maxim Blumenthal <maxim.blumenthal@intel.com> Date: Tue Jul 21 10:16:25 2015 +0300 Reduced computation complexity in tests for simd pragma to make the execution time reasonable. diff --git a/libgomp/testsuite/libgomp.c/examples-4/simd-7.c b/libgomp/testsuite/libgomp.c/examples-4/simd-7.c index 4aab962..732cd91 100644 --- a/libgomp/testsuite/libgomp.c/examples-4/simd-7.c +++ b/libgomp/testsuite/libgomp.c/examples-4/simd-7.c @@ -5,17 +5,27 @@ #include <stdio.h> #include <stdlib.h> -#define N 45 +#define N 30 int a[N], a_ref[N], b[N]; #pragma omp declare simd inbranch int fib( int n ) { - if (n <= 2) - return n; - else { - return fib(n-1) + fib(n-2); - } + if (n <= 1) + return n; + else + return fib(n-1) + fib(n-2); +} + +void fib_ref() +{ + int i; + + a_ref[0] = 0; + a_ref[1] = 1; + + for (i=2; i < N; i++) + a_ref[i] = a_ref[i-2] + a_ref[i-1]; } int main(void) @@ -30,8 +40,7 @@ int main(void) for (i=0; i < N; i++) a[i] = fib(b[i]); - for (i=0; i < N; i++) - a_ref[i] = fib(b[i]); + fib_ref (); for (i=0; i < N; i++) if (a[i] != a_ref[i]) diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 index a61bb03..7560657 100644 --- a/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 @@ -4,9 +4,9 @@ program fibonacci implicit none - integer,parameter :: N=45 + integer,parameter :: N=30 integer :: a(0:N-1), b(0:N-1) - integer :: a_ref(0:N-1), b_ref(0:N-1) + integer :: a_ref(0:N-1) integer :: i integer, external :: fib @@ -15,35 +15,39 @@ program fibonacci b(i) = i end do - do i = 0,N-1 - b_ref(i) = i - end do - !$omp simd do i=0,N-1 a(i) = fib(b(i)) end do - do i=0,N-1 - a_ref(i) = fib(b_ref(i)) - end do + call fib_ref (a_ref, N) do i = 0, N-1 if (a(i) .ne. a_ref(i)) call abort () end do - if (a(44) .ne. 1134903170) call abort() - end program recursive function fib(n) result(r) !$omp declare simd(fib) inbranch integer :: n, r - if (n <= 2) then - r = n + if (n <= 1) then + r = n else r = fib(n-1) + fib(n-2) endif end function fib + +subroutine fib_ref(a_ref, n) + integer :: n, a_ref(0:n-1) + + a_ref(0) = 0 + a_ref(1) = 1 + + do i = 2, n-1 + a_ref(i) = a_ref(i-1) + a_ref(i-2) + end do + +end subroutine fib_ref ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2. 2015-07-22 15:12 ` Maxim Blumental @ 2015-07-22 15:30 ` Jakub Jelinek 0 siblings, 0 replies; 19+ messages in thread From: Jakub Jelinek @ 2015-07-22 15:30 UTC (permalink / raw) To: Maxim Blumental; +Cc: H.J. Lu, gcc-patches, Ilya Verbin On Wed, Jul 22, 2015 at 05:49:13PM +0300, Maxim Blumental wrote: > 2015-07-22 Maxim Blumenthal <maxim.blumenthal@intel.com> > > PR libgomp/66950 > * testsuite/libgomp.c/examples-4/simd-7.c(N): Change to 30 from 45. Space before (N): > (fib_ref): New function. > (fib): Correct corner cases in the recursion. > (main): Replace the non-simd loop with fib_ref call. > * testsuite/libgomp.fortran/examples-4/simd-7.f90: (fib_ref): New > subroutine. > (fibonacci): Lower the parameter N to 30. Correct accordingly check > for the last array element value. Replace the non-simd loop with > fib_ref call. Remove redundant b_ref array. Remove the comparison > of the last array element with according Fibbonacci sequence element. > (fib): Correct corner cases in the recursion. Ok with that change. Jakub ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2
@ 2015-07-15 10:49 Dominique d'Humières
2015-07-15 13:37 ` Ilya Verbin
0 siblings, 1 reply; 19+ messages in thread
From: Dominique d'Humières @ 2015-07-15 10:49 UTC (permalink / raw)
To: bvmaks; +Cc: jakub, GCC Patches
> The patch replaces all FP comparisons with inequalities and epsilons
> in those tests for libgomp.
In libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90
integer, parameter :: EPS = 0.005
should be
real, parameter :: EPS = 0.005
TIA
Dominique
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Tests for libgomp based on OpenMP Examples 4.0.2 2015-07-15 10:49 Dominique d'Humières @ 2015-07-15 13:37 ` Ilya Verbin 0 siblings, 0 replies; 19+ messages in thread From: Ilya Verbin @ 2015-07-15 13:37 UTC (permalink / raw) To: Dominique d'Humières; +Cc: bvmaks, GCC Patches On Wed, Jul 15, 2015 at 12:29:53 +0200, Dominique d'Humières wrote: > > The patch replaces all FP comparisons with inequalities and epsilons > > in those tests for libgomp. > In libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 > > integer, parameter :: EPS = 0.005 > > should be > > real, parameter :: EPS = 0.005 Committed as obvious. 2015-07-15 Maxim Blumenthal <maxim.blumenthal@intel.com> * testsuite/libgomp.fortran/examples-4/simd-8.f90: (main): Change type of EPS parameter from integer to real. * testsuite/libgomp.fortran/examples-4/task_dep-5.f90: (check): Change type of EPS parameter from integer to real. diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 index ba7b0f9..3c7869d 100644 --- a/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 +++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-8.f90 @@ -36,7 +36,7 @@ program simd_8f implicit none real :: pri, arr(1000), diff integer :: i - integer, parameter :: EPS = 0.005 + real, parameter :: EPS = 0.005 do i = 1, 1000 P(i) = i diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 index f12b42c..0746531 100644 --- a/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 +++ b/libgomp/testsuite/libgomp.fortran/examples-4/task_dep-5.f90 @@ -44,7 +44,7 @@ contains subroutine check (N, A, B) integer :: N integer :: i, j - integer, parameter :: EPS = 0.000001 + real, parameter :: EPS = 0.000001 real, dimension(N,N) :: A, B real :: diff do i = 1, N -- Ilya ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2015-07-22 14:55 UTC | newest] Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-07-07 16:48 Tests for libgomp based on OpenMP Examples 4.0.2 Maxim Blumental 2015-07-07 17:08 ` Maxim Blumental 2015-07-07 18:17 ` Jakub Jelinek 2015-07-07 18:30 ` Ilya Verbin 2015-07-08 12:51 ` Maxim Blumental 2015-07-08 13:00 ` Maxim Blumental 2015-07-09 12:57 ` Maxim Blumental 2015-07-09 14:23 ` Maxim Blumental 2015-07-09 20:14 ` Jakub Jelinek 2015-07-14 13:41 ` Jakub Jelinek [not found] ` <CACy_Q+xw79aVfMxHg00LX7OWRqLUKS4LE4QtV=RSqMSS8vV=Vw@mail.gmail.com> [not found] ` <20150714172935.GM1788@tucnak.redhat.com> [not found] ` <CACy_Q+x4JiHm_=BaSDmxCXqFJmChh=vvTv+22Xh-9x2br1HUAQ@mail.gmail.com> 2015-07-14 17:46 ` Maxim Blumental 2015-07-14 18:28 ` Jakub Jelinek 2015-07-20 19:58 ` H.J. Lu 2015-07-22 13:57 ` Maxim Blumental 2015-07-22 14:16 ` Jakub Jelinek 2015-07-22 15:12 ` Maxim Blumental 2015-07-22 15:30 ` Jakub Jelinek 2015-07-15 10:49 Dominique d'Humières 2015-07-15 13:37 ` Ilya Verbin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).