Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / lib-88.c
blobc1cccd919c3152ce6c532a89a6528cc7b3c476d6
1 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
3 #include <stdio.h>
4 #include <pthread.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include <ctype.h>
8 #include <openacc.h>
10 unsigned char *x;
11 void *d_x;
12 const int N = 256;
14 static void *
15 test (void *arg)
17 int i;
19 if (acc_get_current_cuda_context () != NULL)
20 abort ();
22 if (acc_is_present (x, N) != 1)
23 abort ();
25 memset (x, 0, N);
27 acc_copyout (x, N);
29 for (i = 0; i < N; i++)
31 if (x[i] != i)
32 abort ();
34 x[i] = N - i - 1;
37 d_x = acc_copyin (x, N);
39 return 0;
42 int
43 main (int argc, char **argv)
45 const int nthreads = 1;
46 int i;
47 pthread_attr_t attr;
48 pthread_t *tid;
50 acc_init (acc_device_default);
52 x = (unsigned char *) malloc (N);
54 for (i = 0; i < N; i++)
56 x[i] = i;
59 d_x = acc_copyin (x, N);
61 if (acc_is_present (x, N) != 1)
62 abort ();
64 if (pthread_attr_init (&attr) != 0)
65 perror ("pthread_attr_init failed");
67 tid = (pthread_t *) malloc (nthreads * sizeof (pthread_t));
69 for (i = 0; i < nthreads; i++)
71 if (pthread_create (&tid[i], &attr, &test, (void *) (unsigned long) (i))
72 != 0)
73 perror ("pthread_create failed");
76 if (pthread_attr_destroy (&attr) != 0)
77 perror ("pthread_attr_destroy failed");
79 for (i = 0; i < nthreads; i++)
81 void *res;
83 if (pthread_join (tid[i], &res) != 0)
84 perror ("pthread join failed");
87 if (acc_is_present (x, N) != 1)
88 abort ();
90 memset (x, 0, N);
92 acc_copyout (x, N);
94 for (i = 0; i < N; i++)
96 if (x[i] != N - i - 1)
97 abort ();
100 if (acc_is_present (x, N) != 0)
101 abort ();
103 return 0;
106 /* { dg-output "" } */