7.4.1 Inlining Example - Same Source File

The following example demonstrates inlining both with /inline=setup , meaning only the subroutine setup will be inlined, and with /inline , meaning both subroutines are inlined. The KAP output includes optimized versions of both routines, in addition to the expanded main program. Setting /inline_looplevel>2 is required, since one CALL is in a loop and one is not.

Source file:
   PROGRAM TSTEXP
   REAL A(200,200),B(200,200),C(200,200)
   CALL SETUP(B,200)
   CALL SETUP(C,200)
   DO 100  N = 25,200,25
   CALL MXMR(N,A,B,C)
   WRITE(*,900) N,A(7,13)
100 CONTINUE
900 FORMAT(1X,'For N=',I5,',  A(7,13):',F12.4)
   END

   SUBROUTINE SETUP(E,N)
   REAL E(N,N)
   DO 10 I=1,N
      DO 10 J=1,N
        E(I,J) = MOD( I + 7*J, 10) /10.0
    10 CONTINUE
       RETURN
       END

   SUBROUTINE MXMR(N,A,B,C)
   REAL A(200,200),B(200,200),C(200,200)
   DO 1000 I=1,N
     DO 1000 J=1,N
         A(I,J) = 0.0
           DO 1000 K=1,N
             A(I,J)=A(I,J)+B(I,K)*C(K,J)
   1000 CONTINUE
        RETURN
        END

The /inline=setup qualifier generates the following main program:

PROGRAM TSTEXP
  REAL A(200,200),B(200,200),C(200,200)
  INTEGER II1, II2, II3, II4
  DO 2 II1=1,200
  DO 2 II2=1,200
  B(II1,II2) = MOD (II1 + 7 * II2, 10) / 10.0
2 CONTINUE
  DO 3 II3=1,200
  DO 3 II4=1,200
  C(II3,II4) = MOD (II3 + 7 * II4, 10) / 10.0
3 CONTINUE
 DO 100 N=25,200,25
   CALL MXMR(N,A,B,C)
   WRITE(*,900) N,A(7,13)
100 CONTINUE
900 FORMAT(1X,'For N=',I5,',  A(7,13):',F12.4)
  END

The /inline qualifier generates the following output:

PROGRAM TSTEXP
  REAL A(200,200),B(200,200),C(200,200)
  INTEGER II1, II2, II3, II4, II5, II6, II7
  DO 3 II4=1,200
  DO 3 II5=1,200
  B(II4,II5) = MOD (II4 + 7 * II5, 10) / 10.0
3 CONTINUE
  DO 4 II6=1,200
  DO 4 II7=1,200
  C(II6,II7) = MOD (II6 + 7 * II7, 10) / 10.0
4 CONTINUE
  DO 100 N=25,200,25
  DO 2 II1=1,N
  DO 2 II2=1,N
  A(II1,II2) = 0.0
  DO 2 II3=1,N
  A(II1,II2) = A(II1,II2) + B(II1,II3) * C(II3,II2)
2 CONTINUE
  WRITE (*, 900) N, A(7,13)
100 CONTINUE
900 FORMAT(1X,'For N=',I5,',  A(7,13):',F12.4)
  END


Previous Page | Next Page | Contents | Index |
Command-Line Qualifiers