Using lustre-mt to parallelize a Lustre program
This tutorial will illustrate :
- How to create a task
- How to use the tool
lustre-mt
to parallelize these tasks
First, we need a Lustre V6 program with a node call.
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 parallelize tasks, we first need to declare them. We use
the pragma %MT:task1%
in front of a node call in order to do this.
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 need to compile with the
--2c-multi-task
(or -2cmt
for short) option in order to generate C
files with this task.
lv6 para_task.lus -n para --2c-multi-task
Compiling with the -2cmt
option will also generate a Yaml file. The C
files will not compile, and will require to generate another file
using the external tool lustre-mt
and this Yaml file.
lustre-mt para_task_para.yml
lustre-mt
generates 2 files, called wraptask.c
and wraptask.h
,
which contains functions to parallelize tasks. Now we can compile
with these new files :
gcc -lpthread -o para.exec *.c
And finally execute the program with parallel tasks :
./para.exec