From: Cesar Philippidis <cesar@codesourcery.com>
To: <mexas@bris.ac.uk>, <fortran@gcc.gnu.org>
Subject: Re: gfortran6 with OpenACC - error
Date: Tue, 26 Apr 2016 15:16:00 -0000 [thread overview]
Message-ID: <571F8652.7080503@codesourcery.com> (raw)
In-Reply-To: <201604261508.u3QF8Edn008744@mech-as222.men.bris.ac.uk>
On 04/26/2016 08:08 AM, Anton Shterenlikht wrote:
> gfortran 6.0.0 20160410 on linux.
> Compiling with *no* -fopenacc works fine,
> and the serial program runs as expected.
> Compiling with -fopenacc gives an error.
> Am I using OpenACC directives wrongly?
>
> newblue4> cat z.f90
> program z
> implicit none
> integer, parameter :: d1 = 1000, d2 = 1000
> real :: tmp( (d1-2) *(d2-2) )
> real, allocatable :: arr(:,:), old(:,:)
> integer :: i,j,k
>
> ! allocate and set all to zero
> allocate( arr(d1,d2), source = 0.0 )
> allocate( old(d1,d2) )
>
> ! set inner cells to random numbers
> call random_number(tmp)
> arr( 2:d1-1 , 2:d2-1 ) = reshape( tmp, (/ d1-2, d1-2 /) )
>
> !$acc data copy(arr)
> write (*,*) "before:", sum(abs(arr))
>
> do i=1,1000
> old = arr
>
> !$acc kernels
> do j=2,d1-1
> do k=2,d2-1
> arr(j,k) = 0.25 * ( old(j-1,k) + old(j+1,k) + old(j,k-1) + old(j,k+1) )
> end do
> end do
> !$acc end kernels
>
> end do
>
> write (*,*) "after:", sum(abs(arr))
>
> end program z
> newblue4>
>
> newblue4> gfortran -O2 z.f90 -Wall -o gfort-acc.x
> newblue4> time ./gfort-acc.x
> before: 497871.688
> after: 464004.844
> 9.102u 0.006s 0:09.13 99.6% 0+0k 0+0io 0pf+0w
> newblue4>
>
> newblue4> gfortran -fopenacc -O2 z.f90 -Wall -o gfort-acc.x
> z.f90:34:3:
>
> end program z
> 1
> Error: Unexpected END statement at (1)
> f951: Error: Unexpected end of file in ‘z.f90’
> newblue4>
This program missing an "!$acc end data" to mark the end of the data region.
Cesar
next prev parent reply other threads:[~2016-04-26 15:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-26 15:08 Anton Shterenlikht
2016-04-26 15:16 ` Cesar Philippidis [this message]
2016-04-26 15:37 ` Anton Shterenlikht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=571F8652.7080503@codesourcery.com \
--to=cesar@codesourcery.com \
--cc=fortran@gcc.gnu.org \
--cc=mexas@bris.ac.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).