XL C/C++ Advanced Edition V8.0 for Linux can be used for large, complex, computationally intensive programs, including interlanguage calls with Fortran programs. This section discusses the features of the XL C/C++ compiler at a high level. It is intended for people who are evaluating XL C/C++ and for new users who want to find out more about the product.
XL C/C++, together with XL C and XL Fortran, comprise the family of XL compilers.
The XL compilers are part of a larger family of IBM C, C++, and Fortran compilers that are derived from a common code base that shares compiler function and optimization technologies among a variety of platforms and programming languages, such as AIX, Linux distributions, OS/390, OS/400, z/OS, and z/VM operating systems. The common code base, along with compliance to international programming language standards, helps ensure consistent compiler performance and ease of program portability across multiple operating systems and hardware platforms.
The XL compilers are available for use on AIX and selected Linux distributions.
This guide provides an overview of XL C/C++ and its features. You can also find more extensive product documentation in the following formats:
- Readme files.
- Installable man pages.
- An HTML-based information system.
- Portable Document Format (PDF) documents.
- Online technical support over the Web.
XL C/C++ Advanced Edition V8.0 for Linux supports several Linux distributions. See the README file and System prerequisites for a complete list of supported distributions and requirements.
The compiler, its libraries, and its generated object programs will run on all POWER3(TM), POWER4(TM), POWER5(TM), POWER5+(TM), PowerPC(R), and PowerPC 970 systems with the required software and disk space.
To take maximum advantage of different hardware configurations, the compiler provides a number of options for performance tuning based on the configuration of the machine used for executing an application.
XL C/C++ offers you a wealth of features to let you tailor the compiler to your own unique compilation requirements.
The compiler also provides corresponding "_r" versions of most invocation commands, for example, xlC_r. These "_r" invocations instruct the compiler to link and bind object files to thread-safe components and libraries, and produce threadsafe object code for compiler-created data and procedures.
For more information about XL C/C++ compiler invocation commands, see Compiling with XL C/C++ or Invoking the compiler or a compiler component.
XL C/C++ lets you specify compiler options through a combination of environment variables, compiler configuration files, command line options, and compiler directive statements embedded in your C or C++ program source.
For more information about XL C/C++ compiler options, see Compiler options reference.
Your compilation needs may frequently call for specifying compiler option settings other than the defaults settings provided by XL C/C++. If so, XL C/C++ provides the vac_configure utility that you can use to create additional configuration files. You can then modify these files with any text editor to contain your own frequently-used compiler option settings.
See Customizing the configuration file for more information on creating and using custom configuration files.
The compiler supports the following programming language specifications for C and C++:
- ISO/IEC 9899:1999 (C99)
- ISO/IEC 9899:1990 (referred to as C89)
- ISO/IEC 14882:2003 (referred to as Standard C++)
- ISO/IEC 14882:1998, the first official specification of the language (referred to as C++98)
In addition to the standardized language levels, XL C/C++ also supports language extensions, including:
- OpenMP extensions to support parallelized programming.
- Language extensions to support VMX vector programming.
- A subset of GNU C and C++ language extensions.
See Supported language standards for more information about C and C++ language specifications and extensions.
XL C/C++ supports a subset of the GNU compiler command options to facilitate porting applications developed with gcc and g++.
This support is available when the gxlc or gxlc++ invocation command is used together with select GNU compiler options. The compiler maps these options to their XL C/C++ compiler option counterparts before invoking the compiler.
The gxlc and gxlc++ invocation commands use the /etc/opt/ibmcmp/vac/8.0/gxlc.cfg plain text configuration file to control GNU-to-XL C/C++ option mappings and defaults. You can customize the /etc/opt/ibmcmp/vac/8.0/gxlc.cfg file to better meet the needs of any unique compilation requirements you may have. See Reusing GNU C/C++ compiler options with gxlc and gxlc++ for more information.
XL C/C++ uses GNU C and GNU C++ header files together with the GNU C and C++ runtime libraries to produce code that is binary-compatible with that produced with the GNU compiler, GCC Version 3.3. Portions of an application can be built with XL C/C++ and combined with portions built with GCC to produce an application that behaves as if it had been built solely with GCC.
XL C/C++ helps protect your investment in your existing C and C++ source code by providing compiler invocation commands that instruct the compiler to compile your application to a specific language level. You can also use the -qlanglvl compiler option to specify a given language level, and the compiler will issue warnings, errors and severe error messages if language or language extension elements in your program source do not conform to that language level.
See -qlanglvl for more information.
XL C/C++ Advanced Edition V8.0 for Linux ships with the following libraries:
The IBM Mathematics Acceleration Subsystem (MASS) libraries consist of highly tuned scalar and vector mathematical intrinsic functions tuned specifically for optimum performance on PowerPC processor architectures. You can choose MASS libraries to support high-performance computing on a broad range of processors, or you can select libraries tuned to specific processor families.
The MASS libraries support both 32-bit and 64-bit compilation modes, are thread-safe, and offer improved performance over their corresponding libm routines. They are called automatically when you request specific levels of optimization for your application. You can also make explicit calls to MASS functions regardless of whether optimization options are in effect or not.
See Using the Mathematical Acceleration Subsystem for more information.
The BLAS set of high-performance algebraic functions are shipped in the libxlopt library. These functions let you:
For more information about using the BLAS functions, see Using the Basic Linear Algebra Subprograms.
XL C/C++ provides several compiler options that can help you control the optimization of your programs. With these options, you can:
Optimizing transformations can give your application better overall performance at run time. C and C++ provides a portfolio of optimizing transformations tailored to various supported hardware. These transformations can:
Significant performance improvements are possible with relatively little development effort because the compiler is capable of sophisticated program analysis and transformation. Moreover, XL C/C++ enables programming models, such as OpenMP, which allow you to write high-performance code.
If possible, you should test and debug your code without optimization before attempting to optimize it.
For more information about optimization techniques, see Optimizing your applications.
For a summary of optimization-related compiler options, see Options for performance optimization.
The XL C/C++ compiler's 64-bit object capability addresses increasing demand for larger storage requirements and greater processing power. The Linux operating system provides an environment that allows you to develop and execute programs that exploit 64-bit processors through the use of 64-bit address spaces.
To support larger executables that can be fit within a 64-bit address space, a separate, 64-bit object form is used to meet the requirements of 64-bit executables. The linker binds 64-bit objects to create 64-bit executables. Note that objects that are bound together must all be of the same object format. The following scenarios are not permitted and will fail to load, or execute, or both:
On both 64-bit and 32-bit platforms, 32-bit executables will continue to run as they currently do on a 32-bit platform.
XL C/C++ supports 64-bit mode mainly through the use of the -q64 and -qarch compiler options. This combination determines the bit mode and instruction set for the target architecture.
For more information, see Using 32-bit and 64-bit modes.
XL C/C++ Advanced Edition V8.0 for Linux supports application development for multiprocessor system architectures. You can use any of the following methods to develop your parallelized applications with XL C/C++:
- Directive-based shared memory parallelization (OpenMP)
- Instructing the compiler to automatically generate shared memory parallelization
- Message-passing-based shared or distributed memory parallelization (MPI)
- POSIX threads (Pthreads) parallelization
- Low-level UNIX parallelization using fork() and exec()
For more information, see Parallelizing your programs.
OpenMP directives are a set of API-based commands supported by XL C/C++ and many other IBM and non-IBM C, C++, and Fortran compilers.
You can use OpenMP directives to instruct the compiler how to parallelize a particular loop. The existence of the directives in the source removes the need for the compiler to perform any parallel analysis on the parallel code. OpenMP directives require the presence of Pthread libraries to provide the necessary infrastructure for parallelization.
OpenMP directives address three important issues of parallelizing an application:
- Clauses and directives are available for scoping variables. Frequently, variables should not be shared; that is, each processor should have its own copy of the variable.
- Work sharing directives specify how the work contained in a parallel region of code should be distributed across the SMP processors.
- Directives are available to control synchronization between the processors.
XL C/C++ supports the OpenMP API Version 2.5 specification. For more information, see www.openmp.org.
The compiler output listing has optional sections that you can include or omit. For more information about the applicable compiler options and the listing itself, refer to XL C/C++ compiler listings.
You can use gdb or any other symbolic debugger when debugging your programs.