[plain]

Today’s parallelism Industry standards The problems which led to the design of Sklml

OpenMP

MPI

Sklml’s parallelism Overview What Sklml is Sklml is:

What Sklml is not Sklml is not:

Programming in Sklml Sklml skeletons Sklml skeletons What is a skeleton A skeleton value is an OCaml value with type (α, β) skel, its input is of type α, its output of type β. The Sklml library provides skeletal combinators which might either

Sklml skeletons The farm skelton combinator The farm skeleton combinator is used when one treatment must be applied in parallel to a flow of data. val farm : (α, β) skel * int → (α, β) skel;;

=0ptpn 8ar 700 750 100 100 0 6.28319pa 1325 500pa 2075 500pa 2075 0pa 1325 0pa 1325 500fp=.5ex by 0.250in 1.700into 0ptFpa 1325 1500pa 2075 1500pa 2075 1000pa 1325 1000pa 1325 1500fp=.5ex by 1.250in 1.700into 0ptFar 2700 750 100 100 0 6.28319pa 0 750pa 600 750da 0.050=1exby -1 by 2 by .5ex by 0.750in 0.300into 0ptxpa 2800 750pa 3400 750da 0.050=1exby -1 by 2 by .5ex by 0.750in 3.100into 0ptF(x)sh 1.000pn 1pa 1235 301pa 1325 250pa 1270 337pa 1235 301fppn 8pa 800 750pa 1253 319fpsh 1.000pn 1pa 2545 663pa 2600 750pa 2510 699pa 2545 663fppn 8pa 2075 250pa 2528 681fpsh 1.000pn 1pa 1270 1163pa 1325 1250pa 1235 1199pa 1270 1163fppn 8pa 800 750pa 1253 1181fpsh 1.000pn 1pa 2510 801pa 2600 750pa 2545 837pa 2510 801fppn 8pa 2075 1250pa 2528 819fpdepth1.500in width0pt height 0pt3.400in
1em


farm (F, 2) skeleton graph

Sklml skeletons The pipeline skeleton combinator The pipeline skeleton combinator is used when a composition of two functions must be applied to a flow of data. val ( ||| ) :
  (α, β) skel → (β, γ) skel → (α, γ) skel;;

=0ptpn 8pa 0 250pa 500 250da 0.050=1exby -1 by 2 by .5ex by 0.250in 0.250into 0ptxar 600 250 100 100 0 6.28319sh 1.000pn 1pa 900 225pa 1000 250pa 900 275pa 900 225fppn 8pa 700 250pa 900 250fppa 1000 500pa 1500 500pa 1500 0pa 1000 0pa 1000 500fp=.5ex by 0.250in 1.250into 0ptFsh 1.000pn 1pa 1700 225pa 1800 250pa 1700 275pa 1700 225fppn 8pa 1500 250pa 1700 250fppa 1800 500pa 2300 500pa 2300 0pa 1800 0pa 1800 500fp=.5ex by 0.250in 2.050into 0ptGsh 1.000pn 1pa 2500 225pa 2600 250pa 2500 275pa 2500 225fppn 8pa 2300 250pa 2500 250fpar 2700 250 100 100 0 6.28319pa 2800 250pa 3500 250da 0.050=1exby -1 by 2 by .5ex by 0.250in 3.150into 0ptG(F(x))depth0.500in width0pt height 0pt3.500in
1em


G ||| F skeleton graph

Sklml skeletons The loop skeleton combinator The loop skeleton combinator is a control combinator, it iterates a skeleton on a data until a given predicate turns to be false. val loop :
  (α, bool) skel * (α, α) skel → (α, α) skel;;

=0ptpn 8ar 700 250 100 100 0 6.28319sh 1.000pn 1pa 1200 225pa 1300 250pa 1200 275pa 1200 225fppn 8pa 800 250pa 1200 250fppa 1300 500pa 2050 500pa 2050 0pa 1300 0pa 1300 500fp=.5ex by 0.250in 1.675into 0ptFsh 1.000pn 1pa 2450 225pa 2550 250pa 2450 275pa 2450 225fppn 8pa 2050 250pa 2450 250fpar 2650 250 100 100 0 6.28319ar 1675 1250 200 200 0 6.28319=.5ex by 1.250in 1.675into 0ptPsh 1.000pn 1pa 675 450pa 700 350pa 725 450pa 675 450fppn 8pa 1475 1250pa 700 1250pa 700 360spsh 1.000pn 1pa 1975 1275pa 1875 1250pa 1975 1225pa 1975 1275fppn 8pa 2650 350pa 2650 1250pa 1885 1250sppa 0 250pa 600 250da 0.050=1exby -1 by 2 by .5ex by 0.250in 0.300into 0ptxpa 2750 250pa 3350 250da 0.050=1exby -1 by 2 by .5ex by 0.250in 3.050into 0ptFn(x)depth1.450in width0pt height 0pt3.350in
1em


loop (P, F) skeleton graph

Example Simple example Introducing the example Problem Find the first element which does not satisify a given property P. Testing this property is expensive and must be done in parallel.

Two functions are provided:

This problem is taken from the test PrimeGen, a generator of primes satisfying strong cryptographic properties. This test can be found in the standard Sklml distribution.

[fragile] Simple example The actual Sklml code In Sklml:

let find_skl nw =
  loop ( farm (test_elm, nw) ||| fold_or,
         next_elms ) in
  ...

In C:

do {
    elm = next_elm(elm);
} while (test_elm(elm) == True);

Interacting with Sklml Sklml and the other languages Sequential parts of Sklml programs can be written:

Old code can be reused with Sklml! Inside Sklml Sklml distribution Sklml is a set of 4 components written both in OCaml and Sklml:

Sklml’s key feature (1) Fact Skeletal combinators have simple sequential semantics. As a consequence, two compilation modes are proposed, a sequential interpretation of skeletal combinators and a parallel one.

Two semantics in practice Compile either in parallel mode: sklmlc -mode par code.ml Or in sequential mode: sklmlc -mode seq code.ml

Sklml’s key feature (2) Moreover, the Sklml system guaranty that:

Thus:

  1. develop and debug using the sequential semantics and compilation;
  2. start the heavy thing by simply changing a flag in the makefile.

Sklml and OCaml 3.12 Sklml, because of its high abstraction, uses not so regular features of the OCaml language.

Future directions Things to do Sklml is already usable but it can be improved:

End That’s all folks!


This document was translated from LATEX by HEVEA.