Debian Codegraph @

libgomp/testsuite/libgomp.oacc-c-c++-common/pr85486.c

raw
1 /* { dg-do run { target openacc_nvidia_accel_selected } } */
2 /* { dg-additional-options "-DVECTOR_LENGTH=vector_length(128)" } */
3
4 /* { dg-additional-options "-foffload=-fdump-tree-oaccloops" } */
5 /* { dg-set-target-env-var "GOMP_DEBUG" "1" } */
6
7 /* Minimized from ref-1.C. */
8
9 #include <stdio.h>
10
11 #pragma acc routine vector
12 void __attribute__((noinline, noclone))
13 Vector (int *ptr, int n, const int inc)
14 {
15 #pragma acc loop vector
16 for (unsigned ix = 0; ix < n; ix++)
17 ptr[ix] += inc;
18 }
19
20 int
21 main (void)
22 {
23 const int n = 32, m=32;
24
25 int ary[m][n];
26 unsigned ix, iy;
27
28 for (ix = m; ix--;)
29 for (iy = n; iy--;)
30 ary[ix][iy] = (1 << 16) + (ix << 8) + iy;
31
32 int err = 0;
33
34 #pragma acc parallel copy (ary) VECTOR_LENGTH /* { dg-warning "using .vector_length \\(32\\). due to call to vector-partitionable routine, ignoring 128" } */
35 {
36 Vector (&ary[0][0], m * n, (1 << 24) - (1 << 16));
37 }
38
39 for (ix = m; ix--;)
40 for (iy = n; iy--;)
41 if (ary[ix][iy] != ((1 << 24) + (ix << 8) + iy))
42 {
43 printf ("ary[%u][%u] = %x expected %x\n",
44 ix, iy, ary[ix][iy], ((1 << 24) + (ix << 8) + iy));
45 err++;
46 }
47
48 if (err)
49 {
50 printf ("%d failed\n", err);
51 return 1;
52 }
53
54 return 0;
55 }
56
57 /* { dg-final { scan-offload-tree-dump "__attribute__\\(\\(oacc function \\(1, 1, 32\\)" "oaccloops" } } */
58 /* { dg-output "nvptx_exec: kernel main\\\$_omp_fn\\\$0: launch gangs=1, workers=1, vectors=32" } */