
IBM XL C/C++ for Linux, V13.1.6 IBM Optimization and Programming Guide for Little Endian Distributions Version 13.1.6 SC27-6560-05 IBM XL C/C++ for Linux, V13.1.6 IBM Optimization and Programming Guide for Little Endian Distributions Version 13.1.6 SC27-6560-05 Note Before using this information and the product it supports, read the information in “Notices” on page 117. First edition This edition applies to IBM XL C/C++ for Linux, V13.1.6 (Program 5765-J08; 5725-C73) and to all subsequent releases and modifications until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. © Copyright IBM Corporation 1996, 2017. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About this document ......... v An intermediate step: adding -qhot suboptions at Who should read this document........ v level 3 ............... 26 How to use this document.......... v Optimizing at level 4 .......... 26 How this document is organized ....... v Optimizing at level 5 .......... 27 Conventions .............. vi Tuning for your system architecture ...... 28 Related information ............ ix Getting the most out of target machine options 28 Available help information ........ ix Using high-order loop analysis and transformations 29 Standards and specifications ........ xi Getting the most out of -qhot ....... 30 Other IBM information.......... xi Using shared-memory parallelism (SMP) .... 31 Other information ........... xi Getting the most out of -qsmp ....... 32 Technical support ............ xi Using interprocedural analysis ........ 33 How to send your comments ........ xii Getting the most from -qipa ........ 35 Using profile-directed feedback ........ 36 Chapter 1. Using XL C/C++ with Fortran 1 Compiling with -qpdf1 ......... 36 Training with typical data sets ....... 37 Identifiers ............... 1 Recompiling or linking with -qpdf2 ..... 40 Corresponding data types .......... 2 Marking variables as local or imported ..... 43 Character and aggregate data ......... 4 Getting the most out of -qdatalocal ..... 44 Function calls and parameter passing ...... 4 Using compiler reports to diagnose optimization Pointers to functions............ 5 opportunities .............. 45 Sample program: C/C++ calling Fortran ..... 5 Parsing compiler reports with development tools 47 Other optimization options ......... 47 Chapter 2. Aligning data........ 7 Using alignment modes........... 7 Chapter 6. Debugging optimized code 49 Alignment of aggregates ......... 8 Detecting errors in code .......... 49 Alignment of bit-fields .......... 9 Understanding different results in optimized Using alignment modifiers ......... 10 programs ............... 50 Debugging in the presence of optimization .... 51 Chapter 3. Handling floating-point operations ............. 13 Chapter 7. Coding your application to Floating-point formats ........... 13 improve performance ........ 53 Handling multiply-and-add operations ..... 13 Finding faster input/output techniques ..... 53 Compiling for strict IEEE conformance ..... 14 Reducing function-call overhead ....... 53 Handling floating-point constant folding and Managing memory efficiently (C++ only) .... 55 rounding ............... 14 Optimizing variables ........... 55 Matching compile-time and runtime rounding Manipulating strings efficiently ........ 56 modes ............... 15 Optimizing expressions and program logic .... 56 Handling floating-point exceptions ...... 16 Optimizing operations in 64-bit mode ..... 57 The C++ template model .......... 58 Chapter 4. Constructing a library ... 17 Using delegating constructors (C++11) ..... 58 Compiling and linking a library ....... 17 Using rvalue references (C++11) ....... 59 Compiling a static library......... 17 Using visibility attributes (IBM extension) .... 61 Compiling a shared library ........ 17 Types of visibility attributes ........ 62 Linking a library to an application...... 17 Rules of visibility attributes ........ 63 Linking a shared library to another shared library 18 Propagation rules (C++ only) ....... 69 Initializing static objects in libraries (C++) .... 18 Specifying visibility attributes using the -fvisibility option .......... 71 Chapter 5. Optimizing your applications 21 Specifying visibility attributes using pragma Distinguishing between optimization and tuning .. 21 preprocessor directives ......... 71 Steps in the optimization process ....... 22 Basic optimization ............ 22 Chapter 8. Exploiting POWER9 Optimizing at level 0 .......... 22 technology ............. 75 Optimizing at level 2 .......... 23 POWER9 compiler options ......... 75 Advanced optimization .......... 24 High-performance libraries that are tuned for Optimizing at level 3 .......... 25 POWER9 ............... 75 © Copyright IBM Corp. 1996, 2017 iii POWER9 built-in functions ......... 75 Shared and private variables in a parallel environment.............. 104 Chapter 9. Using the high performance Reduction operations in parallelized loops.... 105 libraries .............. 81 Using the Mathematical Acceleration Subsystem Chapter 12. Offloading computations (MASS) libraries ............. 81 to the NVIDIA GPUs ........ 107 Using the scalar library ......... 82 System prerequisites for offloading to the NVIDIA Using the vector libraries ......... 84 GPUs ................ 107 Using the SIMD libraries ......... 88 Programming with OpenMP device constructs .. 107 Compiling and linking a program with MASS .. 91 Extensions from OpenMP Technical Reports .. 108 Using the Basic Linear Algebra Subprograms - BLAS 92 Using IBM XL C/C++ for Linux with NVCC ... 110 BLAS function syntax .......... 93 Limitations .............. 110 Linking the libxlopt library ........ 95 Chapter 13. Vector element order Chapter 10. Using vector technology 97 toggling .............. 113 Chapter 11. Parallelizing your programs 99 Notices .............. 117 Countable loops ............. 99 Trademarks .............. 119 Enabling automatic parallelization ...... 101 Data sharing attribute rules......... 101 Index ............... 121 Using OpenMP directives ......... 103 iv XL C/C++: Optimization and Programming Guide for Little Endian Distributions About this document This guide discusses advanced topics related to the use of IBM® XL C/C++ for Linux, V13.1.6, with a particular focus on program portability and optimization. The guide provides both reference information and practical tips for getting the most out of the compiler's capabilities through recommended programming practices and compilation procedures. Who should read this document This document is addressed to programmers building complex applications, who already have experience compiling with XL C/C++ and would like to take further advantage of the compiler's capabilities for program optimization and tuning, support for advanced programming language features, and add-on tools and utilities. How to use this document This document uses a task-oriented approach to present the topics by concentrating on a specific programming or compilation problem in each section. Each topic contains extensive cross-references to the relevant sections of the reference guides in the IBM XL C/C++ for Linux, V13.1.6 documentation set, which provides detailed descriptions of compiler options, pragmas, and specific language extensions. How this document is organized This guide includes the following chapters: v Chapter 1, “Using XL C/C++ with Fortran,” on page 1 discusses considerations for calling Fortran code from XL C/C++ programs. v Chapter 2, “Aligning data,” on page 7 discusses options available for controlling the alignment of data in aggregates, such as structures and classes. v Chapter 3, “Handling floating-point operations,” on page 13 discusses options available for controlling how floating-point operations are handled by the compiler. v Chapter 4, “Constructing a library,” on page 17 discusses how to compile and link static and shared libraries and how to specify the initialization order of static objects in C++ programs. v Chapter 5, “Optimizing your applications,” on page 21 discusses various options provided by the compiler for optimizing your programs, and it provides recommendations on how to use these options. v Chapter 6, “Debugging optimized code,” on page 49 discusses the potential usability problems of optimized programs and the options that can be used to debug optimized code. v Chapter 7, “Coding your application to improve performance,” on page 53 discusses recommended programming practices and coding techniques to enhance program performance and compatibility with the compiler's optimization capabilities. v Chapter 9, “Using the high performance libraries,” on page 81 discusses two performance libraries that are shipped with XL C/C++: the Mathematical Acceleration Subsystem (MASS), which contains tuned versions of standard © Copyright IBM Corp. 1996, 2017 v math library functions, and the Basic Linear Algebra Subprograms (BLAS), which contains basic functions for matrix multiplication. v Chapter 10, “Using vector technology,” on page 97 provides an overview of the vector technology, which can be used to accelerate the performance-driven, high-bandwidth communications and computing applications. v Chapter 11, “Parallelizing your programs,” on page 99 provides an overview of options offered by XL C/C++ for creating multi-threaded programs, including OpenMP language constructs. v Chapter 12, “Offloading computations to the
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages138 Page
-
File Size-