-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.txt
79 lines (52 loc) · 2.54 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
**************************************************************************
* *
* Functory: a distributed computing library for Ocaml *
* Copyright (C) 2010 Jean-Christophe Filliatre and Kalyan Krishnamani *
* *
* This software is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License version 2.1, with the special exception on linking *
* described in file LICENSE. *
* *
* This software is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
**************************************************************************
This is Functory mini tutorial.
Installation
============
./configure
make
sudo make install
Usage
=====
Assume you want to apply a function "map" such as
let map x = x+1
to some list elements such as
[1;2;3;4;5]
and sum the results with a function "fold" such as
let fold = (+)
You can do that using function "map_local_fold" from the library, as follows:
let () = Printf.printf "%d@." (map_local_fold ~map ~fold 0 [1;2;3;4;5])
The Functory library allows you to perform this computation in three
different ways: either sequentially, or using several cores on the
same machine, or using a network of different machines.
To use the sequential implementation, you simply use the following
line of code
open Functory.Sequential
To use several cores (say 4) on a single machine, you should add
instead
open Functory.Cores
let () = set_number_of_cores 4
Finally, to use a network of, say 2 cores on machine "mach1" and 4
cores on machine "mach2", you should add instead
open Functory.Network
let () = declare_workers ~n:2 "mach1"
let () = declare_workers ~n:4 "mach2"
Your program is compiled in the following way (in any case):
ocamlopt -I +functory unix.cmxa functory.cmxa <your files...>
and then run as usual. In the network case, the same program should be
run on the three machines, that are the two workers and the master.
(It is also possible to run different programs for master and workers;
see the documentation).