Prev | Next | ta_parallel_setup |
thread_alloc::parallel_setup(num_threads, in_parallel, thread_num)
num_thread
is equal to one,
for thread_alloc
to hold onto memory.
This can be accomplished using the function call
thread_alloc::hold_memory(true)
see hold_memory
.
size_t num_threads
and must be greater than zero.
It specifies the number of threads that are sharing memory.
The case
num_threads == 1
is a special case that is
used to terminate a multi-threading environment.
bool in_parallel(void)
It must return true
if there is more than one thread
currently executing.
Otherwise it can return false.
In the special case where
num_threads == 1
,
the routine
in_parallel
is not used.
size_t thread_num(void)
It must return a thread number that uniquely identifies the
currently executing thread.
Furthermore
0 <= thread_num() < num_threads
.
In the special case where
num_threads == 1
,
the routine
thread_num
is not used.
Note that this function is called by other routines so,
as soon as a new thread is executing,
one must be certain that
thread_num()
will
work for that thread.
parallel_setup
must be called before
the program enters parallel
execution mode.
In addition, this function cannot be called while in parallel mode.