Parallel Programming Guide for HP-UX Systems

Parallel synchronization
Thread-parallelism
Chapter 8 135
Thread-parallelism
Only one level of parallelism is supported: thread-parallelism. If you
attempt to spawn thread-parallelism from within a thread-parallel, your
directives on the inner thread-parallel construct are ignored.
Thread ID assignments
Programs are initiated as a collection of threads, one per available
processor. All but thread 0 are idle until parallelism is encountered.
When a process begins, the threads created to run it have unique kernel
thread IDs. Thread 0, which runs all the serial code in the program, has
kernel thread ID 0. The rest of the threads have unique but unspecified
kernel thread IDs at this point. The num_threads() intrinsic returns the
number of threads created, regardless of how many are active when it is
called.
When thread 0 encounters parallelism, it spawns some or all of the
threads created at program start. This means it causes these threads to
go from idle to active, at which point they begin working on their share of
the parallel code. All available threads are spawned by default, but this
is changed using various compiler directives.
If the parallel structure is thread-parallel, then num_threads() threads
are spawned, subject to user-specified limits. At this point, kernel thread
0 becomes spawn thread 0, and the spawned threads are assigned spawn
thread IDs ranging from 0..num_threads()-1. This range begins at what
used to be kernel thread 0.
If you manually limit the number of spawned threads, these IDs range
from 0 to one less than your limit.