aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2015-11-13 15:08:11 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2015-11-13 15:08:11 +0000
commitdd3c1b14afa954856789c4cb955dec474d799edd (patch)
tree19a08eb6b2e574c679c43e09a166f5db2cd3e2bf /libgomp
parent23c64853c83f3cf9cdf6925ab1c77d951cd1686b (diff)
downloadgcc-dd3c1b14afa954856789c4cb955dec474d799edd.zip
gcc-dd3c1b14afa954856789c4cb955dec474d799edd.tar.gz
gcc-dd3c1b14afa954856789c4cb955dec474d799edd.tar.bz2
nvptx.c (nvptx_generate_vector_shuffle): Deal with complex types.
gcc/ * config/nvptx/nvptx.c (nvptx_generate_vector_shuffle): Deal with complex types. libgomp/ * testsuite/libgomp.oacc-c-c++-common/reduction-cplx-dbl.c: New. * testsuite/libgomp.oacc-c-c++-common/reduction-cplx-flt.c: New. From-SVN: r230325
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog5
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-cplx-dbl.c52
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-cplx-flt.c52
3 files changed, 109 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 4e0cddb..9ca963a 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2015-11-13 Nathan Sidwell <nathan@codesourcery.com>
+
+ * testsuite/libgomp.oacc-c-c++-common/reduction-cplx-dbl.c: New.
+ * testsuite/libgomp.oacc-c-c++-common/reduction-cplx-flt.c: New.
+
2015-11-12 James Norris <jnorris@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-cplx-dbl.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-cplx-dbl.c
new file mode 100644
index 0000000..314e511
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-cplx-dbl.c
@@ -0,0 +1,52 @@
+
+#include <complex.h>
+
+/* Double float has 53 bits of fraction. */
+#define FRAC (1.0 / (1LL << 48))
+
+int close_enough (double _Complex a, double _Complex b)
+{
+ double _Complex diff = a - b;
+ double mag2_a = __real__(a) * __real__ (a) + __imag__ (a) * __imag__ (a);
+ double mag2_diff = (__real__(diff) * __real__ (diff)
+ + __imag__ (diff) * __imag__ (diff));
+
+ return mag2_diff / mag2_a < (FRAC * FRAC);
+}
+
+int main (void)
+{
+#define N 100
+ double _Complex ary[N], sum, prod, tsum, tprod;
+ int ix;
+
+ sum = tsum = 0;
+ prod = tprod = 1;
+
+ for (ix = 0; ix < N; ix++)
+ {
+ double frac = ix * (1.0 / 1024) + 1.0;
+
+ ary[ix] = frac + frac * 2.0i - 1.0i;
+ sum += ary[ix];
+ prod *= ary[ix];
+ }
+
+#pragma acc parallel vector_length(32) copyin(ary) copy (tsum, tprod)
+ {
+#pragma acc loop vector reduction(+:tsum) reduction (*:tprod)
+ for (ix = 0; ix < N; ix++)
+ {
+ tsum += ary[ix];
+ tprod *= ary[ix];
+ }
+ }
+
+ if (!close_enough (sum, tsum))
+ return 1;
+
+ if (!close_enough (prod, tprod))
+ return 1;
+
+ return 0;
+}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-cplx-flt.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-cplx-flt.c
new file mode 100644
index 0000000..b3bde65
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-cplx-flt.c
@@ -0,0 +1,52 @@
+
+#include <complex.h>
+
+/* Single float has 23 bits of fraction. */
+#define FRAC (1.0f / (1 << 20))
+
+int close_enough (float _Complex a, float _Complex b)
+{
+ float _Complex diff = a - b;
+ float mag2_a = __real__(a) * __real__ (a) + __imag__ (a) * __imag__ (a);
+ float mag2_diff = (__real__(diff) * __real__ (diff)
+ + __imag__ (diff) * __imag__ (diff));
+
+ return mag2_diff / mag2_a < (FRAC * FRAC);
+}
+
+int main (void)
+{
+#define N 100
+ float _Complex ary[N], sum, prod, tsum, tprod;
+ int ix;
+
+ sum = tsum = 0;
+ prod = tprod = 1;
+
+ for (ix = 0; ix < N; ix++)
+ {
+ float frac = ix * (1.0f / 1024) + 1.0f;
+
+ ary[ix] = frac + frac * 2.0i - 1.0i;
+ sum += ary[ix];
+ prod *= ary[ix];
+ }
+
+#pragma acc parallel vector_length(32) copyin(ary) copy (tsum, tprod)
+ {
+#pragma acc loop vector reduction(+:tsum) reduction (*:tprod)
+ for (ix = 0; ix < N; ix++)
+ {
+ tsum += ary[ix];
+ tprod *= ary[ix];
+ }
+ }
+
+ if (!close_enough (sum, tsum))
+ return 1;
+
+ if (!close_enough (prod, tprod))
+ return 1;
+
+ return 0;
+}