1f62d6375b
2018-05-02 Tom de Vries <tom@codesourcery.com> PR libgomp/82428 * builtins.def (DEF_GOACC_BUILTIN_ONLY): Define. * omp-builtins.def (BUILT_IN_GOACC_PARLEVEL_ID) (BUILT_IN_GOACC_PARLEVEL_SIZE): New builtin. * builtins.c (expand_builtin_goacc_parlevel_id_size): New function. (expand_builtin): Call expand_builtin_goacc_parlevel_id_size. * doc/extend.texi (Other Builtins): Add __builtin_goacc_parlevel_id and __builtin_goacc_parlevel_size. * f95-lang.c (DEF_GOACC_BUILTIN_ONLY): Define. * c-c++-common/goacc/builtin-goacc-parlevel-id-size-2.c: New test. * c-c++-common/goacc/builtin-goacc-parlevel-id-size.c: New test. * testsuite/libgomp.oacc-c-c++-common/gang-static-2.c: Use __builtin_goacc_parlevel_{id,size}. * testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-g-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-g-2.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-wv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-v-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-w-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-g-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-v-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-w-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c: Same. * testsuite/libgomp.oacc-c-c++-common/tile-1.c: Same. From-SVN: r259850
134 lines
2.6 KiB
C
134 lines
2.6 KiB
C
/* { dg-additional-options "-fopenacc-dim=16:16" } */
|
|
|
|
#include <openacc.h>
|
|
#include <alloca.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <gomp-constants.h>
|
|
|
|
#pragma acc routine
|
|
static int __attribute__ ((noinline)) coord ()
|
|
{
|
|
int res = 0;
|
|
|
|
if (acc_on_device (acc_device_not_host))
|
|
{
|
|
int g, w, v;
|
|
|
|
g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
|
|
w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
|
|
v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
|
|
res = (1 << 24) | (g << 16) | (w << 8) | v;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
|
|
int check (const int *ary, int size, int gp, int wp, int vp)
|
|
{
|
|
int exit = 0;
|
|
int ix;
|
|
int *gangs = (int *)alloca (gp * sizeof (int));
|
|
int *workers = (int *)alloca (wp * sizeof (int));
|
|
int *vectors = (int *)alloca (vp * sizeof (int));
|
|
int offloaded = 0;
|
|
|
|
memset (gangs, 0, gp * sizeof (int));
|
|
memset (workers, 0, wp * sizeof (int));
|
|
memset (vectors, 0, vp * sizeof (int));
|
|
|
|
for (ix = 0; ix < size; ix++)
|
|
{
|
|
int g = (ary[ix] >> 16) & 0xff;
|
|
int w = (ary[ix] >> 8) & 0xff;
|
|
int v = (ary[ix] >> 0) & 0xff;
|
|
|
|
if (g >= gp || w >= wp || v >= vp)
|
|
{
|
|
printf ("unexpected cpu %#x used\n", ary[ix]);
|
|
exit = 1;
|
|
}
|
|
else
|
|
{
|
|
vectors[v]++;
|
|
workers[w]++;
|
|
gangs[g]++;
|
|
}
|
|
offloaded += ary[ix] >> 24;
|
|
}
|
|
|
|
if (!offloaded)
|
|
return 0;
|
|
|
|
if (offloaded != size)
|
|
{
|
|
printf ("offloaded %d times, expected %d\n", offloaded, size);
|
|
return 1;
|
|
}
|
|
|
|
for (ix = 0; ix < gp; ix++)
|
|
if (gangs[ix] != gangs[0])
|
|
{
|
|
printf ("gang %d not used %d times\n", ix, gangs[0]);
|
|
exit = 1;
|
|
}
|
|
|
|
for (ix = 0; ix < wp; ix++)
|
|
if (workers[ix] != workers[0])
|
|
{
|
|
printf ("worker %d not used %d times\n", ix, workers[0]);
|
|
exit = 1;
|
|
}
|
|
|
|
for (ix = 0; ix < vp; ix++)
|
|
if (vectors[ix] != vectors[0])
|
|
{
|
|
printf ("vector %d not used %d times\n", ix, vectors[0]);
|
|
exit = 1;
|
|
}
|
|
|
|
return exit;
|
|
}
|
|
|
|
#define N (32 *32*32)
|
|
|
|
int test_1 (int gp, int wp, int vp)
|
|
{
|
|
int ary[N];
|
|
int exit = 0;
|
|
|
|
#pragma acc parallel copyout (ary)
|
|
{
|
|
#pragma acc loop gang (static:1)
|
|
for (int ix = 0; ix < N; ix++)
|
|
ary[ix] = coord ();
|
|
}
|
|
|
|
exit |= check (ary, N, gp, 1, 1);
|
|
|
|
#pragma acc parallel copyout (ary)
|
|
{
|
|
#pragma acc loop worker
|
|
for (int ix = 0; ix < N; ix++)
|
|
ary[ix] = coord ();
|
|
}
|
|
|
|
exit |= check (ary, N, 1, wp, 1);
|
|
|
|
#pragma acc parallel copyout (ary)
|
|
{
|
|
#pragma acc loop vector
|
|
for (int ix = 0; ix < N; ix++)
|
|
ary[ix] = coord ();
|
|
}
|
|
|
|
exit |= check (ary, N, 1, 1, vp);
|
|
|
|
return exit;
|
|
}
|
|
|
|
int main ()
|
|
{
|
|
return test_1 (16, 16, 32);
|
|
}
|