c68ddd5e2a
libgomp/ * testsuite/libgomp.oacc-c-c++-common/lib-11.c: Enable for all but '-DACC_MEM_SHARED=0'. * testsuite/libgomp.oacc-c-c++-common/lib-13.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-14.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-15.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-20.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-23.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-24.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-34.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-42.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-44.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-48.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-88.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-89.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-92.c: Likewise. * testsuite/libgomp.oacc-fortran/lib-14.f90: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-5.c: Add 'acc_device_radeon' testing. * testsuite/libgomp.oacc-c-c++-common/lib-6.c: Likewise. * testsuite/libgomp.oacc-fortran/lib-5.f90: Likewise. * testsuite/libgomp.oacc-fortran/lib-7.f90: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-52.c: Enable for all. * testsuite/libgomp.oacc-c-c++-common/lib-53.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-54.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-86.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-87.c: Likewise. * testsuite/libgomp.oacc-fortran/lib-10.f90: Likewise. * testsuite/libgomp.oacc-fortran/lib-8.f90: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-57.c: Improve checking for non-'openacc_nvidia_accel_selected'. * testsuite/libgomp.oacc-c-c++-common/lib-58.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-62.c: Clarify that "Not all implement this checking". * testsuite/libgomp.oacc-c-c++-common/lib-63.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-64.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-65.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-67.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-68.c: Likewise.
119 lines
2.0 KiB
C
119 lines
2.0 KiB
C
/* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
|
|
|
|
#include <stdio.h>
|
|
#include <pthread.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <ctype.h>
|
|
#include <openacc.h>
|
|
|
|
unsigned char **x;
|
|
void **d_x;
|
|
const int N = 16;
|
|
const int NTHREADS = 32;
|
|
|
|
static void *
|
|
test (void *arg)
|
|
{
|
|
int i;
|
|
int tid;
|
|
unsigned char *p;
|
|
int devnum;
|
|
|
|
tid = (int) (long) arg;
|
|
|
|
devnum = acc_get_device_num (acc_device_default);
|
|
acc_set_device_num (devnum, acc_device_default);
|
|
|
|
#if ACC_DEVICE_TYPE_nvidia
|
|
if (acc_get_current_cuda_context () == NULL)
|
|
abort ();
|
|
#else
|
|
if (acc_get_current_cuda_context () != NULL)
|
|
abort ();
|
|
#endif
|
|
|
|
p = (unsigned char *) malloc (N);
|
|
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
p[i] = tid;
|
|
}
|
|
|
|
x[tid] = p;
|
|
|
|
d_x[tid] = acc_copyin (p, N);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
int i;
|
|
pthread_attr_t attr;
|
|
pthread_t *tid;
|
|
|
|
acc_init (acc_device_default);
|
|
|
|
x = (unsigned char **) malloc (NTHREADS * N);
|
|
d_x = (void **) malloc (NTHREADS * N);
|
|
|
|
if (pthread_attr_init (&attr) != 0)
|
|
perror ("pthread_attr_init failed");
|
|
|
|
tid = (pthread_t *) malloc (NTHREADS * sizeof (pthread_t));
|
|
|
|
for (i = 0; i < NTHREADS; i++)
|
|
{
|
|
if (pthread_create (&tid[i], &attr, &test, (void *) (unsigned long) (i))
|
|
!= 0)
|
|
perror ("pthread_create failed");
|
|
}
|
|
|
|
if (pthread_attr_destroy (&attr) != 0)
|
|
perror ("pthread_attr_destroy failed");
|
|
|
|
for (i = 0; i < NTHREADS; i++)
|
|
{
|
|
void *res;
|
|
|
|
if (pthread_join (tid[i], &res) != 0)
|
|
perror ("pthread join failed");
|
|
}
|
|
|
|
for (i = 0; i < NTHREADS; i++)
|
|
{
|
|
if (acc_is_present (x[i], N) != 1)
|
|
abort ();
|
|
}
|
|
|
|
for (i = 0; i < NTHREADS; i++)
|
|
{
|
|
memset (x[i], 0, N);
|
|
acc_copyout (x[i], N);
|
|
}
|
|
|
|
for (i = 0; i < NTHREADS; i++)
|
|
{
|
|
unsigned char *p;
|
|
int j;
|
|
|
|
p = x[i];
|
|
|
|
for (j = 0; j < N; j++)
|
|
{
|
|
if (p[j] != i)
|
|
abort ();
|
|
}
|
|
|
|
if (acc_is_present (x[i], N) != 0)
|
|
abort ();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* { dg-output "" } */
|