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 some functions and macros approved by the ISO/ANSI C committee for inclusion in the C9X draft standard.

NOTE: The libM library, which formerly supported XPG and POSIX while the libm library supported SVID, is obsolete now that these standards are compatible. The various versions of libM now exist only as soft links to the corresponding versions of libm. (See “Locations of the Math Libraries at Release 10.30” for details.)

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

The libm and libcl math libraries on HP-UX operating system at Release 10.30 and later are targeted primarily to the PA-RISC 1.1 architecture (PA1.1). They also run well on PA-RISC 2.0 (PA2.0) systems.

The libraries will execute on all HP 9000 systems that run HP-UX Release 10.30 and later.

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

NOTE: The PA-RISC 1.0 architecture is no longer supported, and the PA1.0 libraries are no longer provided on HP-UX systems.

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 at HP-UX Release 10.x. 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 10.30, you get results like the following:

Release = B.10.30
_SYSTEM_ID = 210
_CPU_REVISION = 214

The release, 10.30, 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, which allows you to generate PA1.1 code (+DA1.1) or PA2.0 code (+DA2.0). 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 your application must run on both PA1.1 and PA2.0 systems, compile with +DA1.1. Code compiled with +DA2.0 will run only on PA2.0 systems.

When you select +DA1.1 or +DA2.0, the compilation command invokes ld with a library search path that begins with the PA1.1 library directories. Again, the search path may vary from compiler to compiler. 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

Locations of the Math Libraries at Release 10.30

At Release 10.30, 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.

NOTE: The PA1.0 libraries are no longer provided.

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

Table 1-2 Math Library Path Names

Library Path Name

Description

/usr/lib/libm.a

C math library, archive version

/usr/lib/libm.sl

C math library, shared version

/usr/lib/libcl.a

Compiler library (includes Fortran math library), archive version

/usr/lib/libcl.sl

Compiler library (includes Fortran math library), shared version

/usr/lib/milli.a

Millicode versions of several math library routines, available only if you compile with +Olibcalls. For details, see “Millicode Versions of Math Library Functions”.

/opt/fortran90/lib/libblas.a

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

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

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

/opt/fortran/lib/libblas.a

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

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

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

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

Vector library, archive version (provided with the HP FORTRAN/9000 product only) (obsolete)

 

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

Figure 1-1 Math Library Directory Hierarchy at Release 10.30

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