Skip to main content

Software  >  Rational  >  

Using the MASS libraries on Linux

 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 libraries.
 
 
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, the functions have the same names as the corresponding Fortran intrinsic functions, so interface blocks are not necessary. In C/C++, to provide the prototypes for the scalar MASS functions, you need to include the file math.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.

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 or libmass_64.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 [or -q64 -lmass_64]

  xlc progc.c -o progf -lmass [or -q64 -lmass_64]

If libmass.a is installed in another directory, 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 [or -q64 -lmass_64]

  xlc progc.c -o progf -L/home/somebody/mass -lmass [or -q64 -lmass_64]

Calling MASS vector library functions from an application

The MASS 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 Fortran, C or C++ function subroutines. The functions in the vector libraries 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 or double) for functions whose prefix is v, and short-precision (real*4 or float) for functions with prefix vs. The three-argument subroutines are all used in the same way. For example in Fortran:

     INCLUDE 'MASSV.INCLUDE'     .....

     REAL*8 X(500),Y(500)     .....

     CALL VSQRT(Y,X,500)     .....

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

In C:

     #include "massv.h"

     int const n = 500;    

     double x[n], y[n];

     ...     vsqrt(y,x,&n);

returns a vector y of length 500 whose elements are sqrt(x[i]), i=0,...,499.

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 libraries

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

    xlf prog.f -o prog -lmassvp4

    xlc prog.c -o prog -lmassvp4

    xlC prog.C -o prog -lmassvp4

For 64-bit mode, add the compiler option -q64 and replace -lmassvp4 with -lmassvp4_64.

If libmassvp4.a is installed in a different directory such as in /home/somebody/mass, use the -L option to add that directory to the library search path:

    xlf prog.f -o prog -L/home/somebody/mass -lmassvp4

    xlc prog.c -o prog -L/home/somebody/mass -lmassvp4 -lm

    xlC prog.C -o prog -L/home/somebody/mass -lmassvp4 -lm

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. For Fortran, commenting out the @PROCESS lines, which are directives to the IBM XL Fortran compiler, may be necessary for full portability.

When running the application on an IBM pSeries or RS/6000, 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 -lmassvp4, -lmassvp4_64, -lmassvp5, -lmassvp5_64, -lmassvp6, or -libmassvp6_64 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 prototype declarations
MASS Fortran interface blocks
 
 
Original publication date
2004/9/16
 
Cross Reference information
Segment Product Component Platform Version Edition
pSeries Unix Servers (incl pSeries Intellistation)pSeries - Enterprise Servers
Operating SystemLinux
 
 

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):
  Linux
 Software version:
  All
 Reference #:
  7005471
 IBM Group:
 Software Group
 Modified date:
 2005-01-14

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.