Gentoo Logo
Gentoo Logo Side

Guide to Compaq-Tools on Gentoo Alpha

Content:

1. Introduction

Licensing Considerations 

Before you read any further through this guide, you should check your eligibility to use the Compaq Tools. If you need to use anything more than the runtime libraries dev-libs/libots and dev-libs/libcpml you need to qualify as an academic user or an enthusiast.

Code Listing 1.1: HP Educational and Enthusiast License

The Software may be used solely for your individual and personal "enthusiast"
purposes or personal education and study. It may not be used for any
commercial, business or institutional purpose, whether "for profit" or "not
for profit." Any work performed or produced as a result of the use of this
Software cannot be performed or produced for the benefit of other parties for
a fee, compensation or any other reimbursement or remuneration.

Note: If you don't qualify and would still like to use the software, you can purchase a commercial license from HP, which will give you more flexibility in how you use the toolkit.

If you do qualify for a free license, you need to register with HP using the form located at http://h18000.www1.hp.com/products/software/alpha-tools/ee-license.html. Once your request has been processed, HP will send you a license key that can be used to decrypt and install the Compaq Compilers.

Compaq Tools Overview 

If you're familiar with PC optimization, you've probably heard of icc, Intel's optimizing compiler for their pentium processors. The Alpha user's equivalent is The Professional Linux Developers Tools, a set of high performance libraries, compilers and utilities specifically tuned for the Alpha platform, made freely available to Alpha enthusiasts and for educational use. Experimenting with using the Libraries and Compilers in portage compiles is an effective way of improving the performance of your Gentoo Alpha system.

The following tools are available to Gentoo users:

Utility Description Portage Name
libots Compiled code support, a dependency required for using the toolkit. dev-libs/libots
libcpml Compaq Portable Math Library, a high performance maths library for Alpha users that can be used to improve maths performance in applications. dev-libs/libcpml
ccc Compaq C Compiler, highly optimized and tuned for the Alpha platform, it contains a highly optimizing code generator specifically designed to exploit the 64-bit Alpha architecture. It is particularly well-suited and contains extended support for systems programming, parallel programming, and mathematical computing. dev-lang/ccc
cxx Compaq's C++ compiler, tuned specifically for the Alpha platform, offers the same optimizing code generator from Compaq C to C++ programmers. dev-lang/cxx
ladebug Compaq's famous debugger for Tru64, ported to Alpha Linux, contains extended support for applications compiled with the compaq c compilers. dev-util/ladebug
libcxml Compaq's eXtended Math Library, high performance maths library for fortran, c and c++ programmers. dev-libs/libcxml

Note: As of this writing, some of the Compaq Tools are still marked ~alpha This means that although they have been tested and seem to work, they have not undergone extensive testing and we cannot be certain they are totally stable. If you want to install some of these applications, you might need to prefix the commands ACCEPT_KEYWORDS="~alpha" to the emerge command.

Note: If you have any problems with ccc or cxx, or any of the Compaq Tools, please enter a bug into the gentoo bugzilla and assign it to me -- [email protected]

2. Installing the Developers Tools

Runtime Libraries 

The first step toward installing the Developer Tools is getting the runtime libraries. Due to license restrictions, Gentoo cannot distribute the RPM's and you must download them from Compaq.

ftp://ftp.compaq.com/pub/products/linuxdevtools/latest/downloads.html

Download the libots and libcpml rpms, and then place them into your distfiles directory.

Note: If you have an ev6 or higher processor, you should download the ev6 optimized libcpml rpm, this will allow you to exploit the features of your newer processor.  You should also add "ev6" to your USE in /etc/make.conf so that the ebuild will know to use the optimized rpm.  If you don't know which processor revision is in your machine, use the command below to identify it

Code Listing 2.1: Getting the Runtime Libraries

# uname -p   # check your processor revision
EV56
# mv libots-2.2.7-2.alpha.rpm cpml_ev?-5.2.0-1.alpha.rpm /usr/portage/distfiles

Now the rpms are in your distfiles directory, portage will be able to find them and install them onto your system. Use the following code to emerge the libraries.

Code Listing 2.2: Installing Required Libraries

# emerge -pv dev-libs/libots dev-libs/libcpml # check everything looks okay
# emerge dev-libs/libots dev-libs/libcpml

Now the libraries are installed in your system and you are ready to install the compilers and utilities.

Installing the Compilers 

If you haven't already registered for an enthusiast or academic license with HP, now would be a good time.  It seems to take about 24 hours for the license to be issued after you fill in the form on the web.

http://h18000.www1.hp.com/products/software/alpha-tools/ee-license.html

Warning: You will be asked to enter your details and email address. The email address must be valid as you will be emailed a license key that can be used to unlock the compilers.

Note: You will also be asked to explain why you qualify for a free license, eg "Home Alpha enthusiast" or "For academic use at XYZ college."

When your license is issued, your notification email will contain the license key. Use it in the command below to install the ccc and cxx compilers.

Code Listing 2.3: Installing Compaq C

# emerge -pv dev-lang/ccc  # check everything looks okay
# CCC_LICENSE_KEY=0123456789 emerge dev-lang/ccc
# ebuild /var/db/pkg/dev-lang/ccc-6.5.9.001.ebuild config

Note: Remember to substitute 0123456789 with the license key emailed to you

Note: Check which version of the C compiler you are installing before issuing the ebuild command. Emerge will tell you the command to issue when it completes. The ebuild command configures the compiler for your system, allowing it to locate system files and libraries.

If everything went okay, you now have the Compaq C Compiler installed and can use it to start compiling applications from portage or your own applications. If you would also like to use the C++ compilers, use the commands below to install them.  Don't forget to run "cxx" at the end to agree to the EULA.

Code Listing 2.4: Installing Compaq C++

# emerge -pv dev-lang/cxx   # check everything looks okay
# CXX_LICENSE_KEY=0123456789 emerge dev-lang/cxx
# ebuild /var/db/pkg/dev-lang/cxx-6.5.9.31-r1.ebuild config
# cxx   # read and agree to the EULA.

If you would like to take advantage of the enhanced debugger ladebug, you should install it now.

Code Listing 2.5: Installing Ladebug, the Compaq Debugger

# emerge -pv dev-util/ladebug
# emerge dev-util/ladebug

Note: ladebug can be used with gcc executables as well as ccc/cxx executables, If you are from a Tru64 background, you may be familiar with ladebug and might feel more comfortable using it than gdb for general debugging.

3. Using the Compaq Tools with Portage

Compiling C/C++ Programs with Portage 

Compiling programs from portage with ccc is simple. In the following example we will demonstrate installing gzip, an application known to perform very well with ccc.

Code Listing 3.1: Portage Compiling with ccc

# emerge -pv gzip   # check everything looks okay
# CC=ccc CFLAGS="-host -fast" emerge gzip

ccc has many optimization features. There is an overview and explanation of the CFLAGS used here and some other common options farther below.

The same method can be used to compile C++ programs. The following example uses groff, which benchmarks much better when compiled with cxx.

Code Listing 3.2: Portage Compiling with cxx

# emerge -pv groff   # check everything looks okay
# CXX=cxx CXXFLAGS="-host -fast" emerge groff

Optimizing Your ccc/cxx Compiled Applications 

Optimizing applications for Alpha with ccc/cxx is simpler than with gcc. Similar options are grouped together, making command lines shorter and simpler. The table below demonstrates some of the common flags you might want to try in your programs.

Flag Description Safety
-host Optimizes the application for the system being compiled on by taking advantage of any extended instruction set available and scheduling specifically for this machine. Applications compiled with this will probably not function on different alpha machines. Very Safe.
-fast Turns on some advanced optimizations; using this will maximize the performance of your applications Safe.
-O4 Inserts NOP instructions into your code to improve scheduling. Software pipelining using dependency analysis, vector-ization of some loops on 8-bit and  16-bit data (char and  short). Using this may not always improve code performance and should be compared to -O3 and -fast. Usually Safe, may not always improve performance
-std1 Informs the compiler to use the strictest possible interpretation of the standards allowing it to perform more aggressive optimizations that might not have had predictable results in a more liberal interpretation. Not all applications will compile with this and some may not perform as intended if they do compile. May not Compile, but Will Improve Performance.
-tune host Fine tunes the compiler scheduling to perform best on the arch specified; using this will not stop you from using the binaries on different machines and will improve performance. Very Safe.

Note: CCC supports interpretation of most gcc compiler flags so if your application Makefile specifies some gcc options, don't worry, CCC will probably understand it.

Note: If you have the "doc" USE flag set in your make.conf, the compilers will have installed extensive documentation in /usr/share/doc. You can browse this for more information. There are also excellent man pages.

4. Notes on the Compaq Compilers

Applications that benefit from CCC/CXX 

The compaq compilers really excel at optimizing applications that involve intensive floating point maths. They can also outperform GCC at integer maths in most situations. During my experiments I have found many applications that benchmark almost identically with ccc as with gcc, but I haven't found any applications that perform worse with ccc/cxx.

Remember however that GCC has received more extensive testing and provides many extensions to the standards that programmers might make use of. CCC might not support these extensions or not support them as fully as gcc. You should take this into account when choosing what to optimize with ccc.

Benchmarking CCC 

If you want to experiment with different CCC flags and compare them to GCC, you need to benchmark them. For this purpose, I recommend the Freebench benchmark suite. It will compile and run 6 different tests designed to test Integer and Floating Point performance and will also generate html graphs for comparisons.

Here are some examples I have prepared:

Test Summary
CCC Vanilla CCC results with no flags specified.
GCC Vanilla GCC results with no flags specified.
CCC Normal CCC Results with some common flags
GCC Normal GCC Results with some common flags.
CCC Best CCC With some more options specified.
GCC Best GCC With some more options specified.

Note: Higher is better.

Note: A Single page comparison is available here

Advanced Performance Features 

If you've been using Alpha for more than a few minutes, you know about Unaligned accesses, programming errors that affect Alpha users and cause applications to incur performance penalties as the kernel fixes them.

Unaligned accesses aren't serious; programs will run fine even with them.  However the kernel can't fix these instantly and every time it does a fix, your application will run slower. Usually this isn't a problem, but on some programs you might notice the slowdown.

Code Listing 4.1: Unaligned Trap Messages

Apr 9 01:05:55 amnesiac bash(20147): unaligned trap at 0000039db4526d98: 000003
9db4662e26 28 1
Apr 9 01:05:55 amnesiac bash(20147): unaligned trap at 0000039db4526d9c: 000003
9db4662e2a 28 3
Apr 9 01:06:03 amnesiac snort(23800): unaligned trap at 000000012003fe60: 00000
00120161a92 2c 2
Apr 9 01:06:03 amnesiac snort(23800): unaligned trap at 000000012003fe78: 00000
00120161a96 2c 2
Apr 9 01:06:03 amnesiac snort(23800): unaligned trap at 000000012003feb0: 00000
00120161a9e 2c 4
Apr 9 01:06:03 amnesiac snort(23800): unaligned trap at 000000012003feb4: 00000
00120161aa2 2c 5

Note: You can see these messages on your machine with the dmesg command.

There are 2 ways to fix these errors so as to minimize the performance hit. If you're a programmer, you can fix the errors.  This is usually simple, but some applications are riddled with them or are very subtle. If you think you can do this, HP has some documentation for programmers on how to identify and fix these bugs at the link below.

http://h21007.www2.hp.com/dspp/tech/tech_TechSingleTipDetailPage_IDX/1,2366,161,00.html

The second way is using the Compaq Compiler and the -misalign flag, this will add extra checking code to make sure that all code is aligned. This will make your program run slower, so you need to experiment and check if it's worth it.

If possible run the application through time. When the program completes it should show how much time the kernel spent processing system calls, including fixing misaligned accesses. If this number is high (you can compare it to other platforms) and you are receiving lots of UAC messages, you might benefit from recompiling with the extra checking code.

Code Listing 4.2: Measuring the Performance of an Unaligned Access

# time your_application
real 0m2.011s
user 0m0.004s
sys 0m2.007s
# CC=ccc CFLAGS="-host -fast -misalign" emerge your_application
# time your_application
0m0.811s
0m0.804s
0m0.007s

Note: Of course that you don't have to compile your whole application with -misalign You can use the hp documentation above to identify the source file that contains the errors and use misalign on those files specifically.

Note: If the UAC messages bother you or you would like to streamline the kernel handling code for maximum performance, you can modify /usr/src/linux/arch/alpha/kernel/traps.c and remove the printk() and switch statements.

Note: You can use the following command to check how many times the kernel has fixed these errors since you last rebooted

Code Listing 4.3: Check UAC Stats

$ grep unaligned /proc/cpuinfo
kernel unaligned acc : 3 (pc=fffffc000035c7e0,va=120000f1a)
user unaligned acc : 6623 (pc=28d361e4c1c,va=28d36320f62)

The contents of this document are licensed under the Creative Commons - Attribution / Share Alike license.
Print
line
Updated June 05, 2004
line
Tavis Ormandy
Gentoo Alpha Developer

Jorge Paulo
Editor

line
Summary:  This guide is an introduction to the free Compaq Tools for Gentoo Alpha users.
line
The Gentoo Linux Store
line
Copyright 2001-2004 Gentoo Foundation, Inc. Questions, Comments, Corrections? Email [email protected].