raw_master_slave
There are instances when tasks are most naturally generated deep
inside nested loops. In such circumstances, it may be difficult to
re-write the code to create a function GenerateTaskInput(), since
that would require turning the loops inside out. (If you don't know what this
refers to, then you probably don't need "raw_master_slave".)
A typical usage of these functions for raw master-slave mode is:
/* variable not_done initialized to 1, and changed to 0 when done */
TOPC_raw_begin_master_slave(do_task, check_task_result, update_shared_data);
if TOPC_is_master() {
while ( ! done || TOPC_raw_wait_for_task() ) {
...
TOPC_raw_submit_task_input( task_input );
...
}
}
TOPC_raw_end_master_slave();
TOPC_raw_submit_task_input(input) serving
the role of GenerateTaskInput(). The slave blocks inside
TOPC_raw_begin_master_slave() and executes do_task() and
update_shared_data() until the master executes
TOPC_raw_end_master_slave(). At that time, the slave
unblocks. The slave does nothing inside
TOPC_raw_end_master_slave().
TOPC_raw_begin_master_slave()
and TOPC_raw_end_master_slave(); Typical usage is:
TOPC_raw_submit_task_input(TOPC_MSG(&input_data,
sizeof(input_data)) );
The argument, input, corresponds to what would be returned by
GenerateTaskInput() in the routine TOPC_master_slave().
input will be processed by DoTask() and its siblings,
just as in TOPC_master_slave()).
There can be multiple occurrences of
TOPC_raw_submit_task_input().
Go to the first, previous, next, last section, table of contents.