gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c
Tom de Vries 77e0a97acf [nvptx] Ignore c++ exceptions
The nvptx port can't support exceptions using sjlj, because ptx does not
support sjlj.  However, default_except_unwind_info still returns UI_SJLJ, even
even if we configure with --disable-sjlj-exceptions, because UI_SJLJ is the
fallback option.

The reason default_except_unwind_info doesn't return UI_DWARF2 is because
DWARF2_UNWIND_INFO is not defined in defaults.h, because
INCOMING_RETURN_ADDR_RTX is not defined, because there's no ptx equivalent.

Testcase libgomp.c++/for-15.C currently doesn't compile unless fno-exceptions
is added because:
- it tries to generate sjlj exception handling code, and
- it tries to generate exception tables using label-addressed .byte sequence.
  Ptx doesn't support generating random data at a label, nor being able to
  load/write data relative to a label.

This patch fixes the first problem by using UI_TARGET for nvptx.

The second problem is worked around by generating all .byte sequences commented
out.  It would be better to have a narrower workaround, and define
TARGET_ASM_BYTE_OP to "error: .byte unsupported " or some such.

This patch does not enable exceptions for nvptx, it merely allows c++ programs
to run correctly if they do no use exception handling.

Build and reg-tested on x86_64 with nvptx accelerator.

2018-08-02  Tom de Vries  <tdevries@suse.de>

	PR target/86660
	* common/config/nvptx/nvptx-common.c (nvptx_except_unwind_info): New
	function.  Return UI_TARGET unconditionally.
	(TARGET_EXCEPT_UNWIND_INFO): Redefine to nvptx_except_unwind_info.
	* config/nvptx/nvptx.c (TARGET_ASM_BYTE_OP): Emit commented out '.byte'.

	* testsuite/libgomp.oacc-c++/routine-1-auto.C: Remove -fno-exceptions.
	* testsuite/libgomp.oacc-c++/routine-1-template-auto.C: Same.
	* testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C:
	Same.
	* testsuite/libgomp.oacc-c++/routine-1-template.C: Same.
	* testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C: Same.
	* testsuite/libgomp.oacc-c-c++-common/routine-1.c: Same.

From-SVN: r263265
2018-08-02 15:59:01 +00:00

95 lines
2.1 KiB
C

// Defaults, if not "#include"d from ../libgomp.oacc-c++/routine-1-*.C.
#ifndef TEMPLATE
# define TEMPLATE
# define TYPE int
# define RETURN_1 TYPE
# define RETURN_2
#endif
#include <stdlib.h>
#pragma acc routine
TEMPLATE
RETURN_1 fact(TYPE n) RETURN_2
{
if (n == 0 || n == 1)
return 1;
else
return n * fact (n - 1);
}
int main()
{
int *s, *g, *w, *v, *gw, *gv, *wv, *gwv, i, n = 10;
s = (int *) malloc (sizeof (int) * n);
g = (int *) malloc (sizeof (int) * n);
w = (int *) malloc (sizeof (int) * n);
v = (int *) malloc (sizeof (int) * n);
gw = (int *) malloc (sizeof (int) * n);
gv = (int *) malloc (sizeof (int) * n);
wv = (int *) malloc (sizeof (int) * n);
gwv = (int *) malloc (sizeof (int) * n);
#pragma acc parallel loop async copyout(s[0:n]) seq
for (i = 0; i < n; i++)
s[i] = fact (i);
#pragma acc parallel loop async copyout(g[0:n]) gang
for (i = 0; i < n; i++)
g[i] = fact (i);
#pragma acc parallel loop async copyout(w[0:n]) worker
for (i = 0; i < n; i++)
w[i] = fact (i);
#pragma acc parallel loop async copyout(v[0:n]) vector
for (i = 0; i < n; i++)
v[i] = fact (i);
#pragma acc parallel loop async copyout(gw[0:n]) gang worker
for (i = 0; i < n; i++)
gw[i] = fact (i);
#pragma acc parallel loop async copyout(gv[0:n]) gang vector
for (i = 0; i < n; i++)
gv[i] = fact (i);
#pragma acc parallel loop async copyout(wv[0:n]) worker vector
for (i = 0; i < n; i++)
wv[i] = fact (i);
#pragma acc parallel loop async copyout(gwv[0:n]) gang worker vector
for (i = 0; i < n; i++)
gwv[i] = fact (i);
#pragma acc wait
for (i = 0; i < n; i++)
if (s[i] != fact (i))
abort ();
for (i = 0; i < n; i++)
if (g[i] != s[i])
abort ();
for (i = 0; i < n; i++)
if (w[i] != s[i])
abort ();
for (i = 0; i < n; i++)
if (v[i] != s[i])
abort ();
for (i = 0; i < n; i++)
if (gw[i] != s[i])
abort ();
for (i = 0; i < n; i++)
if (gv[i] != s[i])
abort ();
for (i = 0; i < n; i++)
if (wv[i] != s[i])
abort ();
for (i = 0; i < n; i++)
if (gwv[i] != s[i])
abort ();
return 0;
}