Hi Tom, hello all,
it turned out that the testcase fails on PowerPC (but not x86_64)
as the nvptx lto complains: unresolved symbol __sync_val_compare_and_swap_16
The testcase uses int128 – and that's the culprit, but I have no idea
why it only fails with PowerPC and not with x86-64.
Unless someone sees a good way to implement __sync_val_compare_and_swap_16,
I propose to XFAIL it for now.
Namely: Split-off the int128 testcase into a new file and run it only
if not nvptx-offloading on PowerPC. If on nvptx+PowerPC, link that testcase
as well – but XFAIL it.
OK? Or do you/does anyone have a better idea?
Tobias
PS: Should I open a PR for the missing __sync_val_compare_and_swap_16?
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander
Walter
libgomp: Split testcase in order to XFAIL __sync_val_compare_and_swap_16
On PowerPC, only, __sync_val_compare_and_swap_16 is generated for the
testcase – which nvptx currently does not support.
libgomp/ChangeLog:
* testsuite/libgomp.c-c++-common/reduction-16.c: Move int128 test to ...
* testsuite/libgomp.c-c++-common/reduction-17.c: ... this new test.
* testsuite/libgomp.c-c++-common/reduction-17a.c: New test.
.../testsuite/libgomp.c-c++-common/reduction-16.c | 8 +----
.../testsuite/libgomp.c-c++-common/reduction-17.c | 41 ++++++++++++++++++++++
.../testsuite/libgomp.c-c++-common/reduction-17a.c | 11 ++++++
3 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c b/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c
index d0e82b04790..02ec4cd36b8 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c
@@ -1,4 +1,5 @@
/* { dg-do run } */
+/* See also reduction-17.c for an int128 testcase. */
#include <stdlib.h>
@@ -32,9 +33,6 @@ GENERATE_TEST(char)
GENERATE_TEST(short)
GENERATE_TEST(int)
GENERATE_TEST(long)
-#ifdef __SIZEOF_INT128__
-GENERATE_TEST(__int128)
-#endif
int main(void)
{
@@ -46,8 +44,4 @@ int main(void)
abort ();
if (test_long ())
abort ();
-#ifdef __SIZEOF_INT128__
- if (test___int128 ())
- abort ();
-#endif
}
diff --git a/libgomp/testsuite/libgomp.c-c++-common/reduction-17.c b/libgomp/testsuite/libgomp.c-c++-common/reduction-17.c
new file mode 100644
index 00000000000..44dabf6e139
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/reduction-17.c
@@ -0,0 +1,41 @@
+/* { dg-do run { target { ! powerpc*-*-linux* } || { ! offload_target_nvptx } } } */
+/* { dg-require-effective-target int128 } */
+
+/* See also reduction-17a.c for powerpc*-*-linux* + offload_target_nvptx. */
+/* See also reduction-16.c for a char/short/int/long testcase. */
+
+#include <stdlib.h>
+
+#define N 512
+
+#define GENERATE_TEST(T) \
+int test_##T (void) \
+{ \
+ T a[N], res = 0; \
+ \
+ for (int i = 0; i < N; ++i) \
+ a[i] = i & 1; \
+ \
+_Pragma("omp target teams distribute reduction(||:res) defaultmap(tofrom:scalar)") \
+ for (int i = 0; i < N; ++i) \
+ res = res || a[i]; \
+ \
+ /* res should be non-zero. */\
+ if (!res) \
+ return 1; \
+ \
+_Pragma("omp target teams distribute reduction(&&:res) defaultmap(tofrom:scalar)") \
+ for (int i = 0; i < N; ++i) \
+ res = res && a[i]; \
+ \
+ /* res should be zero. */ \
+ return res; \
+}
+
+GENERATE_TEST(__int128)
+
+int main(void)
+{
+ if (test___int128 ())
+ abort ();
+}
diff --git a/libgomp/testsuite/libgomp.c-c++-common/reduction-17a.c b/libgomp/testsuite/libgomp.c-c++-common/reduction-17a.c
new file mode 100644
index 00000000000..1e6a7bc990f
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/reduction-17a.c
@@ -0,0 +1,11 @@
+/* Duplicates reduction-17.c as it fails on PowerPC with nvptx offload
+ due to 'unresolved symbol __sync_val_compare_and_swap_16' on the nvptx side. */
+
+/* { dg-do link { target { powerpc*-*-linux* } && { offload_target_nvptx } } } */
+/* { dg-require-effective-target int128 } */
+/* { dg-xfail-if "__sync_val_compare_and_swap_16" { *-*-* } } */
+
+/* See also reduction-17a.c for either not powerpc*-*-linux* or not offload_target_nvptx. */
+/* See also reduction-16.c for a char/short/int/long testcase. */
+
+#include "reduction-17.c"