[ HPF Home | Versions | Compilers | Projects | Publications | Applications | Benchmarks | Events | Contact ] |
Next: Requirements on the
Up: Extrinsic Procedures
Previous: Overview
An explicit interface must be provided for each extrinsic procedure
entry in the scope where it is called, using an interface block. This
interface defines the ``HPF view'' of the extrinsic procedure.
XBNF
extrinsic-prefix -to -rule
to to is EXTRINSIC ( extrinsic-kind-keyword )
extrinsic-kind-keyword -to -rule
to to is HPF
-to or HPF_LOCAL
XBNF
An extrinsic-prefix may appear in a subroutine-stmt or function-stmt (as defined in the Fortran 90 standard) in the same
place that the keyword RECURSIVE might appear. See Section
for the extended forms of the grammar rules for function-stmt and
subroutine-stmt covering this case.
The extrinsic-kind-keyword indicates the kind of extrinsic interface
to be used. (It may be helpful to think of this name as being to the
subprogram calling interface what a KIND parameter is for
a numeric type. However, an extrinsic-kind is not integer-valued;
it is merely a keyword.) HPF defines two such keywords:
HPF and HPF_LOCAL. The keyword HPF_LOCAL is
intended for use in calling routines coded in the ``local HPF''
style described in Annex . The keyword HPF
refers to the interface normally used for calling ordinary HPF
routines. Thus writing EXTRINSIC(HPF) in an HPF program
has exactly the same effect as not using an EXTRINSIC
specifier at all.
A subprogram with an extrinsic interface lies outside the scope of HPF. However, explicit interfaces to such subprograms must conform to HPF. Note that any particular HPF implementation is free to support any selection of extrinsic kind keywords, or none at all except for HPF itself. Examples:
INTERFACE
EXTRINSIC(HPF_LOCAL) FUNCTION BAGEL(X)
REAL X(:)
REAL BAGEL(100)
!HPF ALIGN WITH X :: Y, Z
!HPF
DISTRIBUTE (BLOCK, BLOCK) X
END FUNCTION
END INTERFACE
INTERFACE KNISH
FUNCTION RKNISH(X) !normal HPF interface REAL X(:), RKNISH END RKNISH
EXTRINSIC(SISAL) FUNCTION CKNISH(X) !extrinsic interface COMPLEX X(:), CKNISH END CKNISH
END INTERFACE In the last interface block, two external procedures, one of them extrinsic and one not, are associated with the same generic procedure name, which returns a scalar of the same type as its array argument.
The intent is that a call to an extrinsic subprogram behaves, as observed by a calling program coded in HPF, exactly as if the subprogram has been coded in HPF.
For example, an implementation on a parallel processor may find it convenient to replicate scalar arguments so as to provide a copy on every processor. This is permitted so long as this process is invisible to the caller. One way to achieve this is to place a restriction on the programmer: on return from the subprogram, all the copies of this scalar argument must have the same value. This implies that if the dummy argument has INTENT(OUT), then all copies must have been updated consistently by the time of subprogram return. (End of advice to implementors.)
©2000-2006 Rice University | [ Contact Us | HiPerSoft | Computer Science ] |