Step 3: Inserting calls to parallel functions

In the main task, insert a call to tinit() to initialize the MTF environment before to any other MTF function call, or after tterm() is invoked. Replace each segment of code that was identified for parallel computation with a call to tsched() which schedules the corresponding parallel function. If more parallel function instances are scheduled than tasks are currently available, the additional instances are queued for subsequent execution in the order in which they were scheduled. They are queued for any task or to a particular task according to the task_id parameter supplied on the tsched() call. If parallel operation is to be achieved by scheduling the same function multiple times with different data, the function call may be placed within a loop.

The arguments passed to the parallel function may be:
The following items must not be used as the arguments supplied to the parallel function using tsched():

After inserting calls to the parallel functions, insert a call to tsyncro() wherever the program requires that any subtask, one particular subtask, or all of the subtasks have finished executing the parallel functions previously scheduled to them. As the last MTF call, insert a call to tterm() before to exit/return from the main task program to remove the MTF environment.

To properly use MTF from the main task program it is necessary to include the mtf.h header file before to the first MTF call in your program. MTF calls themselves can be issued from non-main as well as main functions within the main task program, subject only to the restrictions already described above. MTF calls, however, can only be issued from C functions and not from functions written in any other language.

The next sections show examples of how to change existing C programs to use MTF following the steps just outlined.