Skip to main content

Software  >  Rational  >  

Using the MASS libraries on AIX

 Product documentation
 
Abstract
This document describes how to call MASS library functions from an application, compile and link an application with the MASS libraries, and how to use the vector source library. Prototypes and interface blocks of all MASS functions are also provided.
 
 
Content
Calling MASS scalar library functions from an application

Because MASS does not check its environment, the scalar library must be called with the IEEE rounding mode set to round-to-nearest and with exceptions masked off (the default environment in both XL Fortran and XL C/C++). MASS may not work properly with other settings.

The library uses some global names for shared tables. The global names have the form %...$.

In Fortran, except rsqrt, all the functions have the same names as the corresponding Fortran intrinsic functions, so interface blocks are not necessary. Since rsqrt is not a Fortran intrinsic function, you need to include the file mass.include in the calling program to provide the appropriate interface block.

In C/C++, to provide the prototypes for all the scalar MASS functions except dnint, you need to include the file math.h in the calling program. To provide a prototype for dnint (which accepts a pointer to a double argument), include the file mass.h in the calling program.

Also note that when called from C/C++ code, the functions in libmass.a will not set the global variable errno to indicate range, domain, or loss of precision errors. For instance, with libm.a sqrt(-1) will return the value NaN (not a number) and will set errno to 33 (EDOM -- domain error); with libmass.a sqrt(-1) simply returns NaN but does not set errno.

The links at the bottom of the page give Fortran and C declarations for the functions. The purpose of each function is given as a comment.

Compiling and linking an application with the MASS scalar library

To use libmass.a, use -lmass in the linker command line. For example, if the library is installed in the standard directory /usr/lib/, the command lines for Fortran and C would be:

 xlf progf.f -o progf -lmass
 cc progc.c -o progf -lmass

If libmass.a is installed in a directory other than in /usr/lib, such as in /home/somebody/mass, use the -L option to add that directory to the library search path:

 xlf progf.f -o progf -L/home/somebody/mass -lmass
 cc progc.c -o progf -L/home/somebody/mass -lmass


Selective compiling and linking with the MASS scalar library

If you wish to use libmass.a for some functions and the normal libm.a for the remainder, you can use an export list with the ld command. For instance, to select only the fast tangent routine from libmass.a for use with the C program sample.c:

1. Create an export list containing the names of the desired functions. In this case, the file fast_tan.exp will contain only one line:

 tan

2. Pull the exported routines into an object file using the ld command with libmass.a.

ld -bexport:fast_tan.exp -o fast_tan.o -bnoentry -lmass   -bmodtype:SRE  

(or, if libmass.a is not in /usr/lib)

ld -bexport:fast_tan.exp -o fast_tan.o -bnoentry -L/some/other/path -lmass -bmodtype:SRE  

(or, if you would like the 64-bit versions of the exported functions)

ld -bexport:fast_tan.exp -o fast_tan.o -b64 -bnoentry -lmass -bmodtype:SRE  

3. Archive the object file into a library with the ar command.

ar -q libfasttan.a fast_tan.o

4. Create the final executable using cc, specifying fast_tan.o before the standard math library, libm.a. This will link only the tan routine from MASS (now in fast_tan.o) and the remainder of the math subroutines from the standard system library:

  cc sample.c -o sample -lfasttan -lm

(Note: The routines sin and cos, and atan and atan2, are coded together, so selecting fast sin will also automatically link in fast cos; selecting atan will also link atan2.)

Calling MASS vector library functions from an application

As with the scalar functions, the vector functions must be called with the IEEE rounding mode set to round-to-nearest and with exceptions masked off. When calling the vector functions from C/C++, only call by reference is supported, even for scalar arguments.

The vector function subroutines may be used as any C, C++ or Fortran subroutines. Except for vdiv, vsincos, vcosisin, vatan2, vdfloat, vidint, and vdsign, the functions in libmassv.a, libmassvp3.a, and libmassvp4.a are all of the form function_name (y,x,n), where x is the source vector, y is the target vector, and n is the vector length. The arguments y and x are assumed to be long-precision (real*8) for functions with the prefix v, and short-precision (real*4) for functions with the prefix vs. The three-argument subroutines are all used in the same way. For example, in Fortran:

    .....
   DIMENSION X(500),Y(500)
   .....
   CALL VEXP(Y,X,500)
   .....

returns a vector Y of length 500 whose elements are exp(X(i)); i=1,...,500.

The functions vdiv, vsincos, and vatan2 are of the form function_name(x,y,z,n). The function vdiv returns a vector x whose elements are y(i)/z(i), i=1,n. The function vsincos returns two vectors, x and y, whose elements are sin(z(i)) and cos(z(i)) respectively. The function vatan2 returns a vector x whose elements are atan(y(i)/x(i)).

In vcosisin(y,x,n), x is a vector of n real*8 elements and the function returns a vector y of n complex*16 elements of the form (cos(x(i)),sin(x(i))).

To obtain the vector function prototypes in C/C++ programs, include the file massv.h in the calling program. To obtain the vector function interface blocks in Fortran programs, include the file massv.include in the calling program.

The links at the bottom of the page give Fortran and C declarations for the functions. The purpose of each function is given as a comment.

Compiling and linking an application with the MASS vector library

To use the faster MASS libraries in an application that has been vectorized, simply use the corresponding library name or names in the linker command line. For instance, when the library is installed in the standard directory /usr/lib/, the command lines for Fortran and C to use the libmassvp4.a library would be:

  xlf progf.f -o progf -lmassvp4
 
cc progc.c -o progf -lmassvp4

If libmassv.a is installed in a directory other than /usr/lib, such as in /home/somebody/mass, use the -L option to add that directory to the library search path:

 xlf progf.f -o progf -L/home/somebody/mass -lmassvp4
cc progc.c -o progf -L/home/somebody/mass -lmassvp4

Using the vector source library

The recommended procedure for writing portable code that is vectorized for using the fast MASS vector libraries, is to write in ANSI standard language and use the vector functions defined by libmassv.f or libmassv.c. Then, to prepare to run on a system other than an IBM pSeries or RS/6000 system, compile the application source code together with the libmassv.f or libmassv.c source. The vector syntax to be used is visible in the libmassv.f and libmassv.c source. Commenting out one line of the vrsqrt subroutine, which is a directive to the IBM XL Fortran compiler, may be necessary for full portability.

When running the application on an IBM pSeries or RS/6000 system, the faster MASS vector libraries can be linked as described above.

WARNING: Do not use libmassv.f or libmassv.c on IBM pSeries and RS/6000 systems. Use the -lmassv, -lmassvp3, -lmassvp4, -lmassvp5, or -lmassvp6 flags instead. The source vector library should be used as a portable substitute for the MASS vector libraries only on non-IBM systems.

 
Related information
MASS C/C++ function prototypes for AIX
MASS Fortran interface blocks for AIX
 
 
Cross Reference information
Segment Product Component Platform Version Edition
pSeries Unix Servers (incl pSeries Intellistation)pSeries - Enterprise Servers
RS/6000 (Servers and Workstations)RS/6000 Enterprise Servers
Operating SystemsAIX family AIXAll Versions
Software DevelopmentXL C Enterprise Edition for AIXNot ApplicableAIXAll Versions
Software DevelopmentVisualAge C++ AIXAll versions
Software DevelopmentXL C/C++ AIX, AIX5L, AIXLAll Versions
Software DevelopmentXL FortranAIX, AIXLAll versions
 
 

Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.
Rate this page
Please take a moment to complete this form to help us better serve you.
This material provides me with the information I need.




This material is clear and easy to understand.




Did the information help you to achieve your goal?
What updates, improvements, or related information would you like to see in this document?
Your response will be used to improve our document content. Requests for assistance, if applicable, should be submitted through your normal support channel as we cannot respond from this site.
Input the verification number to submit feedback:
Document information
 Product categories:
 Software
 Software Development
 Traditional Progamming Language & Compilers
 Mathematical Acceleration Subsystem
 Libraries
 Operating system(s):
  AIX, AIX5L, AIXL
 Software version:
  All
 Reference #:
  7005375
 IBM Group:
 Software Group
 Modified date:
 2004-10-04

Translate My Page
 
 

Rate this page

Help us improve this page. Your response will be used to improve our document content. Requests for assistance, if applicable, should be submitted through your normal support channel as we cannot respond from this site.