[gomp4] OpenACC routine directive

Cesar Philippidis cesar@codesourcery.com
Mon Sep 15 23:35:00 GMT 2014


This patch adds initial support for the OpenACC routine directive. It's
not complete just yet because it doesn't implement any of the optional
clauses, except for the optional function/subroutine name. As such, it
doesn't go beyond marking functions with the "omp declare target" attribute.

According to the OpenACC technical committee, the routine clause will be
revised in the next OpenACC 2.x release. In particular, function
definitions must have an 'acc routine' associated with it. My
understanding is 'acc routine' should also be visible at the call site,
but if it's not the compiler can treat it as a regular function call.
Furthermore, I've been told that it's not sufficient to place the
routine directive in an interface block by itself. E.g.

  interface
    recursive function fact (x)
      !$acc routine
      integer, intent(in) :: x
      integer :: fact
    end function fact
  end interface
  integer, parameter :: n = 10
  integer :: a(n), i
  !$acc parallel
  !$acc loop
  do i = 1, n
     a(i) = fact (i)
  end do
  !$acc end parallel
  do i = 1, n
     write (*, "(I10)") a(i)
  end do
end
recursive function fact (x) result (res)
  integer, intent(in) :: x
  integer :: res
  if (x < 1) then
     res = 1
  else
     res = x * fact (x - 1)
  end if
end function fact

This will result in a runtime failure because gcc will not generate an
accelerated version of fact. The justification for this is that fortran
lacks a file scope, so 'acc routine' wouldn't be visible to fact.

Is this patch OK for gomp-4_0-branch?

Thanks,
Cesar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: routine-gomp4.diff
Type: text/x-patch
Size: 24405 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20140915/d96035a6/attachment.bin>


More information about the Fortran mailing list