PGI Fortran Guide
Total Page:16
File Type:pdf, Size:1020Kb
PGI® User’s Guide Parallel Fortran, C and C++ for Scientists and Engineers The Portland Group® STMicroelectronics Two Centerpointe Drive Lake Oswego, OR 97035 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, Inc. and/or The Portland Group® and may be used or copied only in accordance with the terms of the license agreement ("EULA"). 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, Inc and/or The Portland Group®. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this manual, STMicroelectronics was aware of a trademark claim. The designations have been printed in caps or initial caps. PGF95, PGF90, and PGI Unified Binary are trademarks; and PGI, PGHPF, PGF77, PGCC, PGC++, PGI Visual Fortran, PVF, Cluster Development Kit, PGPROF, PGDBG, and The Portland Group are registered trademarks of The Portland Group Incorporated. PGI CDK is a registered trademark of STMicroelectronics. *Other brands and names are the property of their respective owners. PGI® User’s Guide Copyright © 1998 – 2000 The Portland Group, Inc. Copyright © 2000 – 2008 STMicroelectronics, Inc. All rights reserved. Printed in the United States of America First Printing: Release 1.7, Jun 1998 Second Printing: Release 3.0, Jan 1999 Third Printing: Release 3.1, Sep 1999 Fourth Printing: Release 3.2, Sep 2000 Fifth Printing: Release 4.0, May 2002 Sixth Printing: Release 5.0, Jun 2003 Seventh Printing: Release 5.1, Nov 2003 Eight Printing: Release 5.2, Jun 2004 Ninth Printing: Release 6.0, Mar 2005 Tenth Printing: Release 6.1, Dec 2005 Eleventh Printing: Release 6.2, Aug 2006 Twelfth printing: Release 7.0-1, December, 2006 Thirteenth printing: Release 7.1, October, 2007 Fourteenth printing: Release 7.2, May, 2008 Technical support: [email protected] Sales: [email protected] Web: www.pgroup.com Contents Preface .................................................................................................................................... xix Audience Description ............................................................................................................ xix Compatibility and Conformance to Standards ............................................................................ xix Organization ......................................................................................................................... xx Hardware and Software Constraints ........................................................................................ xxii Conventions ........................................................................................................................ xxii Related Publications ............................................................................................................ xxiv 1. Getting Started .................................................................................................................... 1 Overview ................................................................................................................................ 1 Invoking the Command-level PGI Compilers ............................................................................... 1 Command-line Syntax ...................................................................................................... 2 Command-line Options .................................................................................................... 3 Fortran Directives and C/C++ Pragmas .............................................................................. 3 Filename Conventions .............................................................................................................. 3 Input Files ..................................................................................................................... 3 Output Files ................................................................................................................... 5 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 ................................................................................................ 8 Using the PGI Compilers on Linux .................................................................................... 9 Using the PGI Compilers on Windows .............................................................................. 10 Using the PGI Compilers on SUA and SFU ........................................................................ 11 Using the PGI Compilers on Mac OS X ............................................................................. 11 Site-specific Customization of the Compilers .............................................................................. 12 Using siterc Files ........................................................................................................... 12 Using User rc Files ........................................................................................................ 12 Common Development Tasks .................................................................................................. 13 2. Using Command Line Options ....................................................................................... 15 iii Command Line Option Overview ............................................................................................. 15 Command-line Options Syntax ......................................................................................... 15 Command-line Suboptions .............................................................................................. 16 Command-line Conflicting Options ................................................................................... 16 Help with Command-line Options ............................................................................................ 16 Getting Started with Performance ............................................................................................ 17 Using –fast and –fastsse Options ..................................................................................... 18 Other Performance-related Options ................................................................................. 18 Targeting Multiple Systems - Using the -tp Option ...................................................................... 19 Frequently-used Options ......................................................................................................... 19 3. Using Optimization & Parallelization .......................................................................... 21 Overview of Optimization ....................................................................................................... 21 Local Optimization ........................................................................................................ 22 Global Optimization ....................................................................................................... 22 Loop Optimization: Unrolling, Vectorization, and Parallelization ........................................... 22 Interprocedural Analysis (IPA) and Optimization .............................................................. 22 Function Inlining ........................................................................................................... 22 Profile-Feedback Optimization (PFO) .............................................................................. 22 Getting Started with Optimizations ........................................................................................... 23 Local and Global Optimization using -O .................................................................................. 24 Scalar SSE Code Generation ............................................................................................ 26 Loop Unrolling using –Munroll ............................................................................................... 27 Vectorization using –Mvect ..................................................................................................... 28 Vectorization Sub-options ............................................................................................... 28 Vectorization Example Using SSE/SSE2 Instructions ............................................................ 30 Auto-Parallelization using -Mconcur ........................................................................................