 | Level: Introductory Matt Davis (matdavis@us.ibm.com ), Technical Consultant, IBM
06 Jun 2003 Linux PowerPC provides a platform for the development and deployment of 32 bit applications that would benefit from a 64 bit environment. This article addresses porting software from the Intel platform to Linux PowerPC with both of these compiler sets.
Introduction
Linux on POWER provides a platform for the development and deployment of 32 bit
applications that would benefit from a 64 bit environment.Equipped with a 64 bit kernel
and application space,large commercial and computation intensive applications can
utilize larger address spaces with Linux on POWER.Applications can be compiled with
either the GNU Compiler Collection provided by the Free Software Foundation, or the
VisualAge compiler set available from IBM. GCC ’ s strength rests in its standardization
across several types of hardware, and therefore the robust portability of code written to be
compiled with GCC compilers. And the VisualAge compilers offer highly optimized
binaries for the POWER architecture. Since the VisualAge compilers may offer a
performance increase upwards of 30% compared to GCC on this high performance
hardware, many vendors will want to compile binaries with the VA compilers. This
document addresses porting software from the Intel platform to Linux on POWER with
both of these compiler sets.
About POWER Architecture
Performance Optimized with Enhanced RISC (POWER)architecture is the result of more
than a decade of hardware engineering dating to the POWER1 chips released in 1990.
The POWER1 was IBM ’s first commercial RISC processor and debuted at 25 Mhz clock
speed. With the extensive parallelism and optimization in the hardware of the current
implementations, POWER can deliver more computation per cycle than other chip
architectures. Announced in 2001, POWER4 chips feature two 64 bit microprocessors
per CPU board and support SMP configurations up to 32 way.In addition to the
POWER4 hardware, Linux on POWER also runs on IBM eServer hardware featuring
POWER3 and RS64IV hardware. These architectures both feature 64 bit SMP capability
and copper fabrication technology, but whereas the RS64IV processors are still actively
developed, POWER3 is considered the legacy predecessor to POWER4. Each of the
POWER derived chips offers industry leading performance and provides a world class
hardware platform for the deployment of Linux on POWER.
About SLES 8 for POWER
SUSE Linux, available for more than 10 years, offers two levels of Linux distribution.
SUSE Linux 8.0 is intended for workstation environments, and SUSE Linux Enterprise
Server version 8 (SLES 8) for enterprise systems. SLES 8 for POWER is the product of
more than three years of collaboration between SUSE, IBM, and the open source
community. In addition to providing a 64 bit kernel for the POWER architecture, SLES 8
now includes a 64 bit runtime environment and GCC toolchain for building 64 bit
versions of popular open source software (for example, the Apache web server or MySQL).
Combined with IBM ’ s VA Compilers for performance critical applications, the 64 bit
Linux on POWER environment offered by SLES 8 on IBM iSeries and pSeries hardware
delivers an unparalleled platform for developing and deploying Linux solutions. For more information on SuSE Linux, see
http://www.suse.com/us/company/index.html.
About RHEL 3 for POWER
Red Hat Linux is widely recognized as an industry leader in both desktop and enterprise
class Linux markets. Compiler and threading implementations in RHEL 3 differ from
those in SLES 8. Whereas SLES 8 uses two separate toolchains for GCC
implementation, RHEL 3 uses a twin compiler, requiring only a command line flag
(-m64) for selection of the 32 or 64 bit compiler. Native Posix Threads for Linux
(NPTL), featured in RHEL 3, provide better vertical scaling and general performance
improvements over the traditional Linux threading model.
Compiler Sets and Architecture Awareness
Unlike other Linux platforms, Linux on POWER offers not only GCC, but also the IBM
VA Compiler set. GCC offers robust portability of code intended for compilation in
Linux, while the VA Compilers offer a substantial performance increase over GCC. Both
compilers offer 32 and 64 bit compilation modes, and the Linux on POWER environment
allows both 32 and 64 bit code to be run simultaneously without a performance loss.
Linux on POWER varies from Linux Intel in that it is both Big Endian (left to right
assignment of addresses to bytes in a data word)and 64 bit. Much has been written on
byte-ordering and the POWER architecture. For an excellent review of addressing endian
concerns,please see chapter 2 of the AIX 5L Porting Guide. Another practical and
concise reference on this topic is the Migrating Tru64 Applications to AIX whitepaper.
These references may prove particularly useful when migrating code with the VA
Compilers.
Regarding 64 bit code, a long variable type is not the same as an int . On POWER64, ints
are 4 bytes and longs are 8 bytes. Addresses are also 8 bytes. Never cast a pointer to an
int in 64 bit code; this would mismatch 32 and 64 bit data types.
Take time to ensure that bit-specific code is endian friendly and that libraries are the
correct versions and the migration to 64 bit Linux on POWER should be natural.
Porting with the GCC Compiler Set
In general, porting code with GCC compilers should be straightforward. Architecture
may vary, and occasionally library version discrepancies may arise, but for the most part,
GCC is GCC, no matter which architecture it runs on. Architecture specific flags are
discouraged for compilation on Linux on POWER (for example. -m486, -powerpc), as GCC does
not have extensive processor maps for optimization routines on these architectures. Also,
without architecture specific flags, binary compatibility will be greater across different
models of POWER hardware.
64 bit GNU compilers are included in SLES 8 and RHEL 3, and it is recommended to use
the compiler sets packaged with the Linux distributions.In SLES8, the compilers
installed to a directory under /opt/ and makefiles for source code should be altered to
reflect the location of the 64 bit GNU compilers. In some cases, environment variables
will need to be set to reflect the location of the compilers as well. In RHEL3, the biarch
toolchain arrangement allows for access to the 64 bit compiler by adding the -m64 flag.
In SLES8, the libraries for the 64 bit toolchain are located under the 64 bit toolchain
directory tree, so it is important to properly modify the library and compiler path
environment variables. Occasionally, the libraries called by code intended for 32 bit
compilation will have slight name variations in the 64 bit toolchain. In these cases, a
simple symbolic link to the correct library should resolve the issue. Individual examples
of such inconsistencies vary by point release of the toolchain, and tend to be resolved at
the next release. It is important to report these errors to the bug tracking system located
at http://linuxppc.org.
On all architectures, libraries must be compiled with -fPIC;IA32 has this flag applied by
default with GCC. On POWER, this flag specifies that the generated code will be used in
a shared object.
Developers not familiar with the GPL should reference it carefully and make sure the
terms and conditions of the license are understood.
Porting with the VisualAge Compiler Set
Compiling code with the VA compiler set has in many cases shown a significant
performance increase on Linux for IBM eServers featuring POWER hardware.These
compilers, migrated from the high performance compiler set used on AIX, have extensive
optimization routines for POWER hardware, and therefore should be used for any
application that wants to take full advantage of the POWER architecture ’s potential.
However, software originally intended to be compiled with GCC compilers may need
more attention when recompiled with VA compilers. Makefiles need to be edited to
reflect the correct path to the VA compilers, by default /opt/ibmcmp/. The correct
optimization flags should also be set for the specific architecture (for example, -03 -qarch=pwr4
-qtune=pwr4 for IBM POWER4 hardware). In addition to optimization modes for
various POWER architecture derivatives, the VisualAge compilers can be instructed to
compile software in common mode.This guarantees compatibility across all types of
POWER architecture at the expense of performance otherwise gained through
architecture-specific optimization. When compiling 64 bit code, the compiler must be
given the flag for a 64 bit build (that is, -q64), as it defaults to 32 bit mode.
The VisualAge Compilers do not create object code directly. First, an intermediate
language called ".w code " is generated, which is fed back to the compiler ’s backend
optimizer. The optimizer explores variations on the code until the most efficient method
is determined. Following this, the compiler generates .o files and then the final binaries.
A few tips to compiling GCC oriented code with the VisualAge compiler set are listed
below:
- C++comments:GCC allows C++style commenting to be used in C files by
default, but this is not the case with XLC, the VisualAge C compiler. Since it is
not economical to change all the comments in a group of source files to comply
with C style commenting, XLC provides a -q argument to allow these comments,
-q cpluscmt . When C code is compiled with this flag, both C and C++ style
commenting is interpreted.
- Environment variables are often the easiest way to configure build scripts. As
opposed to hand editing Configure scripts and Makefiles, it is recommend that
relevant environment variables such as $CC and $CFLAGS be set and the
Configure script be allowed to generate the Makefile without the need for hand
editing.
- Configure scripts also need to be aware of the proper platform type. This will be
either linux-powerpc-unknown-gnu or linux-powerpc64-unknown-gnu.This
should be set for compilation with either GCC or VA by appending the -target=
flag to the Configure script.
Although extensive documentation for the VisualAge compilers exists, an argument list is
provided at the console by running the compiler with no arguments, for example,
$COMPILER_PATH/bin/cc.
Java
In early distributions of Linux for POWER, the Blackdown JDK was the only available
development kit. Blackdown, while renowned for offering a highly compatible JDK,has
not boasted the performance the IBM JDK has delivered to Java applications on Linux
Intel and AIX platforms.Yet, thanks to the joint effort of IBM, SUSE, and the open
source community, Java migration to Linux on POWER is now powered by the 64 bit
IBM JDK version 1.4.1.The IBM JDK offers the formal compliance to Java Standards
and enterprise class performance expected from IBM development kits. Support for the
64 bit IBM JDK version 1.4.1 is in plan for RHEL 3, with the 32 bit IBM JDK version
1.4.1 available now. Additional performance gains may be found by recompiling
requisite C libraries with the VA Compilers.
Developers not accustomed to developing with the IBM JDK should reference
http://www-136.ibm.com/developerworks/java/. This may be helpful
for understanding optimal levels of garbage collection, JNI usage,etc.
Helpful Terms and Definitions
- POWER
- The 64-bit architecture RISC featured in many enterprise IBM servers.
- Linux for POWER
- The Linux operating system running on POWER hardware. It can be assumed in the
context of this document that this refers explicitly to IBM iSeries and pSeries servers.
- GNU Compiler Collection (GCC)
- The open source GNU Compiler Set, including gcc, the GNU C Compiler, g++, the GNU
C++compiler, and g77, the GNU Fortran77 compiler.
- SUSE Linux Enterprise Server 8 (SLES 8)
- SUSE Linux Enterprise Server, version 8. This is the most recent enterprise Linux
offering from SUSE Linux. In the context of this document, SLES 8 refers to SLES 8 for
POWER architecture.
- Red Hat Enterprise Linux 3 (RHEL 3)
- Red Hat Enterprise Linux, version 3. This is the most recent enterprise Linux offering
from Red Hat Linux. In the context of this document, RHEL 3 refers to RHEL 3 for
POWER architecture.
- VisualAge Compiler Set (VA Compiler)
- This compiler set, functionally identical to IBM ’ s high-performance compiler set for
AIX, is now available for Linux on POWER. The VA compiler set includes xlC, the VA
C compiler, xlC++, the VA C++compiler, and xlF, the VA Fortran compiler.
- IA32
- The 32 bit Intel architecture.
- GPL
- The GNU General Public License, under which the Linux kernel and much of the
software found in the open source community is licensed.More about the GPL can be
found at http://www.gnu.org.
 |
Summary
Linux on POWER offers an enterprise class Linux environment, complete with 64 bit
kernel, application environment, and toolchains. Unlike other Linux environments,
Linux on POWER offers twin compiler sets representing the best of both worlds:ease of
migration with open source code and high performance exploitation of the award winning
high performance POWER architecture. As a result of more than three years of
cooperation between IBM, SUSE, and the open source community, SLES 8 has emerged
as a genuine enterprise class distribution and a leader in its field. RHEL 3 is now
available as a Linux on POWER distribution from long-time Linux leader, Red Hat.
Application performance available on the POWER architecture is now augmented by
development tools never before offered on the Linux operating system. In summary,
Linux on POWER is the leading platform for the deployment of high performance Linux
applications.
Where to Find Compilers
The best source for GCC compilers for Linux on POWER is from a certified IBM Linux
vendor, such as SuSE Linux, as these vendors have taken efforts to build GCC and its
libraries to minimize any version discrepancies.
VisualAge compilers can be found at http://www-306.ibm.com/software/awdtools/vacpp/.
Resources
About the author  | |  | Matt Davis is a Linux technical consultant in the IBM eServer Solutions Enablement
team. As a member of the Linux on POWER project since its inception, he explored and
tested emerging technology for Linux on POWER and wrote several reports summarizing
his findings. These include Journaling File Systems for Linux PowerPC, Parallel Grid
Computing with Linux PowerPC, Open Source Alternatives to Commercial Software for
Linux PowerPC, and the Linux Solutions Catalog, to name a few. He came to IBM as an
intern during his tenure as a student at the University of Texas at Austin, from which he
earned two degrees with academic honors.
|
Rate this page
|  |