Message ID | 87vb0bm0dl.fsf@hertz.schwinge.homeip.net |
---|---|
State | New |
Headers | show |
On Tue, Jul 12, 2016 at 03:50:14PM +0200, Thomas Schwinge wrote: > Hi! > > Templated, and "auto", trailing return type syntax with the C++ OpenACC > routine directive all works, but doesn't have test coverage. OK for > trunk? > > commit 7a387329674b07b8eb7e07cff665250284b4524b > Author: Thomas Schwinge <thomas@codesourcery.com> > Date: Thu Jul 7 16:12:15 2016 +0200 > > C++ OpenACC routine directive testing: templated, and "auto", trailing return type syntax > > libgomp/ > * testsuite/libgomp.oacc-c++/routine-1-auto.C: New file. > * testsuite/libgomp.oacc-c++/routine-1-template-auto.C: Likewise. > * testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C: > Likewise. > * testsuite/libgomp.oacc-c++/routine-1-template.C: Likewise. > * testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C: > Likewise. > * testsuite/libgomp.oacc-c-c++-common/routine-1.c: Adjust. Ok. Though looking at the testcases, they will crash if malloc fails and all the allocations of small buffers look kind of pointless. Wouldn't 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); be better replaced with int buf[80]; s = buf; g = s + n; w = g + n; ... ? Jakub
diff --git libgomp/testsuite/libgomp.oacc-c++/routine-1-auto.C libgomp/testsuite/libgomp.oacc-c++/routine-1-auto.C new file mode 100644 index 0000000..f4b54e5 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-c++/routine-1-auto.C @@ -0,0 +1,9 @@ +// Routine with "auto" return type. + +// { dg-additional-options "-fno-exceptions" } + +#define TEMPLATE +#define TYPE int +#define RETURN_1 auto +#define RETURN_2 +#include "../libgomp.oacc-c-c++-common/routine-1.c" diff --git libgomp/testsuite/libgomp.oacc-c++/routine-1-template-auto.C libgomp/testsuite/libgomp.oacc-c++/routine-1-template-auto.C new file mode 100644 index 0000000..444f1f3 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-c++/routine-1-template-auto.C @@ -0,0 +1,8 @@ +// Templated routine with "auto" return type. + +// { dg-additional-options "-fno-exceptions" } + +#define TEMPLATE template<typename TYPE> +#define RETURN_1 auto +#define RETURN_2 +#include "../libgomp.oacc-c-c++-common/routine-1.c" diff --git libgomp/testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C libgomp/testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C new file mode 100644 index 0000000..bfe2787 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C @@ -0,0 +1,8 @@ +// Templated routine using trailing return type syntax. + +// { dg-additional-options "-fno-exceptions" } + +#define TEMPLATE template<typename TYPE> +#define RETURN_1 auto +#define RETURN_2 -> TYPE +#include "../libgomp.oacc-c-c++-common/routine-1.c" diff --git libgomp/testsuite/libgomp.oacc-c++/routine-1-template.C libgomp/testsuite/libgomp.oacc-c++/routine-1-template.C new file mode 100644 index 0000000..a7e0323 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-c++/routine-1-template.C @@ -0,0 +1,8 @@ +// Templated routine. + +// { dg-additional-options "-fno-exceptions" } + +#define TEMPLATE template<typename TYPE> +#define RETURN_1 TYPE +#define RETURN_2 +#include "../libgomp.oacc-c-c++-common/routine-1.c" diff --git libgomp/testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C libgomp/testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C new file mode 100644 index 0000000..3074ba4 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C @@ -0,0 +1,9 @@ +// Routine using trailing return type syntax. + +// { dg-additional-options "-fno-exceptions" } + +#define TEMPLATE +#define TYPE int +#define RETURN_1 auto +#define RETURN_2 -> TYPE +#include "../libgomp.oacc-c-c++-common/routine-1.c" diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c index f112457..2a36b3b 100644 --- libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c +++ libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c @@ -1,10 +1,18 @@ // { dg-additional-options "-fno-exceptions" } -#include <stdio.h> +// 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 -int fact(int n) +TEMPLATE +RETURN_1 fact(TYPE n) RETURN_2 { if (n == 0 || n == 1) return 1;