1 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
14 const int NTHREADS
= 32;
24 tid
= (int) (long) arg
;
26 devnum
= acc_get_device_num (acc_device_default
);
27 acc_set_device_num (devnum
, acc_device_default
);
29 #if ACC_DEVICE_TYPE_nvidia
30 if (acc_get_current_cuda_context () == NULL
)
33 if (acc_get_current_cuda_context () != NULL
)
37 p
= (unsigned char *) malloc (N
);
39 for (i
= 0; i
< N
; i
++)
46 d_x
[tid
] = acc_copyin (p
, N
);
52 main (int argc
, char **argv
)
58 acc_init (acc_device_default
);
60 x
= (unsigned char **) malloc (NTHREADS
* N
);
61 d_x
= (void **) malloc (NTHREADS
* N
);
63 if (pthread_attr_init (&attr
) != 0)
64 perror ("pthread_attr_init failed");
66 tid
= (pthread_t
*) malloc (NTHREADS
* sizeof (pthread_t
));
68 for (i
= 0; i
< NTHREADS
; i
++)
70 if (pthread_create (&tid
[i
], &attr
, &test
, (void *) (unsigned long) (i
))
72 perror ("pthread_create failed");
75 if (pthread_attr_destroy (&attr
) != 0)
76 perror ("pthread_attr_destroy failed");
78 for (i
= 0; i
< NTHREADS
; i
++)
82 if (pthread_join (tid
[i
], &res
) != 0)
83 perror ("pthread join failed");
86 for (i
= 0; i
< NTHREADS
; i
++)
88 if (acc_is_present (x
[i
], N
) != 1)
92 for (i
= 0; i
< NTHREADS
; i
++)
95 acc_copyout (x
[i
], N
);
98 for (i
= 0; i
< NTHREADS
; i
++)
105 for (j
= 0; j
< N
; j
++)
111 if (acc_is_present (x
[i
], N
) != 0)
118 /* { dg-output "" } */