Take advantage of multi-cores to speed-up Lustre V6 program executions
This tutorial illustrates :
- How to declare a task in Lustre V6
- How to compile programs with tasks into executable that performs tasks computation in parallel
nb: you need lv6 version v6.111.0 or higher.
Defining Tasks via --2c-multi-task-toplevel (or -2cmtt)
The first way to define tasks is by using the lv6 CLI. If you
compile your program using --2c-multi-task-toplevel (or -2cmtt
for short), all the nodes in the main node will be executed in a
different task.
Defining Tasks via Pragmas
The second, more versatile, way to define tasks is to use pragmas. Let’s illustrate this with a simple Lustre V6 program.
function A(in:int) returns (o:int);
let
o = in*2;
tel
node para(x, y:int) returns (o:int);
var a, b:int;
let
a = A(x);
b = A(y);
o = a+b;
tel
In order to perform computations in parallel, we need to declare node
calls as tasks, using the pragma %MT:some_task_name%.
function A(in:int) returns (o:int);
let
o = in*2;
tel
node para(x, y:int) returns (o:int);
var a, b:int;
let
a = A(x);
b = %MT:task1% A(y);
o = a+b;
tel
Now that we have declared a task, we can compile the node with the
--2c-multi-task (or -2cmt for short) option.
lv6 para_task.lus -n para --2c-multi-task
Compiling with the -2cmt option will also generate a Yaml file
para_task_para.yml. The generated C files contain C
functions that need to be defined to perform the actual parallelization
work. Those missing functions can be
- written by end-users, or
- generated using
lustre-mt(distributed withlv6) on the Yaml file.
lustre-mt para_task_para.yml
lustre-mt generates 2 files, wraptask.c and wraptask.h. Now we
can generate the executable (using the para.sh that has been
generated by the call to lv6 above), and run it:
sh para.sh
echo "1 1 q" | ./para.exec
A more advanced use of tasks is illustrated here: lustre-mt-expe