Re: [C++ PATCH] [gomp4] Initial OpenACC support to C++ front-end
Hi Ilmir! On Thu, 13 Mar 2014 21:05:17 +0400, Ilmir Usmanov i.usma...@samsung.com wrote: On 07.03.2014 15:37, Ilmir Usmanov wrote: I prepared simple patch to add support of OpenACC data, kernels and parallel constructs to C++ FE. It adds support of data clauses too. OK to gomp4 branch? OK once Joseph is fine with the patch, and the following addressed: * gcc/testsuite/c-c++-common/goacc/deviceptr-1.c: Move to ... * gcc/testsuite/gcc.dg/goacc/deviceptr-1.c ... here. OK, I see that the diagnostic messages do differ between C and C++, so that it indeed seems to be better to split the file between the two. Same for the structured block tests, sb*.*. --- /dev/null +++ b/gcc/testsuite/g++.dg/goacc-gomp/goacc-gomp.exp @@ -0,0 +1,38 @@ +# Copyright (C) 2006-2013 Free Software Foundation, Inc. 2014. +# Main loop. +dg-runtest [lsort [concat \ + [find $srcdir/$subdir *.C] \ + [find $srcdir/c-c++-common/goacc-gomp *.c]]] -fopenacc -fopenmp I see gcc/testsuite/g++.dg/gomp/gomp.exp using g++-dg-runtest instead of plain dg-runtest. (I have not yet looked what's different there; can you have a look, please?) --- /dev/null +++ b/gcc/testsuite/g++.dg/goacc/goacc.exp @@ -0,0 +1,37 @@ +# Copyright (C) 2006-2013 Free Software Foundation, Inc. Likewise. +# Main loop. +dg-runtest [lsort [concat \ + [find $srcdir/$subdir *.C] \ + [find $srcdir/c-c++-common/goacc *.c]]] -fopenacc Likewise. Grüße, Thomas pgpfZvuNd6DyH.pgp Description: PGP signature
Re: [C++ PATCH] [gomp4] Initial OpenACC support to C++ front-end
Ping. On 13.03.2014 21:05, Ilmir Usmanov wrote: On 07.03.2014 15:37, Ilmir Usmanov wrote: Hi Thomas! I prepared simple patch to add support of OpenACC data, kernels and parallel constructs to C++ FE. It adds support of data clauses too. OK to gomp4 branch? Fixed subject: changed file extensions of tests and fixed comments. OK to gomp4 branch? -- Ilmir.
Re: [C++ PATCH] [gomp4] Initial OpenACC support to C++ front-end
On Thu, 13 Mar 2014, Ilmir Usmanov wrote: * gcc/testsuite/c-c++-common/goacc/deviceptr-1.c: Move to ... * gcc/testsuite/gcc.dg/goacc/deviceptr-1.c ... here. * gcc/testsuite/g++.dg/goacc/goacc.exp: New test directory. * gcc/testsuite/g++.dg/goacc-gomp/goacc-gomp.exp: Likewise. The ChangeLog file is in gcc/testsuite/, so paths should be given relative to that directory (i.e. without the gcc/testsuite/ part). gcc/testsuite/g++.dg/goacc/ * deviceptr-1.cpp: New test. * sb-1.cpp: Likewise. * sb-2.cpp: Likewise. Here, each entry should contain the g++.dg/goacc/ part. And the ChangeLog entry should be updated for the change in filenames to *.C. + for (t = vars; t t; t = TREE_CHAIN (t)) This use of t t seems odd. + c_parser_omp_var_list_parens() should construct a list of No use of () when referring to a function in a comment. +static tree +cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask, +const char *where, cp_token *pragma_tok, +bool finish_p = true) No caller seems to set this finish_p argument, so I don't see a need for it. +/* OpenACC 2.0: + # pragma acc data oacc-data-clause[optseq] new-line + structured-block + + LOC is the location of the #pragma token. +*/ +static tree +cp_parser_oacc_data (cp_parser *parser, cp_token *pragma_tok) There's no parameter LOC, so it seems wrong for the comment to mention one. (This applies to other functions with such a comment as well.) Observations on the tests: I don't see anything testing diagnostics for the case where it's a return statement that branches out of a block for which isn't not permitted (you have tests for goto and switch statements doing such branches) - is that because such tests are also missing for C? There are questions of how OpenACC constructs interact with C++ features not present in C. I think a lot of such questions would apply more to the implementation of the routine directive than to the things in this patch (as there may well be C++ features not readily supported on an accelerator). For the features in this patch, I suppose exception handling is another form of invalid jump out of a structured block, but it must be considered undefined behavior at runtime because it can't be detected at compile time. I guess something to include in the testsuite is testing use of OpenACC directives within templates. Thus, you have a diagnostic for non-pointer variables being used in a deviceptr clause; the testsuite should verify that if the clause is used within a template, and the type of the variable depends on the type for which a template is instantiated, you only get the error for an instantiation giving it a non-pointer type, not if all instantiations give it a pointer type. (Generally, this applies to any check of something that can only be determined for a particular instantiation.) -- Joseph S. Myers jos...@codesourcery.com
[C++ PATCH] [gomp4] Initial OpenACC support to C++ front-end
On 07.03.2014 15:37, Ilmir Usmanov wrote: Hi Thomas! I prepared simple patch to add support of OpenACC data, kernels and parallel constructs to C++ FE. It adds support of data clauses too. OK to gomp4 branch? Fixed subject: changed file extensions of tests and fixed comments. OK to gomp4 branch? -- Ilmir. From 8368b5196c1201401e1f8301107f11c9e6f064b1 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov i.usma...@samsung.com Date: Thu, 13 Mar 2014 20:59:34 +0400 Subject: [PATCH] Initial OpenACC support to C++ FE --- Initial OpenACC support to C++ front-end: parallel, kernels and data construct with data clauses. gcc/cp/ * cp-tree.h (finish_oacc_data): New function prototype. (finish_oacc_kernels, finish_oacc_parallel): Likewise. * parser.c (cp_parser_omp_clause_name): Support data clauses. (cp_parser_oacc_data_clause): New function. (cp_parser_oacc_data_clause_deviceptr, cp_parser_oacc_all_clauses, cp_parser_oacc_data, cp_parser_oacc_kernels, cp_parser_oacc_parallel): Likewise. (OACC_DATA_CLAUSE_MASK): New define. (OACC_KERNELS_CLAUSE_MASK, OACC_PARALLEL_CLAUSE_MASK): Likewise. (cp_parser_omp_construct, cp_parser_pragma): Support OpenACC directives. * semantics.c (finish_oacc_data): New function. (finish_oacc_kernels, finish_oacc_parallel): Likewise. * gcc/testsuite/c-c++-common/goacc/deviceptr-1.c: Move to ... * gcc/testsuite/gcc.dg/goacc/deviceptr-1.c ... here. * gcc/testsuite/g++.dg/goacc/goacc.exp: New test directory. * gcc/testsuite/g++.dg/goacc-gomp/goacc-gomp.exp: Likewise. gcc/testsuite/g++.dg/goacc/ * deviceptr-1.cpp: New test. * sb-1.cpp: Likewise. * sb-2.cpp: Likewise. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8ec7d6a..9b966d2 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5825,6 +5825,9 @@ extern tree finish_omp_clauses (tree); extern void finish_omp_threadprivate (tree); extern tree begin_omp_structured_block (void); extern tree finish_omp_structured_block (tree); +extern tree finish_oacc_data (tree, tree); +extern tree finish_oacc_kernels (tree, tree); +extern tree finish_oacc_parallel (tree, tree); extern tree begin_omp_parallel (void); extern tree finish_omp_parallel (tree, tree); extern tree begin_omp_task (void); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8c167c7..94d9e22 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -26935,16 +26935,26 @@ cp_parser_omp_clause_name (cp_parser *parser) case 'c': if (!strcmp (collapse, p)) result = PRAGMA_OMP_CLAUSE_COLLAPSE; + else if (!strcmp (copy, p)) + result = PRAGMA_OMP_CLAUSE_COPY; else if (!strcmp (copyin, p)) result = PRAGMA_OMP_CLAUSE_COPYIN; + else if (!strcmp (copyout, p)) + result = PRAGMA_OMP_CLAUSE_COPYOUT; else if (!strcmp (copyprivate, p)) result = PRAGMA_OMP_CLAUSE_COPYPRIVATE; + else if (!strcmp (create, p)) + result = PRAGMA_OMP_CLAUSE_CREATE; break; case 'd': - if (!strcmp (depend, p)) + if (!strcmp (delete, p)) + result = PRAGMA_OMP_CLAUSE_DELETE; + else if (!strcmp (depend, p)) result = PRAGMA_OMP_CLAUSE_DEPEND; else if (!strcmp (device, p)) result = PRAGMA_OMP_CLAUSE_DEVICE; + else if (!strcmp (deviceptr, p)) + result = PRAGMA_OMP_CLAUSE_DEVICEPTR; else if (!strcmp (dist_schedule, p)) result = PRAGMA_OMP_CLAUSE_DIST_SCHEDULE; break; @@ -26993,6 +27003,22 @@ cp_parser_omp_clause_name (cp_parser *parser) case 'p': if (!strcmp (parallel, p)) result = PRAGMA_OMP_CLAUSE_PARALLEL; + else if (!strcmp (present, p)) + result = PRAGMA_OMP_CLAUSE_PRESENT; + else if (!strcmp (present_or_copy, p) + || !strcmp (pcopy, p)) + result = PRAGMA_OMP_CLAUSE_PRESENT_OR_COPY; + else if (!strcmp (present_or_copyin, p) + || !strcmp (pcopyin, p)) + result = PRAGMA_OMP_CLAUSE_PRESENT_OR_COPYIN; + else if (!strcmp (present_or_copyout, p) + || !strcmp (pcopyout, p)) + result = PRAGMA_OMP_CLAUSE_PRESENT_OR_COPYOUT; + else if (!strcmp (present_or_create, p) + || !strcmp (pcreate, p)) + result = PRAGMA_OMP_CLAUSE_PRESENT_OR_CREATE; + else if (!strcmp (private, p)) + result = PRAGMA_OMP_CLAUSE_PRIVATE; else if (!strcmp (proc_bind, p)) result = PRAGMA_OMP_CLAUSE_PROC_BIND; break; @@ -27200,6 +27226,111 @@ cp_parser_omp_var_list (cp_parser *parser, enum omp_clause_code kind, tree list) return list; } +/* OpenACC 2.0: + copy ( variable-list ) + copyin ( variable-list ) + copyout ( variable-list ) + create ( variable-list ) + delete ( variable-list ) + present ( variable-list ) + present_or_copy ( variable-list ) + pcopy ( variable-list ) + present_or_copyin ( variable-list ) + pcopyin ( variable-list ) + present_or_copyout ( variable-list ) + pcopyout ( variable-list ) + present_or_create ( variable-list ) + pcreate ( variable-list ) */ + +static tree +cp_parser_oacc_data_clause (cp_parser *parser, pragma_omp_clause c_kind, + tree list) +{ + enum