
IBM XL C/C++ for AIX, V16.1 IBM Optimization and Programming Guide Version 16.1 SC27-8060-00 IBM XL C/C++ for AIX, V16.1 IBM Optimization and Programming Guide Version 16.1 SC27-8060-00 Note Before using this information and the product it supports, read the information in “Notices” on page 189. First edition This edition applies to IBM XL C/C++ for AIX, V16.1 (Program 5765-J12; 5725-C72) 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, 2018. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About this document ........ vii Skipping heap checking ......... 33 Who should read this document ....... vii Using stack traces ........... 34 How to use this document ......... vii How this document is organized ....... vii Chapter 5. Constructing a library ... 35 Conventions .............. viii Compiling and linking a library ....... 35 Related information ........... xii Compiling a static library......... 35 Available help information ........ xiii Compiling a shared library ........ 35 Standards and specifications........ xv Exporting symbols with the CreateExportList Technical support ............ xv utility ............... 38 How to send your comments ........ xvi Linking a library to an application...... 38 Linking a shared library to another shared library 39 Chapter 1. Using XL C/C++ with Fortran 1 Initializing static objects in libraries (C++) .... 39 Identifiers ............... 1 Assigning priorities to objects ....... 39 Corresponding data types .......... 2 Order of object initialization across libraries .. 42 Character and aggregate data ......... 4 Dynamically loading a shared library...... 44 Function calls and parameter passing ...... 5 Loading and initializing a module with the Pointers to functions............ 5 loadAndInit function .......... 44 Sample program: C/C++ calling Fortran ..... 5 Terminating and unloading a module with the terminateAndUnload function ....... 46 Chapter 2. Aligning data........ 7 Using alignment modes........... 7 Chapter 6. Replacing operator new and Alignment of aggregates ......... 10 operator delete in applications that use Alignment of bit-fields.......... 12 shared libraries (C++) ........ 47 Using alignment modifiers ......... 14 Chapter 7. Using the C++ utilities ... 49 Chapter 3. Handling floating-point Demangling compiled C++ names ....... 49 operations ............. 17 Demangling compiled C++ names with c++filt 49 Floating-point formats ........... 17 Demangling compiled C++ names with the Handling multiply-and-add operations ..... 18 demangle class library .......... 50 Compiling for strict IEEE conformance ..... 18 Creating a shared library with the Handling floating-point constant folding and makeC++SharedLib utility ......... 52 rounding ............... 19 Linking with the linkxlC utility........ 54 Matching compile-time and runtime rounding modes ............... 19 Chapter 8. Optimizing your applications 57 Rounding modes and standard library functions 20 Distinguishing between optimization and tuning .. 57 Handling floating-point exceptions ...... 21 Steps in the optimization process ....... 58 Compiling a decimal floating-point program ... 22 Basic optimization ............ 58 Optimizing at level 0 .......... 59 Chapter 4. Using memory heaps.... 23 Optimizing at level 2 .......... 59 Managing memory with multiple heaps ..... 23 Advanced optimization .......... 60 Functions for managing user-created heaps ... 24 Optimizing at level 3 .......... 61 Creating a heap ............ 25 An intermediate step: adding -qhot suboptions at Expanding a heap ........... 26 level 3 ............... 62 Using a heap ............. 27 Optimizing at level 4 .......... 62 Getting information about a heap ...... 28 Optimizing at level 5 .......... 63 Closing and destroying a heap ....... 28 Tuning for your system architecture ...... 64 Changing the default heap used in a program .. 29 Getting the most out of target machine options 65 Compiling and linking a program with Using high-order loop analysis and transformations 66 user-created heaps ........... 29 Getting the most out of -qhot ....... 67 Example of a user heap with regular memory .. 29 Using shared-memory parallelism (SMP) .... 68 Debugging memory heaps ......... 30 Getting the most out of -qsmp ....... 69 Functions for checking memory heaps .... 31 Using interprocedural analysis ........ 70 Functions for debugging memory heaps .... 31 Getting the most from -qipa ........ 71 Using memory allocation fill patterns..... 33 Using profile-directed feedback ........ 73 © Copyright IBM Corp. 1996, 2018 iii Compiling with -qpdf1 ......... 73 Chapter 12. Using the high Training with typical data sets ....... 74 performance libraries ........ 137 Recompiling or linking with -qpdf2 ..... 77 Using the Mathematical Acceleration Subsystem Handling table of contents (TOC) overflow .... 80 (MASS) libraries ............ 137 Options for reducing the number of global Using the scalar library ......... 138 symbols .............. 81 Using the vector libraries ........ 140 Options for enlarging the TOC access range .. 82 Using the SIMD libraries ........ 146 Performance considerations of handling TOC Compiling and linking a program with MASS 149 overflow .............. 82 Using the Basic Linear Algebra Subprograms - Marking variables as local or imported ..... 84 BLAS ................ 150 Getting the most out of -qdatalocal ..... 84 BLAS function syntax ......... 150 Using compiler reports to diagnose optimization Linking the libxlopt library ........ 152 opportunities .............. 86 Parsing compiler reports with development tools 87 Chapter 13. Using vector technology 155 Other optimization options ......... 88 Chapter 9. Debugging optimized code 91 Chapter 14. Parallelizing your Detecting errors in code .......... 92 programs ............. 157 Understanding different results in optimized Countable loops ............ 158 programs ............... 93 Enabling automatic parallelization ...... 159 Debugging in the presence of optimization .... 94 Using IBM SMP directives (C only) ...... 159 Using -qoptdebug to help debug optimized Data sharing attribute rules......... 160 programs ............... 95 Using OpenMP directives ......... 162 Shared and private variables in a parallel Chapter 10. Coding your application to environment.............. 163 improve performance ........ 99 Reduction operations in parallelized loops.... 165 Finding faster input/output techniques ..... 99 Chapter 15. Selecting the standard Reducing function-call overhead ....... 99 Managing memory efficiently (C++ only) .... 101 allocation method to suit performance Optimizing variables ........... 101 (C++) ............... 167 Manipulating strings efficiently ....... 102 Optimizing expressions and program logic ... 103 Chapter 16. Ensuring thread safety Optimizing operations in 64-bit mode ..... 103 (C++) ............... 169 Tracing functions in your code ....... 104 Ensuring thread safety of template objects.... 169 Using C++ templates ........... 108 Ensuring thread safety of stream objects .... 169 Using the -qtempinc compiler option .... 110 Using the -qtemplateregistry compiler option 112 Using explicit instantiation declarations (C++11) 114 Chapter 17. Memory debug library The C++ template model ......... 115 functions (XL-based front end) .... 171 Using delegating constructors (C++11) ..... 115 Memory allocation debug functions ...... 171 Using rvalue references (C++11) ....... 116 _debug_calloc - Allocate and initialize memory 171 Using visibility attributes (IBM extension) .... 117 _debug_free - Free allocated memory .... 172 Types of visibility attributes ....... 118 _debug_heapmin - Free unused memory in the Rules of visibility attributes ....... 120 default heap............. 173 Propagation rules (C++ only) ....... 126 _debug_malloc - Allocate memory ..... 175 Specifying visibility attributes using the _debug_ucalloc - Reserve and initialize memory -qvisibility option .......... 128 from a user-created heap ........ 176 Specifying visibility attributes using pragma _debug_uheapmin - Free unused memory in a preprocessor directives ......... 128 user-created heap ........... 177 _debug_umalloc - Reserve memory blocks from Chapter 11. Exploiting POWER9 a user-created heap .......... 178 technology ............ 131 _debug_realloc - Reallocate memory block... 179 String handling debug functions ....... 180 POWER9 compiler options ......... 131 _debug_memcpy - Copy bytes....... 180 High-performance libraries that are tuned for _debug_memset - Set bytes to value ..... 182 POWER9 ............... 131 _debug_strcat - Concatenate strings ..... 183 POWER9 built-in functions ......... 131 _debug_strcpy - Copy strings ....... 184 _debug_strncat - Concatenate strings .... 185 _debug_strncpy - Copy strings ...... 186 iv XL C/C++: Optimization and Programming Guide Notices .............. 189 Index ............... 193 Trademarks .............. 191 Contents v vi XL C/C++: Optimization and Programming Guide About this document This guide discusses advanced topics related to the use of IBM® XL C/C++ for AIX®, V16.1, 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.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages214 Page
-
File Size-