8183ebcdc1
The test case was written with assumptions about loop iteration ordering that are not guaranteed by OpenACC and do not apply on all targets, in particular AMD GCN. This patch removes those assumptions. 2020-09-08 Julian Brown <julian@codesourcery.com> libgomp/ * testsuite/libgomp.oacc-c-c++-common/atomic_capture-2.c: Remove iteration-ordering assumptions.
1621 lines
26 KiB
C
1621 lines
26 KiB
C
/* { dg-do run } */
|
|
|
|
#include <stdlib.h>
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
int iexp, igot, imax, imin;
|
|
long long lexp, lgot;
|
|
int N = 32;
|
|
int i;
|
|
int idata[N];
|
|
long long ldata[N];
|
|
float fexp, fgot;
|
|
float fdata[N];
|
|
|
|
igot = 1234;
|
|
iexp = 31;
|
|
|
|
for (i = 0; i < N; i++)
|
|
idata[i] = i;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; igot = i; }
|
|
}
|
|
|
|
imax = 0;
|
|
imin = N;
|
|
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
imax = idata[i] > imax ? idata[i] : imax;
|
|
imin = idata[i] < imin ? idata[i] : imin;
|
|
}
|
|
|
|
if (imax != 1234 || imin < 0 || imin > 1)
|
|
abort ();
|
|
|
|
igot = 0;
|
|
iexp = 32;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; igot++; }
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 0;
|
|
iexp = 32;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; ++igot; }
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 0;
|
|
iexp = 32;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
#pragma acc atomic capture
|
|
{ ++igot; idata[i] = igot; }
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 0;
|
|
iexp = 32;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
#pragma acc atomic capture
|
|
{ igot++; idata[i] = igot; }
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 32;
|
|
iexp = 0;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; igot--; }
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 32;
|
|
iexp = 0;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; --igot; }
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 32;
|
|
iexp = 0;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
#pragma acc atomic capture
|
|
{ --igot; idata[i] = igot; }
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 32;
|
|
iexp = 0;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
#pragma acc atomic capture
|
|
{ igot--; idata[i] = igot; }
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
/* BINOP = + */
|
|
igot = 0;
|
|
iexp = 32;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; igot += expr; }
|
|
}
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 0;
|
|
iexp = 32;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ igot += expr; idata[i] = igot; }
|
|
}
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 0;
|
|
iexp = 32;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; igot = igot + expr; }
|
|
}
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 0;
|
|
iexp = 32;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; igot = expr + igot; }
|
|
}
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 0;
|
|
iexp = 32;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ igot = igot + expr; idata[i] = igot; }
|
|
}
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
|
|
igot = 0;
|
|
iexp = 32;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ igot = expr + igot; idata[i] = igot; }
|
|
}
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
/* BINOP = * */
|
|
lgot = 1LL;
|
|
lexp = 1LL << 32;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot *= expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 1LL << 32;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot *= expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 1LL << 32;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = lgot * expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 1LL << 32;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = expr * lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 1LL << 32;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = lgot * expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 1LL << 32;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = expr * lgot; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
/* BINOP = - */
|
|
igot = 32;
|
|
iexp = 0;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; igot -= expr; }
|
|
}
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 32;
|
|
iexp = 0;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ igot -= expr; idata[i] = igot; }
|
|
}
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 32;
|
|
iexp = 0;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; igot = igot - expr; }
|
|
}
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 1;
|
|
iexp = 1;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ idata[i] = igot; igot = expr - igot; }
|
|
}
|
|
}
|
|
|
|
int ones = 0, zeros = 0;
|
|
|
|
for (i = 0; i < N; i++)
|
|
if (idata[i] == 1)
|
|
ones++;
|
|
else if (idata[i] == 0)
|
|
zeros++;
|
|
|
|
if (ones != N / 2 || zeros != N / 2)
|
|
abort ();
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 1;
|
|
iexp = -31;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ igot = igot - expr; idata[i] = igot; }
|
|
}
|
|
}
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
igot = 1;
|
|
iexp = 1;
|
|
|
|
#pragma acc data copy (igot, idata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
int expr = 1;
|
|
|
|
#pragma acc atomic capture
|
|
{ igot = expr - igot; idata[i] = igot; }
|
|
}
|
|
}
|
|
|
|
ones = zeros = 0;
|
|
|
|
for (i = 0; i < N; i++)
|
|
if (idata[i] == 1)
|
|
ones++;
|
|
else if (idata[i] == 0)
|
|
zeros++;
|
|
|
|
if (ones != N / 2 || zeros != N / 2)
|
|
abort ();
|
|
|
|
if (iexp != igot)
|
|
abort ();
|
|
|
|
/* BINOP = / */
|
|
lgot = 1LL << 32;
|
|
lexp = 1LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot /= expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL << 32;
|
|
lexp = 1LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot /= expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL << 32;
|
|
lexp = 1LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = lgot / expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 2LL;
|
|
lexp = 2LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1LL << N;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = expr / lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 2LL << N;
|
|
lexp = 2LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = lgot / expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 2LL;
|
|
lexp = 2LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1LL << N;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = expr / lgot; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
/* BINOP = & */
|
|
lgot = ~0LL;
|
|
lexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot &= expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = ~0LL;
|
|
iexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot &= expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = ~0LL;
|
|
lexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = lgot & expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = ~0LL;
|
|
lexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = expr & lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = ~0LL;
|
|
iexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = lgot & expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = ~0LL;
|
|
lexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = expr & lgot; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
/* BINOP = ^ */
|
|
lgot = ~0LL;
|
|
lexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1 << i;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot ^= expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = ~0LL;
|
|
iexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot ^= expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = ~0LL;
|
|
lexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = lgot ^ expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = ~0LL;
|
|
lexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = expr ^ lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = ~0LL;
|
|
iexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = lgot ^ expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = ~0LL;
|
|
lexp = 0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = expr ^ lgot; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
/* BINOP = | */
|
|
lgot = 0LL;
|
|
lexp = ~0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1 << i;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot |= expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 0LL;
|
|
iexp = ~0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot |= expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 0LL;
|
|
lexp = ~0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = lgot | expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 0LL;
|
|
lexp = ~0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = expr | lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 0LL;
|
|
iexp = ~0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = lgot | expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 0LL;
|
|
lexp = ~0LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = ~(1 << i);
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = expr | lgot; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
/* BINOP = << */
|
|
lgot = 1LL;
|
|
lexp = 1LL << N;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot <<= expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
iexp = 1LL << N;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot <<= expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 1LL << N;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = lgot << expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 2LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < 1; i++)
|
|
{
|
|
long long expr = 1LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = expr << lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 2LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < 1; i++)
|
|
{
|
|
long long expr = 1LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = lgot << expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 2LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < 1; i++)
|
|
{
|
|
long long expr = 1LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = expr << lgot; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
/* BINOP = >> */
|
|
lgot = 1LL << N;
|
|
lexp = 1LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot >>= expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL << N;
|
|
iexp = 1LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot >>= expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL << N;
|
|
lexp = 1LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = lgot >> expr; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 1LL << (N - 1);
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < 1; i++)
|
|
{
|
|
long long expr = 1LL << N;
|
|
|
|
#pragma acc atomic capture
|
|
{ ldata[i] = lgot; lgot = expr >> lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL << N;
|
|
lexp = 1LL;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 1LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = lgot >> expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 1LL << (N - 1);
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < 1; i++)
|
|
{
|
|
long long expr = 1LL << N;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = expr >> lgot; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
// FLOAT FLOAT FLOAT
|
|
|
|
/* BINOP = + */
|
|
fgot = 0.0;
|
|
fexp = 32.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot += expr; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 0.0;
|
|
fexp = 32.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot += expr; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 0.0;
|
|
fexp = 32.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ idata[i] = fgot; fgot = fgot + expr; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 0.0;
|
|
fexp = 32.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot = expr + fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 0.0;
|
|
fexp = 32.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot = fgot + expr; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 0.0;
|
|
fexp = 32.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot = expr + fgot; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
/* BINOP = * */
|
|
fgot = 1.0;
|
|
fexp = 8192.0*8192.0*64.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 2.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot *= expr; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 1.0;
|
|
fexp = 8192.0*8192.0*64.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 2.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot *= expr; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 1.0;
|
|
fexp = 8192.0*8192.0*64.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 2.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot = fgot * expr; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 1.0;
|
|
fexp = 8192.0*8192.0*64.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 2.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot = expr * fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
lgot = 1LL;
|
|
lexp = 1LL << 32;
|
|
|
|
#pragma acc data copy (lgot, ldata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ lgot = lgot * expr; ldata[i] = lgot; }
|
|
}
|
|
}
|
|
|
|
if (lexp != lgot)
|
|
abort ();
|
|
|
|
fgot = 1.0;
|
|
fexp = 8192.0*8192.0*64.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot = expr * fgot; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
/* BINOP = - */
|
|
fgot = 32.0;
|
|
fexp = 0.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot -= expr; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 32.0;
|
|
fexp = 0.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot -= expr; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 32.0;
|
|
fexp = 0.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot = fgot - expr; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 1.0;
|
|
fexp = 1.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot = expr - fgot; }
|
|
}
|
|
}
|
|
|
|
ones = zeros = 0;
|
|
|
|
for (i = 0; i < N; i++)
|
|
if (fdata[i] == 1.0)
|
|
ones++;
|
|
else if (fdata[i] == 0.0)
|
|
zeros++;
|
|
|
|
if (ones != N / 2 || zeros != N / 2)
|
|
abort ();
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 1.0;
|
|
fexp = -31.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot = fgot - expr; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 1.0;
|
|
fexp = 1.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot = expr - fgot; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
ones = zeros = 0;
|
|
|
|
for (i = 0; i < N; i++)
|
|
if (fdata[i] == 1.0)
|
|
ones++;
|
|
else if (fdata[i] == 0.0)
|
|
zeros++;
|
|
|
|
if (ones != N / 2 || zeros != N / 2)
|
|
abort ();
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
/* BINOP = / */
|
|
fgot = 8192.0*8192.0*64.0;
|
|
fexp = 1.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 2.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot /= expr; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 8192.0*8192.0*64.0;
|
|
fexp = 1.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 2.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot /= expr; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 8192.0*8192.0*64.0;
|
|
fexp = 1.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 2.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot = fgot / expr; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 8192.0*8192.0*64.0;
|
|
fexp = fgot;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 1.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fdata[i] = fgot; fgot = expr / fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 2.0 * (1LL << N);
|
|
fexp = 2.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
long long expr = 2LL;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot = fgot / expr; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
fgot = 4.0;
|
|
fexp = 4.0;
|
|
|
|
#pragma acc data copy (fgot, fdata[0:N])
|
|
{
|
|
#pragma acc parallel loop
|
|
for (i = 0; i < N; i++)
|
|
{
|
|
float expr = 2.0;
|
|
|
|
#pragma acc atomic capture
|
|
{ fgot = expr / fgot; fdata[i] = fgot; }
|
|
}
|
|
}
|
|
|
|
if (fexp != fgot)
|
|
abort ();
|
|
|
|
return 0;
|
|
}
|