Order Number: AA--PXEFK--TE
This document provides information about how to run and use Compaq KAP C/OpenMP on Compaq Tru64 UNIX systems.
Revision/Update Information: This is a revised document.
Operating System and Version: Compaq Tru64 UNIX Versions 4.0F, 5.0, and 5.0A
Software Versions:
Version 4.1
Compaq C Version 6.1
Compaq Computer Corporation
Houston, Texas
© 1993 Compaq Computer Corporation
© 1993 Kuck & Associates, Inc.
Compaq, the Compaq logo, Compaq C, and Compaq Fortran, Registered in U.S. Patent and Trademark Office.
KAP is a trademark of Kuck & Associates, Inc.
UNIX is a registered trademark of The Open Group.
All other product names mentioned herein may be trademarks or registered trademarks of their respective companies.
Compaq shall not be liable for technical or editorial errors or omissions contained herein. The information in this document is subject to change without notice. This document is available on CD-ROM.
Contents | Index |
This document describes how to use Compaq KAP C/OpenMP software on Compaq Tru64 UNIX systems.
This document is a guide for KAP users working with Compaq C on Compaq Tru64 UNIX systems.
This document is organized into the following chapters and appendixes:
This document is part of the KAP document set that also includes:
The following are equivalent terms used in this document:
The following table lists the other conventions used in this guide.
Convention | Description |
---|---|
< > | Angle brackets denote command input you replace with the appropriate value. |
( ) |
Parentheses containing a single command value denote the default value.
For example, (-optimize=5) denotes 5 is the default value.
Parentheses containing hyphenated value ranges denote that you choose a value from the range. |
[ ] |
Square brackets indicate optional syntax. For example:
#pragma _KAP [no]inline [(name)] |
UPPERCASE and lowercase | The Tru64 UNIX system differentiates between lowercase and uppercase characters. Literal strings that appear in text, examples, syntax descriptions, and function descriptions must be typed exactly as shown. |
italic type | Italic type indicates complete titles of manuals and keywords, as well as product names. |
KAP for C is a source-to-source preprocessor that restructures C code for improved performance and better utilization of the memory hierarchy of Tru64 UNIX systems. Additionally, KAP performs parallel decomposition to take advantage of shared memory and symmetric multiprocessors. By eliminating inefficiencies and bottlenecks, KAP enables you to get your answers faster without time-consuming, hand-recoding of applications programs.
Because KAP makes it possible to run serial C programs efficiently on advanced architecture computers without hand-recoding, the original programs remain portable and users need not concern themselves with the details of each machine.
KAP optimizations include:
The KAP conversion process is designed to operate effectively without intervention from you. KAP provides a large set of command-line switches and inline assertions and directives that the advanced user can use for even better performance on specific codes. The optional KAP listing file includes information that identifies the parts of the source program that could benefit from such attention.
This chapter gives general information about KAP syntax, file-naming conventions, and optimizing programs with KAP. Sections describing how to compile and run programs with KAP are specific to single-processor Tru64 UNIX systems. For information on how to compile and run programs with KAP on multiprocessor systems, see Chapter 3.
Compaq KAP C/OpenMP for Tru64 UNIX can be run in either of two modes:
The following command-line switches provide maximum general optimization: -optimize=5, -roundoff=3, and -scalaropt=3. These are the default settings for these switches.
See Section 2.3 for an explanation of how to pass command-line
switches to KAP and Chapter 4 for details about what is controlled
by each switch's levels.
2.2 Installing KAP
KAP is installed on the Tru64 UNIX system with the system command setld. See the Compaq KAP C/OpenMP for Tru64 UNIX Installation Guide for details.
The directory that contains the executable KAP file must be in your path; or a command such as kapc must be aliased to point to the executable file.
If you are a frequent user of KAP, you may find it convenient to add an
alias to your .cshrc files so that a kapc command
with preferred switches is available. Contact your system manager for
the directory location of the executable KAP file.
2.3 Compiling a Program Using the kcc Driver
The kcc command invokes a driver program that automatically calls KAP, the C compiler, and the linker. The following examples show how to use kcc:
kcc myprog.c |
kcc myprog.c -v |
oursmp>kcc -v sin.c timing.o -lm /usr/bin/cc -C -E -D__KAP -U_INLINE_INTRINSICS sin.c > ./ktmpa24807.c /usr/bin/kapc -cmp=./sin.cmp.c -nolist ./ktmpa24807.c -tune=EV4 KAP/Tru64_U_C 4.0 k010710 990730 02-Sep-1999 16:48:52 0 errors in file ./ktmpa24807.c /usr/bin/cc -migrate -fast -v ./sin.cmp.c timing.o -lm -tune host -non_shared -lkio /usr/lib/cmplrs/cc.dtk/gemc_cc -D__LANGUAGE_C__ -D__unix__ -D__osf__ -D__alpha -D_SYSTYPE_BSD -D_LONGLONG -D__digital__ -D__arch64__ -g0 -O3 -std -intrinsics -ansi_alias -ansi_args -assume nomath_errno -assume trusted_short_alignment -D_INTRINSICS -D_INLINE_INTRINSICS -D_FASTMATH -float -fp_reorder -ifo -readonly_strings -v -tune ev4 -I/usr/include.dtk -o /tmp/deccobjAAAaayhca ./sin.cmp.c These macros are in effect at the start of the compilation. ----- ------ --- -- ------ -- --- ----- -- --- ------------ -D__DECC -D__osf__ -D__arch64__ -D__PRAGMA_ENVIRONMENT -D_LONGLONG -D__digital__ -D__X_FLOAT=0 -D__DATE__="Sep 2 1999" -D__DECC_MODE_RELAXED -D__DECC_VER=60160104 -D_SYSTYPE_BSD -D__ALPHA -D__IEEE_FLOAT -D_FASTMATH -D__unix__ -D_INLINE_INTRINSICS -D__TIME__="16:48:53" -D__Alpha_AXP -D__INITIAL_POINTER_SIZE=0 -D_INTRINSICS -D__STDC__=0 -D__LANGUAGE_C__ -D__alpha /usr/lib/cmplrs/cc.dtk/gemc_cc: 0.18u 0.07s 0:00 92% 0+9k 0+11io 0pf+0w 9stk+1328mem /usr/lib/cmplrs/cc.dtk/ld -g0 -O3 /usr/lib/cmplrs/cc.dtk/crt0.o /tmp/deccobjAAAaayhca timing.o -lm -non_shared -lkio -qlots -lc /usr/lib/cmplrs/cc.dtk/ld: 0.15u 0.13s 0:00 23% 0+13k 45+58io 14pf+0w 13stk+2024mem rm ./ktmpa24807.c mv sin.cmp.o sin.o |
kcc -ckapargs='-optimize=5 -roundoff=3 -scalaropt=3 \ -list=myprog_annotated.lis' myprog.c |
kcc -ckapargs='-optimize=5 -roundoff=3 -scalaropt=3' \ -o myprog.exe myprog.c |
kcc -call_shared myprog.c |
The kcc command saves the optimized version of your source
program followed by the extension .cmp.c in the source
directory for use in debugging and profiling. You can override the KAP
default of adding .cmp.c to the source program name with the
-cmp switch. See Section 4.7.1 for more information.
2.5 KAP Command Switches Determined by Compiler Switches
Some C compiler switches automatically set KAP command switches or alter the default switch settings.
Explicitly calling the compiler switch -std1 causes KAP to be called with the command switch -syntax=a.
Explicitly calling the compiler switch -standard=common causes KAP to be called with the command switch -syntax=k.
Calling the C compiler without any compiler switches or with the
compiler switch -std0 causes KAP to be called with the command
switch -syntax=d.
2.6 Invoking the C Preprocessor
The kcc command invokes the C preprocessor before transforming
a file with KAP. The name __KAP is defined for the C
preprocessor in order to include alternate code in some system include
files. Commands with the preprocess-only switch will terminate after
the C preprocessor phase.
2.7 Preprocessing a Program Using kapc
For C programs that do not contain C preprocessor commands such as #define, #include, #ifdef, or macro definitions, use the following command to execute KAP as a standalone preprocessor:
kapc [kap_switch_string] myprog.c -cmp=myprog.cmp.c |
The [kap_switch_string] is a list of one or more KAP command switches, for example:
kapc -inm -roundoff=2 myprog.c -cmp=myprog.cmp.c |
For C programs that contain C preprocessor commands, the input file must first be preprocessed with the C compiler. Use the following commands:
cc -P -D__KAP -U_INLINE_INTRINSICS myprog.c kapc -cmp=myprog.cmp.c myprog.i |
After preprocessing your program, give the optimized source file myprog.cmp.c to the compiler, as follows:
cc -migrate myprog.cmp.c -tune host -lkio -O4 |
cc -migrate myprog.cmp.c -tune host -lkio -fast |
For an explanation of the -migrate, -tune host, -lkio, -fast, and -U_INLINE_INTRINSICS switches, see Section 2.3.
When you use kapc to process a file, you must set the Compaq C compiler and linker switches appropriately. For this reason, Compaq recommends that you use kcc whenever possible, because kcc automatically sets the compiler and linker switches correctly. |
Specify switches in lowercase with the syntax -switch[=value]. Do not leave spaces between the switch name and the value. Switches can appear before or after the input file as follows:
kapc -inm myprog.c -roundoff=2 |
KAP recognizes standard abbreviations for switches. Switches that take a list of names must have the names separated by commas and without spaces, for example:
-inff=file1.c,file2.c |
Enclose KAP command switches passed through kcc by using the -ckapargs switch with single quotation marks, as follows:
kcc -ckapargs='-optimize=5 -roundoff=3 -scalaropt=3' -list myprog.c |
C compiler switches, for example, -list, do not require
quotation marks.
2.9 Using File Naming Conventions
Any input file name is acceptable. Output file names are written to stdout unless the -cmp command switch is specified.
When KAP detects an error condition, KAP writes a message to standard
error.
2.10 Introducing the Five-Minute KAP Guide
This section describes how you can get maximum performance in your application programs in the shortest time.
This information can be used with both multiprocessor and single-processor systems, and with both Fortran and C versions of all KAP products. Therefore, the information may contain references to command-line switches or settings that are unavailable or are different from those in the KAP that you are using.
This section provides separate protocols for small and large programs. Small programs are defined as those that can be compiled and run quickly. Because the cost of each iteration is small, you can take risks. The information presented here further assumes that small programs have a small number of program units.
Large programs are defined as those that take more time to compile and
run than it takes for you to check the results. A program can be large
either because the source code is very large or because the execution
time is long.
2.10.1 Optimizing Small Programs with KAP
Follow these guidelines to optimize small programs:
Next | Contents | Index |