14 const int NTHREADS
= 32;
24 tid
= (int) (long) arg
;
26 devnum
= acc_get_device_num (acc_device_nvidia
);
27 acc_set_device_num (devnum
, acc_device_nvidia
);
29 if (acc_get_current_cuda_context () == NULL
)
32 p
= (unsigned char *) malloc (N
);
34 for (i
= 0; i
< N
; i
++)
41 d_x
[tid
] = acc_copyin (p
, N
);
47 main (int argc
, char **argv
)
53 if (acc_get_num_devices (acc_device_nvidia
) == 0)
56 acc_init (acc_device_nvidia
);
58 x
= (unsigned char **) malloc (NTHREADS
* N
);
59 d_x
= (void **) malloc (NTHREADS
* N
);
61 if (pthread_attr_init (&attr
) != 0)
62 perror ("pthread_attr_init failed");
64 tid
= (pthread_t
*) malloc (NTHREADS
* sizeof (pthread_t
));
66 for (i
= 0; i
< NTHREADS
; i
++)
68 if (pthread_create (&tid
[i
], &attr
, &test
, (void *) (unsigned long) (i
))
70 perror ("pthread_create failed");
73 if (pthread_attr_destroy (&attr
) != 0)
74 perror ("pthread_attr_destroy failed");
76 for (i
= 0; i
< NTHREADS
; i
++)
80 if (pthread_join (tid
[i
], &res
) != 0)
81 perror ("pthread join failed");
84 for (i
= 0; i
< NTHREADS
; i
++)
86 if (acc_is_present (x
[i
], N
) != 1)
90 for (i
= 0; i
< NTHREADS
; i
++)
93 acc_copyout (x
[i
], N
);
96 for (i
= 0; i
< NTHREADS
; i
++)
103 for (j
= 0; j
< N
; j
++)
109 if (acc_is_present (x
[i
], N
) != 0)
113 acc_shutdown (acc_device_nvidia
);
118 /* { dg-output "" } */