Steps for using PDF optimization

Perform the following steps to use the PDF optimization:

  1. Compile your program with the IPA(PDF1) suboption. The OPTIMIZE(2) option, or preferably the OPTIMIZE(3) option should be specified for optimization. Pay special attention to the compiler options that are used to compile your program because the same options (other than IPA(PDF1)) should be used later.
  2. If you are using an MVS™ data set for your PDF file, preallocate the PDF data set using RECFM = U and LRECL = 0.
  3. Run the program built from step 1 with typical input data. The program records profiling information when it finishes. The program can be run multiple times with different input data sets, and the profiling information is accumulated to provide a count of how often branches are taken and blocks of code are executed, based on the input data sets used. It is critically important that the data used is representative of the data that will be used during a normal run of the finished program.
  4. It is recommended that you rebuild your program using the identical set of source files with the identical compiler options that you used in step 1, but change PDF1 to PDF2. This must be done with the same compiler release you use in step 1. In this second stage, the accumulated profiling information is used to fine-tune the optimizations. The resulting program does not contain profiling overhead.

    If you modify the source files, compiler options, or both that are used in step 1, you might see a list of warnings and the benefits from PDF might not apply for the changes from step 1.

    During the PDF2 phase, the compiler issues a message with a number in the range of 0 - 100. If you have not changed your program between the PDF1 and PDF2 phases, the number is 100, which means that all the profile data can be used to optimize the program. Otherwise, the number is less than 100. If the number is 0, it means that the profile data is completely outdated, and the compiler cannot take advantage of any information. Then you must recompile your program with the PDF1 option and regenerate the profile data.

    Note: If you specify the PDF1 or PDF2 option on the IPA Link step but not on the Compile step, the compiler issues a warning message. The message indicates that you must recompile your program to get all the profiling information.

Specifically, the following JCL can be used to perform a PDF1 compile of the hello world program (see Example 1. all C parts).

//USERID1A JOB (127A,0329),'$MEM$',                                    
//  MSGLEVEL=(2,0),MSGCLASS=S,CLASS=A,                                 
//  NOTIFY=USERID1,REGION=1024M                                        
//PROC JCLLIB ORDER=(CBC.SCCNPRC)                                      
//*--------------------------------------------------------------------
//* IPA compile step for hello1.c                                      
//*--------------------------------------------------------------------
//C001F336  EXEC EDCC,                                                 
//          INFILE='USERID1.IPA.SOURCE(HELLO1)',                       
//          OUTFILE='USERID1.IPA.OBJECT(HELLOX1),DISP=SHR',            
//          CPARM='OPTFILE(DD:OPTIONS)'                                
//OPTIONS  DD *                                                        
    IPA(NOOBJECT,PDF1) RENT LONG OPT(2) XPLINK GOFF                    
/*                                                                     
//*--------------------------------------------------------------------
//* IPA compile step for hello2.c                                      
//*--------------------------------------------------------------------
//C001F336  EXEC EDCC,                                                 
//          INFILE='USERID1.IPA.SOURCE(HELLO2)',                       
//          OUTFILE='USERID1.IPA.OBJECT(HELLOX2),DISP=SHR',            
//          CPARM='OPTFILE(DD:OPTIONS)'                                
//OPTIONS  DD *                                                        
    IPA(NOOBJECT,PDF1) RENT LONG OPT(2) XPLINK GOFF                    
/*                                                                     
//*--------------------------------------------------------------------
//* IPA compile step for hello3.c  
//*-------------------------------------------------------------------- 
//C001F336  EXEC EDCC,                                                  
//          INFILE='USERID1.IPA.SOURCE(HELLO3)',                        
//          OUTFILE='USERID1.IPA.OBJECT(HELLOX3),DISP=SHR',             
//          CPARM='OPTFILE(DD:OPTIONS)'                                 
//OPTIONS  DD *                                                         
    IPA(NOOBJECT,LIST,PDF1) RENT LONG OPT(2) XPLINK GOFF                
/*                                                                      
//*-------------------------------------------------------------------- 
//* IPA link step for the hello module                                  
//*-------------------------------------------------------------------- 
//C001F336  EXEC EDCXI,                                                 
//          OUTFILE='USERID1.IPALINK.OBJECT(HELLOXP),DISP=SHR',         
//          IPARM='OPTFILE(DD:OPTIONS)'                                 
//* The following line sets up an input file that just includes all     
//*   the IPA compile step object files.                                
//SYSIN  DD DATA,DLM='/>'                                               
  INCLUDE OBJECT(HELLOX1,HELLOX2,HELLOX3)                               
  INCLUDE SYSLIB(CELHS003,CELHS001)                                     
/>                                                                                                
//* These are the options used                                          
//OPTIONS  DD DATA,DLM='/>'                                             
    IPA(LINK,LEVEL(2),MAP,PDF1,PDFNAME(//'USERID1.MY.PDF'))             
    OPT(2) RENT LONGNAME LIST                                           
    XPLINK GOFF                                                         
/>                                                                      
//* The following line gives the object library                         
//OBJECT DD DSN=USERID1.IPA.OBJECT,DISP=SHR                             
//*-------------------------------------------------------------------- 
//* LINK the hello module                                              
//*--------------------------------------------------------------------
//C001F336  EXEC CCNXPD1B,                                             
//          INFILE='USERID1.IPALINK.OBJECT(HELLOXP)',                  
//          OUTFILE='USERID1.DEV.LOAD1(HELLOXP),DISP=SHR'  
Note: The PDF1 option is specified on each of the IPA compiles, and the PDFNAME suboption is specified on the IPA link step. This PDFNAME suboption gives the name of the file where the statistics about the program will be stored, this file is referred to as the PDF file. While it is not strictly required to preallocate the PDF file, when using a PS or PDS file, the data set may be required to preallocate to ensure the file is large enough. If the PDF file is preallocated, it should be allocated with an LRECL of 0 and a RECFM of U.

Finally, instead of using a traditional link proc, the link of the PDF1 code should be done with the CCNPD1B proc (for non-XPLINK code), the CCNXPD1B proc (for XPLINK code), or the CCNQPD1B proc for 64-bit code and linking. These procs provide all the libraries necessary to allow the object file created by the IPA link step to be linked with the PDF runtime function that stores the statistical information.

A PDF2 IPA compile job looks very similar to a PDF1 IPA compile job except that the: