[PATCH] Fix OpenACC vector_length parsing in fortran
Thomas Schwinge
thomas@codesourcery.com
Fri Jul 15 07:44:00 GMT 2016
Hi!
On Thu, 14 Jul 2016 19:05:52 -0700, Cesar Philippidis <cesar@codesourcery.com> wrote:
> The fortran FE is currently scanning for the vector clause before
> vector_length. That's a problem match_oacc_clause_gwv matches 'vector'
> without looking for whatever follows it. The correction I made here was
> to scan for vector_length before vector.
Does that me we (erroneously) accept any random junk after "vector",
"vector_length", and likely other clauses?
> --- a/gcc/fortran/openmp.c
> +++ b/gcc/fortran/openmp.c
> @@ -1338,6 +1338,11 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask,
> continue;
> break;
> case 'v':
> + if ((mask & OMP_CLAUSE_VECTOR_LENGTH)
> + && c->vector_length_expr == NULL
> + && (gfc_match ("vector_length ( %e )", &c->vector_length_expr)
> + == MATCH_YES))
> + continue;
> if ((mask & OMP_CLAUSE_VECTOR)
> && !c->vector
> && gfc_match ("vector") == MATCH_YES)
> @@ -1353,11 +1358,6 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask,
> needs_space = true;
> continue;
> }
> - if ((mask & OMP_CLAUSE_VECTOR_LENGTH)
> - && c->vector_length_expr == NULL
> - && (gfc_match ("vector_length ( %e )", &c->vector_length_expr)
> - == MATCH_YES))
> - continue;
> break;
Unless there's a more generic problem here (per my comment above), this
at least needs a source code comment added why "vector_length" needs to
be handled before "vector".
> --- /dev/null
> +++ b/gcc/testsuite/gfortran.dg/goacc/vector_length.f90
> @@ -0,0 +1,11 @@
> +program t
> + implicit none
> + integer, parameter :: n = 100
> + integer a(n), i
> +
> + !$acc parallel loop num_gangs(100) num_workers(1) vector_length(32)
> + do i = 1, n
> + a(i) = i
> + enddo
> + !$acc end parallel loop
> +end program t
My preference is that such tests are added to existing test files, for
example where "!$acc parallel loop" is tested, instead of adding such
mini files.
Grüße
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20160715/2419cd13/attachment.sig>
More information about the Fortran
mailing list