The Portland Group

Total Page:16

File Type:pdf, Size:1020Kb

The Portland Group ® 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
Recommended publications
  • C and C++ Preprocessor Directives #Include #Define Macros Inline
    MODULE 10 PREPROCESSOR DIRECTIVES My Training Period: hours Abilities ▪ Able to understand and use #include. ▪ Able to understand and use #define. ▪ Able to understand and use macros and inline functions. ▪ Able to understand and use the conditional compilation – #if, #endif, #ifdef, #else, #ifndef and #undef. ▪ Able to understand and use #error, #pragma, # and ## operators and #line. ▪ Able to display error messages during conditional compilation. ▪ Able to understand and use assertions. 10.1 Introduction - For C/C++ preprocessor, preprocessing occurs before a program is compiled. A complete process involved during the preprocessing, compiling and linking can be read in Module W. - Some possible actions are: ▪ Inclusion of other files in the file being compiled. ▪ Definition of symbolic constants and macros. ▪ Conditional compilation of program code or code segment. ▪ Conditional execution of preprocessor directives. - All preprocessor directives begin with #, and only white space characters may appear before a preprocessor directive on a line. 10.2 The #include Preprocessor Directive - The #include directive causes copy of a specified file to be included in place of the directive. The two forms of the #include directive are: //searches for header files and replaces this directive //with the entire contents of the header file here #include <header_file> - Or #include "header_file" e.g. #include <stdio.h> #include "myheader.h" - If the file name is enclosed in double quotes, the preprocessor searches in the same directory (local) as the source file being compiled for the file to be included, if not found then looks in the subdirectory associated with standard header files as specified using angle bracket. - This method is normally used to include user or programmer-defined header files.
    [Show full text]
  • PGI Fortran Guide
    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.
    [Show full text]
  • Guide to C Files and H Files by Jacob “Bob” Egner Introduction This
    Guide To C Files And H Files by Jacob “Bob” Egner Introduction This document explains the philosophy of C and H files, and what to put in each file type. At times, I'll stray from the main topic to talk about C compilation in general. The more you understand about C compilation, the less trouble you'll have getting your programs to compile and work. Along with this document, you should also have the files heap.h, heap.c, and heap_test.c. This project can be found in the starter files section of the web site. heap.c and heap.h make up a “module” that implements a memory heap. heap_test.c uses the heap module. I wrote these files to be examples for this document, bring dynamic memory management to the 9S12, and mostly for fun. Please glance over these files before proceeding. The project can be found in the “Starter files” section of the course web site. Why Do We Have H Files? One key thing in understanding C and H files is that declaration and definition are two different things. A declaration tells the compiler that something exists and what kind of beast it is. A definition tells the compiler what it is. A function declaration tells the name of a function, what arguments it takes and what it returns. A function definition also has all that and the code that implements the function. A variable declaration tells the type of a variable. A variable definition tells the type and actually allocates space for the variable.
    [Show full text]
  • Absoft Pro Fortran User Guide
    Pro Fortran Windows™ User Guide For 32-bit and 64-bit Windows Pro Fortran Windows™ User Guide For 32-bit and 64-bit Windows 2111 Cass Lake Road, Suite 102 Troy, MI 48084 U.S.A. Tel (248) 220-1190 Fax (248) 220-1194 [email protected] All rights reserved. No part of this publication may be reproduced or used in any form by any means, without the prior written permission of Absoft Corporation. THE INFORMATION CONTAINED IN THIS PUBLICATION IS BELIEVED TO BE ACCURATE AND RELIABLE. HOWEVER, ABSOFT CORPORATION MAKES NO REPRESENTATION OF WARRANTIES WITH RESPECT TO THE PROGRAM MATERIAL DESCRIBED HEREIN AND SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE. FURTHER, ABSOFT RESERVES THE RIGHT TO REVISE THE PROGRAM MATERIAL AND MAKE CHANGES THEREIN FROM TIME TO TIME WITHOUT OBLIGATION TO NOTIFY THE PURCHASER OF THE REVISION OR CHANGES. IN NO EVENT SHALL ABSOFT BE LIABLE FOR ANY INCIDENTAL, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE PURCHASER'S USE OF THE PROGRAM MATERIAL. U.S. GOVERNMENT RESTRICTED RIGHTS — The software and documentation are provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the Government is subject to restrictions set forth in subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer Software clause at 252.227-7013. The contractor is Absoft Corporation, 2111 Cass Lake Rd, Suite 102, Keego Harbr, Michigan 48320. ABSOFT CORPORATION AND ITS LICENSOR(S) MAKE NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE SOFTWARE.
    [Show full text]
  • Javaserver Pages™ (JSP™) V1.2 Syntax Reference
    JavaServer Pages™ (JSP™) v1.2 Syntax Reference <jsp:root> Defines standard elements and namespace attributes of tag libraries. Hidden Comment Documents the JSP page but is not inserted into the response. Declaration Declares a variable or method valid in the scripting language used in the page. Expression Contains an expression valid in the scripting language used in the page. Scriptlet Contains a code fragment valid in the scripting language used in the page. <jsp:text> Encloses template data. Include Directive Includes a resource of text or code when the JSP page is translated. Page Directive Defines attributes that apply to an entire JSP page. Taglib Directive Defines a tag library and prefix for the custom tags used in the JSP page. <jsp:forward> Forwards a request to an HTML file, JSP page, or servlet. <jsp:getProperty> Inserts the value of a bean property into the response. <jsp:include> Includes a static resource or the result from another web component <jsp:plugin> Causes the execution of an applet or bean. The applet or bean executes in the specified plugin. If the plugin is not available, the client displays a dialog to initiate the download of the plugin software. <jsp:setProperty> Sets a bean property value or values. <jsp:useBean> Instantiates or references a bean with a specific name and scope. 1 Preface All tags are case sensitive. A pair of single quotes is equivalent to a pair of double quotes. Spaces are not allowed between an equals sign and an attribute value. The elements in a JSP page can be expressed in JSP syntax or XML syntax.
    [Show full text]
  • Section “Common Predefined Macros” in the C Preprocessor
    The C Preprocessor For gcc version 12.0.0 (pre-release) (GCC) Richard M. Stallman, Zachary Weinberg Copyright c 1987-2021 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation. A copy of the license is included in the section entitled \GNU Free Documentation License". This manual contains no Invariant Sections. The Front-Cover Texts are (a) (see below), and the Back-Cover Texts are (b) (see below). (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Table of Contents 1 Overview :::::::::::::::::::::::::::::::::::::::: 1 1.1 Character sets:::::::::::::::::::::::::::::::::::::::::::::::::: 1 1.2 Initial processing ::::::::::::::::::::::::::::::::::::::::::::::: 2 1.3 Tokenization ::::::::::::::::::::::::::::::::::::::::::::::::::: 4 1.4 The preprocessing language :::::::::::::::::::::::::::::::::::: 6 2 Header Files::::::::::::::::::::::::::::::::::::: 7 2.1 Include Syntax ::::::::::::::::::::::::::::::::::::::::::::::::: 7 2.2 Include Operation :::::::::::::::::::::::::::::::::::::::::::::: 8 2.3 Search Path :::::::::::::::::::::::::::::::::::::::::::::::::::: 9 2.4 Once-Only Headers::::::::::::::::::::::::::::::::::::::::::::: 9 2.5 Alternatives to Wrapper #ifndef ::::::::::::::::::::::::::::::
    [Show full text]
  • The Portland Group
    ® PGI Compiler Reference Manual 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 Reference Manual 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.3, March 2011 Fourth Printing: Release 2011, 11.4, April 2011 Fifth Printing: Release 2011, 11.5, May 2011 Technical support: [email protected] Sales: [email protected] Web: www.pgroup.com ID: 111162228 Contents Preface .....................................................................................................................................
    [Show full text]
  • The Portland Group
    PGI Visual Fortran® 2013 Installation Guide Version 13.5 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 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. PVF® Installation Guide Copyright © 2010-2013 STMicroelectronics, Inc. All rights reserved. Printed in the United States of America First Printing: Release 2013, version 13.1, January 2013 Second Printing: Release 2013, version 13.2, February 2013 Third Printing: Release 2013, version 13.3, March 2013 Fourth Printing: Release 2013, version 13.4, April 2013 Fourth Printing: Release 2013, version 13.5, May 2013 Technical support: [email protected] Sales: [email protected] Web: www.pgroup.com ID: 07183206 Contents 1.
    [Show full text]
  • The Portland Group
    PGI® 2013 Release Notes Version 13.3 The Portland Group While every precaution has been taken in the preparation of this document, The Portland Group® (PGI®) 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 The Portland Group and/or its licensors 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, PGI Unified Binary, and PGCL 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 The Portland Group, Inc. PGI® 2013 Release Notes Copyright © 2013 The Portland Group, Inc. and STMicroelectronics, Inc. All rights reserved. Printed in the United States of America First Printing: Release 2013, version 13.1, January 2013 Second Printing: Release 2013, version 13.2, February 2013 Third Printing: Release 2013, version 13.3, March 2013 Technical support: [email protected] Sales: [email protected] Web: www.pgroup.com ID: 07135184 Contents 1.
    [Show full text]
  • ILE C/C++ Programmer's Guide
    IBM i 7.2 Programming IBM Rational Development Studio for i ILE C/C++ Programmer's Guide IBM SC09-2712-07 Note Before using this information and the product it supports, read the information in “Notices” on page 441. This edition applies to version 7, release 2, modification 0 of IBM Rational Development Studio for i (product number 5770-WDS) and to all subsequent releases and modifications until otherwise indicated in new editions. This version does not run on all reduced instruction set computer (RISC) models nor does it run on CISC models. This document may contain references to Licensed Internal Code. Licensed Internal Code is Machine Code and is licensed to you under the terms of the IBM License Agreement for Machine Code. © Copyright International Business Machines Corporation 1993, 2013. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents ILE C/C++ Programmer’s Guide..............................................................................1 PDF file for ILE C/C++ Programmer’s Guide............................................................................................... 3 About ILE C/C++ Programmer's Guide........................................................................................................5 Install Licensed Program Information................................................................................................... 5 Notes About Examples..........................................................................................................................
    [Show full text]
  • Who Knew You Could Do That with RPG IV? Modern RPG for the Modern Programmer
    Front cover Who Knew You Could Do That with RPG IV? Modern RPG for the Modern Programmer Rich Diedrich Jim Diephuis Susan Gantner Jeff Minette Jon Paris Kody Robinson Tim Rowe Paul Tuohy Redbooks International Technical Support Organization Who Knew You Could Do That with RPG IV? Modern RPG for the Modern Programmer December 2016 SG24-5402-01 Note: Before using this information and the product it supports, read the information in “Notices” on page ix. Second Edition (December 2016) This edition applies to Version 7, Release 2, Modification 0, Technology Refresh 1 of IBM i (5770-SS1) and IBM Rational Development Studio for i (5770-WDS). © Copyright International Business Machines Corporation 2000, 2016. All rights reserved. Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Notices . ix Trademarks . .x Preface . xi Authors. xi Now you can become a published author, too! . xiv Comments welcome. xiv Stay connected to IBM Redbooks . .xv Chapter 1. Introduction to RPG IV . 1 1.1 Why update this book on RPG IV now? . 3 1.2 Evolution of the RPG IV language . 3 1.2.1 Examples in this book are based on IBM i 7.2 . 7 1.3 The future for RPG IV . 7 1.3.1 A future for RPG programmers . 7 1.4 A roadmap. 8 1.4.1 Step 1: RPG IV and RDi . 8 1.4.2 Step 2: Modularization by using ILE . 9 1.4.3 Step 3: Using database features. 9 1.4.4 Step 4: Modernizing the user interface .
    [Show full text]
  • Tuning C++ Applications for the Latest Generation X64 Processors with PGI Compilers and Tools
    Tuning C++ Applications for the Latest Generation x64 Processors with PGI Compilers and Tools Douglas Doerfler and David Hensinger Sandia National Laboratories Brent Leback and Douglas Miles The Portland Group (PGI) ABSTRACT: At CUG 2006, a cache oblivious implementation of a two dimensional Lagrangian hydrodynamics model of a single ideal gas material was presented. This paper presents further optimizations to this C++ application to allow packed, consecutive-element storage of vectors, some restructuring of loops containing neighborhood operations, and adding type qualifiers to some C++ pointer declarations to improve performance. In addition to restructuring of the application, analysis of the compiler-generated code resulted in improvements to the latest PGI C++ compiler in the area of loop-carried redundancy elimination, resolution of pointer aliasing conflicts, and vectorization of loops containing min and max reductions. These restructuring and compiler optimization efforts by PGI and Sandia have resulted in application speedups of 1.25 to 1.80 on the latest generation of x64 processors. KEYWORDS: Compiler, C, C++, Optimization, Vectorization, Performance Analysis, AMD Opteron™, Intel Core™ 2, Micro-architecture vector or SIMD units to increase FLOP rates in general 1. Introduction purpose processors. While first-generation AMD and Intel 64-bit x86 Although modern compilers do an admirable job of (x64) processors contain 128-bit wide Streaming SIMD optimization when provided with nothing other than the Extensions (SSE) registers, their 64-bit data paths and “–fast” switch, many times there are still significant floating-point units limit the performance benefit of performance gains to be obtained with detailed analysis vectorizing double-precision loops.
    [Show full text]