Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Floating-Point Guide: HP 9000 Computers > Chapter 1 Introduction

Overview of HP-UX Math Libraries

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Basic operations such as addition and multiplication are specified by the IEEE standard. More complex mathematical operations such as logarithmic and trigonometric functions are provided by math library routines. The high-level operations of math library routines are specified not by the IEEE standard but by individual language standards (such as ISO/ANSI C) and by programming environment specifications (such as X/Open and SVID).

C math library functions are located in the libm math library. The libm functions operate according to the C standard and the latest versions of the System V Interface Definition (currently SVID3) and of the X/Open Portability Guide (currently XPG4.2). The XPG4.2 specification is a superset of the POSIX.1 standard (IEEE Std 1003.1-1990). The SVID3 and XPG4.2 specifications are compatible. The libm library also supports many functions and macros that the ISO/ANSI C committee has included in the C9X draft standard (the proposed new ISO/ANSI C standard).

Fortran and Pascal intrinsic functions are located in the libcl library. In addition, Basic Linear Algebra Subroutine (BLAS) library routines are provided in the libblas library (provided with the HP Fortran 90 and HP ­FORTRAN/9000 products only).

Table 1-1 “HP-UX Math Libraries” lists the math libraries available on HP-UX systems and shows the option you specify to the compiler or linker in order to link in each library.

Table 1-1 HP-UX Math Libraries

Library Name

Description

Linker Option

libm

C math library; ANSI C, POSIX, XPG4.2, and SVID specifications

-lm

libcl

Fortran and Pascal library

Linked in automatically by f90, f77, and pc commands; use -lcl with other compiler commands

libblas

Basic Linear Algebra Subroutine (BLAS) library (provided with the HP Fortran 90 and HP FORTRAN/9000 products only)

-lblas

 

Math Libraries and System Architecture

At Release 11.0, HP-UX systems provide math libraries that run on two different architectures:

  • PA-RISC 1.1 (a 32-bit architecture), abbreviated PA1.1

  • PA-RISC 2.0 (a 64-bit architecture), which can run in both narrow mode (32-bit mode, abbreviated PA2.0N) and wide mode (64-bit mode, abbreviated PA2.0W)

The HP-UX math libraries in the directory /usr/lib are 32-bit libraries targeted to PA1.1 and PA2.0 systems. The math libraries in the directory /usr/lib/pa20_64 are 64-bit libraries targeted to PA2.0 systems, and run only on those systems.

The HP Fortran 90 and HP FORTRAN/9000 products supply two versions of the BLAS library, one specially tuned for PA1.1 systems, the other specially tuned for PA2.0 narrow mode.

When you compile a program on a PA2.0 system at HP-UX Release 11.0, the compiler by default generates PA2.0N code. To generate PA2.0W code, you need to specify the +DA2.0W option (see “Selecting Different Versions of the Math Libraries”).

All HP 9000 systems except the oldest Series 800 systems are PA1.1-based or PA2.0-based. If you do not know your system's architecture type, see “Determining Your System's Architecture Type”.

For complete information about the math libraries, see Chapter 4 “HP-UX Math Libraries on HP 9000 Systems”.

Determining Your System's Architecture Type

There are two main ways to find the architecture type of your system. To do it from the command line:

  1. Issue the command uname -m to learn the model number of your system. For example:

    $ uname -m 
    9000/879
  2. Look up the second part of the model number in the file /opt/langtools/lib/sched.models to find its architecture type. For example:

    $ grep 879 /opt/langtools/lib/sched.models
    879 2.0 PA8000

    The 2.0 indicates that a Model 879 is PA2.0-based.

You can also learn the system architecture type at run time. A simple program that gives you useful information follows.

Example 1-1 Sample Program: get_arch.c

#include <stdio.h>
#include <sys/utsname.h>

extern int _SYSTEM_ID;
extern int _CPU_REVISION;

struct utsname uts;

int main(void)
{
uname(&uts);
printf("Release = %s\n", uts.release);
printf("_SYSTEM_ID = %x\n", _SYSTEM_ID);
printf("_CPU_REVISION = %x\n", _CPU_REVISION);
}

The uts.release is the release of HP-UX on the system where you run the program. The _SYSTEM_ID is the kind of code the compiler generated. The _CPU_REVISION is the architecture type.

If you compile this program on a PA1.1 system, then run it on a PA2.0 system running HP-UX Release 11.0, you get results like the following:

Release = B.11.00
_SYSTEM_ID = 210
_CPU_REVISION = 214

The release, 11.00, is easy to decipher. To decode the other results, search the file /usr/include/sys/unistd.h:

$ grep 210 /usr/include/sys/unistd.h 
# define CPU_PA_RISC1_1 0x210 /* HP PA-RISC1.1 */
$ grep 214 /usr/include/sys/unistd.h
/# define CPU_PA_RISC2_0 0x214 /* HP PA-RISC2.0 */

The compiler generated PA1.1 code, which is running on a PA2.0 system.

Selecting Different Versions of the Math Libraries

If you use a compilation command (f90, cc, and so on) to invoke the link editor (ld), the selection of math libraries is driven by the +DA compiler option.

By default, the compiler generates code for the kind of system on which you are running the compiler. This ensures the best possible performance on that system. If you compile on a PA2.0 system, by default the compiler generates narrow-mode code.

Table 1-2 “Code-Generation Compiler Options at HP-UX Release 11.0” describes the code-generation compiler options.

Table 1-2 Code-Generation Compiler Options at HP-UX Release 11.0

OptionSynonymsCode GeneratedRuns on
+DA1.1+DD32 (C only), +OportablePA1.1All PA systems running HP-UX 11.0 or later
+DA2.0+DA2.0NPA2.0 narrow modeAll PA2.0 systems running HP-UX 11.0 or later
+DA2.0W+DD64 (C only)PA2.0 wide modePA2.0 (HP-UX 11.0 wide-mode kernels only)

 

If your application must run on both PA1.1 and PA2.0 systems, compile with +DA1.1. Code compiled with +DA2.0 or +DA2.0W will run only on PA2.0 systems.

The +DA option determines not only the code generated by the compiler but also the library search path chosen by the linker. For example, if you invoke the HP Fortran 90 compiler with +DA2.0, it contains the following:

/opt/fortran90/lib/pa2.0
/opt/fortran90/lib
/usr/lib
/opt/langtools/lib

Not all HP-UX compilers support the generation of 64-bit code. The following compilers support the +DA2.0W option:

  • HP C (cc)

  • HP ANSI C++ (aCC)

The following compilers support +DA1.1 and +DA2.0, but not +DA2.0W:

  • HP Fortran 90 (f90)

  • HP FORTRAN/9000 (f77)

  • HP C++ (CC)

  • HP Pascal (pc)

Locations of the Math Libraries at Release 11.0

At Release 11.0, the main HP-UX math libraries are in the directory /usr/lib. The BLAS library is in both /opt/fortran90/lib and /opt/fortran/lib. The obsolete vector library exists only in /opt/fortran/old/lib.

Table 1-3 “Math Library Path Names” shows the math library path names.

Table 1-3 Math Library Path Names

Library Path Name

Description

/usr/lib/libm.a

C math library, archive version, PA1.1

/usr/lib/libm.2

C math library, shared version, PA1.1

/usr/lib/pa20_64/libm.a

C math library, archive version, PA2.0 wide mode

/usr/lib/pa20_64/libm.2

C math library, shared version, PA2.0 wide mode

/usr/lib/libcl.a

Compiler library (includes Fortran math library), archive version, PA1.1

/usr/lib/libcl.2

Compiler library (includes Fortran math library), shared version, PA1.1

/usr/lib/pa20_64/libcl.a

Compiler library (includes Fortran math library), archive version, PA2.0 wide mode

/usr/lib/pa20_64/libcl.2

Compiler library (includes Fortran math library), shared version, PA2.0 wide mode

/usr/lib/milli.a

PA1.1 and PA2.0 narrow-mode millicode library: versions of several math library routines, available only if you compile with +Olibcalls. For details, see “Millicode Versions of Math Library Functions”.

/usr/lib/pa20_64/milli.a

PA2.0 wide-mode millicode library.

/opt/fortran90/lib/libblas.a

Basic Linear Algebra Subroutine (BLAS) library, PA1.1 archive version (provided with the HP Fortran 90 product)

/opt/fortran90/lib/pa2.0/libblas.a

Basic Linear Algebra Subroutine (BLAS) library, PA2.0 narrow-mode archive version (provided with the HP Fortran 90 product)

/opt/fortran/lib/libblas.a

Basic Linear Algebra Subroutine (BLAS) library, PA1.1 archive version (provided with the HP FORTRAN/9000 product)

/opt/fortran/lib/pa2.0/libblas.a

Basic Linear Algebra Subroutine (BLAS) library, PA2.0 narrow-mode archive version (provided with the HP FORTRAN/9000 product)

/opt/fortran/old/lib/libvec.a

Vector library, PA1.1 and PA2.0 narrow-mode archive version (provided with the HP FORTRAN/9000 product only) (obsolete)

 

Figure 1-1 “Math Library Directory Hierarchy at Release 11.0” illustrates the directory hierarchy for the math libraries.

Figure 1-1 Math Library Directory Hierarchy at Release 11.0

Math Library Directory Hierarchy at Release 11.0
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997 Hewlett-Packard Development Company, L.P.