next up previous contents
Next: Special Considerations for HPF_SERIAL Up: HPF Bindings Previous: Additional Special Considerations for

Argument Association

If a dummy argument of an EXTRINSIC("0DHPF"0D,"0DLOCAL"0D) routine is a scalar, then the corresponding dummy argument of the local procedure must be a scalar of the same type and type parameters. Only scalars of intrinsic types, or of derived types that are not explicitly mapped, may be passed from a global to an HPF_LOCAL routine. When the extrinsic procedure is invoked, the local procedure is passed an argument that consists of a local copy of the scalar. This copy will be a valid HPF scalar.

If a dummy argument of an EXTRINSIC("0DHPF"0D,"0DLOCAL"0D) routine is an array, then the corresponding dummy argument in the specification of the local procedure must be an array of the same rank, type, and type parameters.

If the array is sequential in the extrinsic interface, the corresponding actual argument will be passed by replicatation on all processors, just as scalar arguments are passed. Each local dummy argument will be associated with a full copy of the actual array argument. The dummy argument in the extrinsic interface and the corresponding dummy argument in the specification of the local procedure may be declared with the same explicit shape. All sequential dummy arguments passed by replication to an EXTRINSIC("0DHPF"0D,"0DLOCAL"0D) procedure must either be INTENT(IN) arguments or should be updated consistently across processors.

If the dummy argument is a nonsequential array, then, when the extrinsic procedure is invoked, the local dummy argument is associated with the local array that consists of the subgrid of the global array that is stored locally. This local array will be a valid HPF array.

If an EXTRINSIC("0DHPF"0D,"0DLOCAL"0D) routine is a function, then the local procedure is a function that returns a scalar of the same type and type parameters as the HPF extrinsic function. The value returned by each local invocation must be the same.

Each physical processor has at most one copy of each HPF variable.

Consider the following extrinsic interface:

  INTERFACE
    EXTRINSIC('HPF','LOCAL') FUNCTION MATZOH(X, Y) RESULT(Z)
      REAL, DIMENSION(:,:) :: X
      REAL, DIMENSION(:) :: Y
      REAL Z
      !HPF$ ALIGN WITH X(:,*) :: Y(:)
        ! note that this asserts that size(Y) = size(X,1)
      !HPF$ DISTRIBUTE X(BLOCK, CYCLIC)
    END FUNCTION
  END INTERFACE

The corresponding local HPF procedure is specified as follows.

EXTRINSIC('HPF','LOCAL') FUNCTION MATZOH(XX, YY) RESULT(ZZ)
  REAL, DIMENSION(:,:) :: XX
  REAL, DIMENSION(5:) :: YY ! assumed shape with lower bound of 5
  REAL ZZ
  NX1 = SIZE(XX, 1)
  LX1 = LBOUND(XX, 1)
  UX1 = UBOUND(XX, 1)
  NX2 = SIZE(XX, 2)
  LX2 = LBOUND(XX, 2)
  UX2 = UBOUND(XX, 2)
  NY  = SIZE(YY, 1)
  LY  = LBOUND(YY, 1)
  UY  = UBOUND(YY, 1)
  ...
END FUNCTION

Assume that the function is invoked with an actual (global) array X of shape and an actual vector Y of length on a 4-processor machine, using a processor arrangement (assuming one abstract processor per physical processor).

Then each local invocation of the function MATZOH receives the following actual arguments:

Processor (1,1)          Processor (1,2)
X(1,1)  X(1,3)             X(1,2)
X(2,1)  X(2,3)             X(2,2)
Y(1)                       Y(1)
Y(2)                       Y(2)

Processor (2,1)          Processor (2,2)
X(3,1)  X(3,3)             X(3,2)
Y(3)                       Y(3)

Here are the values to which each processor would set NX1, LX1, UX1, NX2, LX2, UX2, NY, LY, and UY:

Processor (1,1)          Processor (1,2)
NX1=2  LX1=1  UX1=2      NX1=2  LX1=1  UX1=2
NX2=2  LX2=1  UX2=2      NX2=1  LX2=1  UX2=1
NY=2   LY=5   UY=6       NY=2   LY=5   UY=6

Processor (2,1)
NX1=2  LX1=1  UX1=2      NX1=2  LX1=1  UX1=2
NX2=2  LX2=1  UX2=2      NX2=1  LX2=1  UX2=1
NY=1   LY=5   UY=5       NY=1   LY=5   UY=5

An actual argument to an extrinsic procedure may be a pointer. Since the corresponding dummy argument may not have the POINTER attribute, the dummy argument becomes associated with the target of the HPF global pointer. In no way may a local pointer become pointer associated with a global HPF target. Therefore, an actual argument may not be of a derived-type containing a pointer component.

Other inquiry intrinsics, such as ALLOCATED or PRESENT, should also behave as expected. Note that when a global array is passed to a local routine, some processors may receive an empty set of elements.


next up previous contents
Next: Special Considerations for HPF_SERIAL Up: HPF Bindings Previous: Additional Special Considerations for