Retro68/gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-loop-gang-6.c
Wolfgang Thaller 6fbf4226da gcc-9.1
2019-06-20 20:10:10 +02:00

41 lines
712 B
C

#include <assert.h>
/* Test of gang-private aggregate variable declared on loop directive, with
broadcasting to partitioned workers. */
typedef struct {
int x, y, z;
int attr[13];
} vec3;
int
main (int argc, char* argv[])
{
int i, arr[32 * 32];
vec3 pt;
for (i = 0; i < 32 * 32; i++)
arr[i] = i;
#pragma acc kernels copy(arr)
{
#pragma acc loop gang private(pt)
for (i = 0; i < 32; i++)
{
pt.x = i;
pt.y = i * 2;
pt.z = i * 4;
pt.attr[5] = i * 6;
#pragma acc loop worker
for (int j = 0; j < 32; j++)
arr[i * 32 + j] += pt.x + pt.y + pt.z + pt.attr[5];
}
}
for (i = 0; i < 32 * 32; i++)
assert (arr[i] == i + (i / 32) * 13);
return 0;
}