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
Fortran 90, Fortran 77, C, aC++: Exemplar Programming Guide > Appendix F Compiler Parallel Support Library

Accessing CPSlib

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

C and C++ programs using CPSlib functions must include the following header file:

#include <cps.h>

To access errno symbolic constant values in C or C++, you must also include the following header file:

#include <errno.h>

The Fortran 90, Fortran 77, aC++, and C compilers share a common interface to CPSlib; the same library, libcps.sl, allows access to the CPSlib functions from any of the languages.

In the Exemplar compilers, CPSlib is automatically linked in only at +O3 (and above) when +Oparallel is specified. If your program explicitly calls CPSlib routines or calls other libraries that use CPS routines and you are not linking at +O3 (or +O4) with +Oparallel, you must explicitly link in CPSlib as shown in the example below.

Assume prog.c contains calls to CPSlib routines:

% cc prog.c -lpthread -lcps -lpthread

Linking in CPSlib requires specifying—in the order given—all of the string -lpthread -lcps -lpthread. The pthread library is required because CPSlib uses Pthreads routines. Pthreads routines can be used independently of CPSlib. For more information on using Pthreads, see the pthread(3t) man page or the book Programming with Threads on HP-UX (B2355-90060).

CPSlib and MP_NUMBER_OF_THREADS

CPSlib checks the value of the MP_NUMBER_OF_THREADS environment variable to determine how many processors to generate code for. This variable is read at runtime. If this variable is set to some positive integer n, your program executes on n processors; n must be less than or equal to the number of processors in the system where the program is executing. The default value for MP_NUMBER_OF_THREADS is 1.

The following command line shows the C shell syntax to use when setting the variable to 8 processors:

% setenv MP_NUMBER_OF_THREADS 8

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.