13 const int NTHREADS
= 32;
23 tid
= (int) (long) arg
;
25 devnum
= acc_get_device_num (acc_device_nvidia
);
26 acc_set_device_num (devnum
, acc_device_nvidia
);
28 if (acc_get_current_cuda_context () == NULL
)
31 acc_copyout (x
[tid
], N
);
35 for (i
= 0; i
< N
; i
++)
45 main (int argc
, char **argv
)
52 if (acc_get_num_devices (acc_device_nvidia
) == 0)
55 acc_init (acc_device_nvidia
);
57 x
= (unsigned char **) malloc (NTHREADS
* N
);
58 d_x
= (void **) malloc (NTHREADS
* N
);
60 for (i
= 0; i
< N
; i
++)
64 p
= (unsigned char *) malloc (N
);
68 for (j
= 0; j
< N
; j
++)
73 d_x
[i
] = acc_copyin (p
, N
);
76 if (pthread_attr_init (&attr
) != 0)
77 perror ("pthread_attr_init failed");
79 tid
= (pthread_t
*) malloc (NTHREADS
* sizeof (pthread_t
));
81 acc_get_cuda_stream (1);
83 for (i
= 0; i
< NTHREADS
; i
++)
85 if (pthread_create (&tid
[i
], &attr
, &test
, (void *) (unsigned long) (i
))
87 perror ("pthread_create failed");
90 if (pthread_attr_destroy (&attr
) != 0)
91 perror ("pthread_attr_destroy failed");
93 for (i
= 0; i
< NTHREADS
; i
++)
97 if (pthread_join (tid
[i
], &res
) != 0)
98 perror ("pthread join failed");
101 for (i
= 0; i
< NTHREADS
; i
++)
103 if (acc_is_present (x
[i
], N
) != 0)
107 acc_shutdown (acc_device_nvidia
);
112 /* { dg-output "" } */