Next: Memory Allocation
Up: Application Programming Interface
Previous: Prototype Definition
void SMP_Init(void);
SUBROUTINE SMP_INIT
- initializes SMPlib parameters, should be the first thing
(other than those setting options such as
SMP_Setoption)
to call in an SMP program.
Environment variable SMP_TMPDIR is used to define the
directory for temporary SMPlib files, default to ``."
(the current working directory).
Environment variable SMP_DEBUG is checked.
int SMP_Fork(int num_procs);
INTEGER FUNCTION SMP_FORK(NUM_PROCS)
INTEGER NUM_PROCS
- forks ``
num_procs" processes and return the rank
(0 to num_procs-1) of the current process in the process group.
If num_procs=0, the environment variable SMP_NUM_PROCS
will be used.
If SMP_NUM_PROCS is undefined, no subprocess is created,
i.e. num_procs=1 is used.
Number of threads per process is defined by the environment
variable OMP_NUM_THREADS.
If OMP_NUM_THREADS is undefined, one (1) is assumed.
- error code:
SMP_ERR_NPROC, SMP_ERR_NTHR
int SMP_Forkthread(int num_procs, int num_threads[]);
INTEGER FUNCTION SMP_FORKTHREAD(NUM_PROCS, NUM_THREADS)
INTEGER NUM_PROCS, NUM_THREADS(0:*)
- forks ``
num_procs" processes and return the rank (0 to
num_procs-1) of the current process in the process group.
If num_procs=0, the environment variable SMP_NUM_PROCS
will be used.
If SMP_NUM_PROCS is undefined, no subprocess is created,
i.e. num_procs=1 is used.
In addition, num_threads[i] of threads is specified for
process i.
If num_threads[i] is 0, the variable OMP_NUM_THREADS
will be checked;
if OMP_NUM_THREADS is undefined, one (1) is assumed.
- error code:
SMP_ERR_NPROC, SMP_ERR_NTHR
void SMP_Finish(void);
SUBROUTINE SMP_FINISH
- finishes and cleans up things, should be called by all processes.
Any previously allocated shared memory buffers will be freed at
this point. All subprocesses perform a join function and only
the master process may continue execution after
SMP_Finish().
Use of this function is important for cases where only the master
process is allowed for further execution, such as, when mixing
SMP with MPI.
void SMP_Join(void);
SUBROUTINE SMP_JOIN
- joins all the forked processes, should be called by all processes.
This function is very similar to
SMP_Finish() except that
it does not free any previously allocated shared memory buffers.
Only the master process may continue execution after
SMP_Join().
Next: Memory Allocation
Up: Application Programming Interface
Previous: Prototype Definition
Haoqiang Jin
2005-08-10