The Portland Group
Total Page:16
File Type:pdf, Size:1020Kb
® PGI Compiler User's Guide Parallel Fortran, C and C++ for Scientists and Engineers Release 2011 The Portland Group While every precaution has been taken in the preparation of this document, The Portland Group® (PGI®), a wholly-owned subsidiary of STMicroelectronics, Inc., makes no warranty for the use of its products and assumes no responsibility for any errors that may appear, or for damages resulting from the use of the information contained herein. The Portland Group retains the right to make changes to this information at any time, without notice. The software described in this document is distributed under license from STMicroelectronics and/or The Portland Group and may be used or copied only in accordance with the terms of the end-user license agreement ("EULA"). PGI Workstation, PGI Server, PGI Accelerator, PGF95, PGF90, PGFORTRAN, and PGI Unified Binary are trademarks; and PGI, PGHPF, PGF77, PGCC, PGC++, PGI Visual Fortran, PVF, PGI CDK, Cluster Development Kit, PGPROF, PGDBG, and The Portland Group are registered trademarks of The Portland Group Incorporated. Other brands and names are property of their respective owners. No part of this document may be reproduced or transmitted in any form or by any means, for any purpose other than the purchaser's or the end user's personal use without the express written permission of STMicroelectronics and/or The Portland Group. PGI® Compiler User’s Guide Copyright © 2010-2011 STMicroelectronics, Inc. All rights reserved. Printed in the United States of America First Printing: Release 2011, 11.0, December, 2010 Second Printing: Release 2011, 11.1, January, 2011 Third Printing: Release 2011, 11.2, February, 2011 Fourth Printing: Release 2011, 11.3, March, 2011 Fourth Printing: Release 2011, 11.4, April, 2011 Technical support: [email protected] Sales: [email protected] Web: www.pgroup.com ID: 1196151 Contents Preface ...................................................................................................................................... xv Audience Description ............................................................................................................. xv Compatibility and Conformance to Standards ............................................................................. xv Organization ......................................................................................................................... xvi Hardware and Software Constraints ........................................................................................ xvii Conventions ......................................................................................................................... xvii Related Publications .............................................................................................................. xix 1. Getting Started .................................................................................................................... 1 Overview ................................................................................................................................ 1 Invoking the Command-level PGI Compilers ............................................................................... 2 Command-line Syntax ...................................................................................................... 2 Command-line Options .................................................................................................... 3 Fortran Directives and C/C++ Pragmas .............................................................................. 3 Filename Conventions .............................................................................................................. 4 Input Files ..................................................................................................................... 4 Output Files ................................................................................................................... 6 Fortran, C, and C++ Data Types ............................................................................................... 7 Parallel Programming Using the PGI Compilers ........................................................................... 7 Running SMP Parallel Programs ...................................................................................... 8 Running Data Parallel HPF Programs ................................................................................. 8 Platform-specific considerations ................................................................................................ 9 Using the PGI Compilers on Linux .................................................................................... 9 Using the PGI Compilers on Windows .............................................................................. 10 PGI on the Windows Desktop ......................................................................................... 12 Using the PGI Compilers on Mac OS X ............................................................................. 13 Site-specific Customization of the Compilers .............................................................................. 14 Using siterc Files ........................................................................................................... 14 Using User rc Files ........................................................................................................ 14 Common Development Tasks .................................................................................................. 15 2. Using Command Line Options ....................................................................................... 17 Command Line Option Overview ............................................................................................. 17 iii Command-line Options Syntax ......................................................................................... 17 Command-line Suboptions .............................................................................................. 18 Command-line Conflicting Options ................................................................................... 18 Help with Command-line Options ............................................................................................ 18 Getting Started with Performance ............................................................................................ 20 Using –fast and –fastsse Options ..................................................................................... 20 Other Performance-related Options ................................................................................. 21 Targeting Multiple Systems - Using the -tp Option ...................................................................... 21 Frequently-used Options ......................................................................................................... 21 3. Optimizing & Parallelizing ............................................................................................ 23 Overview of Optimization ....................................................................................................... 24 Local Optimization ........................................................................................................ 24 Global Optimization ....................................................................................................... 24 Loop Optimization: Unrolling, Vectorization, and Parallelization ........................................... 24 Interprocedural Analysis (IPA) and Optimization .............................................................. 24 Function Inlining ........................................................................................................... 24 Profile-Feedback Optimization (PFO) .............................................................................. 25 Getting Started with Optimizations ........................................................................................... 25 Common Compiler Feedback Format (CCFF) ............................................................................ 27 Local and Global Optimization using -O .................................................................................. 27 Scalar SSE Code Generation ............................................................................................ 28 Loop Unrolling using –Munroll ............................................................................................... 29 Vectorization using –Mvect ..................................................................................................... 30 Vectorization Sub-options ............................................................................................... 31 Vectorization Example Using SSE/SSE2 Instructions ............................................................ 32 Auto-Parallelization using -Mconcur ......................................................................................... 35 Auto-parallelization Sub-options ...................................................................................... 35 Loops That Fail to Parallelize ......................................................................................... 36 Processor-Specific Optimization & the Unified Binary ................................................................. 39 Interprocedural Analysis and Optimization using –Mipa .............................................................. 39 Building a Program Without