[ HPF Home | Versions | Compilers | Projects | Publications | Applications | Benchmarks | Events | Contact ] |
This example performs only the initialization of the above example. It illustrates use of the LAYOUT("0DF77_ARRAY"0D) attribute to pass an HPF distributed array without remapping, as well as use of PASS_BY("0DHPF_HANDLE"0D) to pass an HPF-style descriptor or handle for use in the F77_LOCAL subgrid inquiry function. It also illustrates the addressing of data in terms of ``embedding arrays.''
PROGRAM EXAMPLE INTEGER, PARAMETER :: NX = 100, NY = 100 REAL, DIMENSION(NX,NY) :: Y !HPF$ DISTRIBUTE(BLOCK,BLOCK) :: Y ! Local subgrid parameters are declared per processor ! for a rank-two array INTEGER, DIMENSION(NUMBER_OF PROCESSORS(),2) :: & LB, UB, LB_EMBED, UB_EMBED !HPF$ DISTRIBUTE(BLOCK,*) :: LB, UB, LB_EMBED, UB_EMBED ! Define interfaces INTERFACE EXTRINSIC(F77_LOCAL) SUBROUTINE LOCAL1( & LB1, UB1, LB_EMBED1, UB_EMBED1, & LB2, UB2, LB_EMBED2, UB_EMBED2, X, X_DESC ) INTEGER, DIMENSION(:) :: & LB1, UB1, LB_EMBED1, UB_EMBED1, & LB2, UB2, LB_EMBED2, UB_EMBED2 ! By default, X is passed by reference REAL, DIMENSION(:,:), LAYOUT('HPF_ARRAY') :: X ! X_DESC is passed by its descriptor or 'handle' REAL, DIMENSION(:,:), LAYOUT('HPF_ARRAY'), & PASS_BY('HPF_HANDLE') :: X_DESC !HPF$ DISTRIBUTE(BLOCK) :: LB1, UB1, LB_EMBED1, UB_EMBED1 !HPF$ DISTRIBUTE(BLOCK) :: LB2, UB2, LB_EMBED2, UB_EMBED2 !HPF$ DISTRIBUTE(BLOCK,BLOCK) :: X END END INTERFACE ! Initialize values ! ( Assume stride = 1 and no axis permutation ) CALL HPF_SUBGRID_INFO( Y, IERR, & LB=LB, LB_EMBED=LB_EMBED, & UB=UB, UB_EMBED=UB_EMBED) IF (IERR.NE.0) STOP 'ERROR!' CALL LOCAL1( & LB(:,1), UB(:,1), LB_EMBED(:,1), UB_EMBED(:,1), & LB(:,2), UB(:,2), LB_EMBED(:,2), UB_EMBED(:,2), Y, Y ) END
SUBROUTINE LOCAL1( & LB1, UB1, LB_EMBED1, UB_EMBED1, & LB2, UB2, LB_EMBED2, UB_EMBED2, X, X_DESC ) ! The subgrid has been passed in its 'embedded' form REAL X ( LB_EMBED1 : UB_EMBED1 , LB_EMBED2 : UB_EMBED2 ) ! This argument is used only as input to inquiry functions INTEGER X_DESC ! Get the global extent of the first axis ! This is an HPF_LOCAL type of inquiry routine with an 'F77_' prefix CALL F77_GLOBAL_SIZE(NX,X_DESC,1) ! Otherwise, initialize elements of the array ! Loop only over actual array elements DO J = LB2, UB2 DO I = LB2, UB2 X(I,J) = I + (J-1) * NX END DO END DO END
©2000-2006 Rice University | [ Contact Us | HiPerSoft | Computer Science ] |