File: parallel.txi

package info (click to toggle)
octave-parallel 4.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,648 kB
  • sloc: ansic: 24,011; cpp: 6,848; sh: 4,476; makefile: 297; perl: 170; xml: 22
file content (540 lines) | stat: -rw-r--r-- 17,252 bytes parent folder | download
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
\input texinfo
@c %**start of header
@setfilename parallel.info
@settitle parallel_doc
@c %**end of header

@c Nowadays the predined function index has entries for each @deftypefn
@c in additiont to each @findex.
@defcodeindex mfn

@copying
General documentation for the parallel package for Octave.

Copyright @copyright{} 2016-2023 @email{Olaf Till <i7tiol@@t-online.de>}

You can redistribute this documentation and/or modify it under the terms
of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any
later version.

This documentation 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. See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License along
with this documentation; if not, see <http://www.gnu.org/licenses/>.
@end copying

@include macros.texi

@macro mysee
@ifhtml
see
@end ifhtml
@end macro

@ifinfo
@dircategory Math
@direntry
* Octave parallel: (parallel).                 Parallel package of Octave.
@end direntry
@end ifinfo

@titlepage
@title General documentation for the documentation package for Octave
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage

@c No table of contents. The table would occupy most of the top node in
@c html and IMHO misleads the user to use the table instead of the menu
@c structure of the nodes, which would let some information unused.
@c
@c @contents

@c ------------------------------------------------------------------

@node Top
@top General documentation for the parallel package for Octave

@ifhtml
The info version of this document is accessible, after package
installation, from the Octave commandline with @code{parallel_doc()}.
@end ifhtml

This documentation applies to version @PACKAGEVERSION of the parallel
package.

The package contains functions for explicit local parallel execution
and functions for parallel execution over a cluster of machines,
possibly combined with local parallel execution at each machine of the
cluster.

Earlier versions of the package used Octave sessions directly
generated by the @code{fork} system call. Since this causes problems,
the current version uses newly started Octave sessions, even for local
parallel execution. This causes some limitations, see
@ref{Limitations}.

The server for cluster execution is installed at GNU/Linux, but not at
some other operating systems, e.g. not at Windows or macOS. The client
functions for cluster execution should be installed at all systems,
though.

@menu
* Installation::                Installation hints.
* Local execution::             Functions for local parallel execution.
* Cluster execution::           Functions for parallel execution over a
                                  cluster of machines.
* Further functions::           Functions possibly helpful in parallel
                                  execution.
* Limitations::                 Limitations of high- and
                                  medium-level functions.

* Documentation::               Function parallel_doc to view
                                  documentation.

Indices
* Function index::              Index of functions in database.
* Concept index::               Concept index.
@end menu

@c ------------------------------------------------------------------

@node Installation
@chapter Installation hints
@cindex installation

@emph{Note:} For using a cluster of machines, identical versions of the
package are required to be installed at each machine.

Maybe your distribution provides the parallel package.

If not, or if you want a newer version, Octaves @code{pkg} command
allows building the package from source and installing it. Note that you
have to @code{load} any Octave package before you can use it. See
Octaves documentation of @code{pkg}.

Parallel execution over a cluster by default is protected by encryption
with authentication. This needs a version of the gnutls library in which
TLS-SRP is not disabled. For building the parallel package from source,
this library must be present during the build; some operating systems
provide development files of libraries in exta @code{...-dev} packages,
which are also needed during the build.

Building or using the package for cluster execution without gnutls will
work, but encryption and authentication are not available in this case.

@c ------------------------------------------------------------------

@node Local execution
@chapter Functions for local parallel execution
@cindex local execution

Explicit local parallel execution, with the intent to exploit more than
one local processor(-core), is performed by calling a user-defined
function in parallel with several different arguments. This is done in
parallel @emph{processes}. Note that there is no way to pass global
variables to or from these processes.

The interface of the functions for local parallel execution is similar
to Octaves @code{cellfun} and @code{arrayfun} functions.

Note that some operations in Octave, particularly some matrix
operations, may already be performed in parallel threads. This may limit
the advantage yielded by explicit local parallel execution. Also, RAM
access can be a bottleneck which limits computation speed of multicore
computing.

For limitations, see @ref{Limitations}.

@menu
* parcellfun::                        Function parcellfun.
* pararrayfun::                       Function pararrayfun.
* parcellfun_set_nproc::              Function parcellfun_set_nproc::
@end menu

@c ------------------------------------------------------------------

@node parcellfun
@section Function parcellfun
@mfnindex parcellfun

@c include function helptext here
@DOCSTRING(parcellfun)

@c ------------------------------------------------------------------

@node pararrayfun
@section Function pararrayfun
@mfnindex pararrayfun

@c include function helptext here
@DOCSTRING(pararrayfun)

See also @ref{XREFparcellfun,,parcellfun},
@ref{XREFarrayfun,,arrayfun,octave}.

@c ------------------------------------------------------------------

@node parcellfun_set_nproc
@section Function parcellfun_set_nproc
@mfnindex parcellfun_set_nproc

@c include function helptext here
@DOCSTRING(parcellfun_set_nproc)

@c ------------------------------------------------------------------

@node Cluster execution
@chapter Functions for parallel execution over a cluster of machines
@cindex cluster execution

There are high level functions, similar to @ref{parcellfun} and
@ref{pararrayfun}, which only require the user to provide a function to
be called and a series of argument sets. Parallel function calls are
then internally distributed over the cluster, and over the local
processors (or processor cores) within the single machines of the
cluster.

Medium and low level functions are also provided. These require the user
to program the scheduling of parallel execution.

Data transfer is possible between the client machine and each server
machine, but also directly between server machines. The latter feature
is exploited e.g. by the @ref{install_vars} function.

For limitations, see @ref{Limitations}.

@menu
* Security::                        Security considerations.
* Authentication::                  Generating authentication keys.
* pserver::                         Starting servers.

Connection-related functions
* pconnect::                        Establishing cluster connections.
* sclose::                          Closing cluster connections.
* network_get_info::                Get network information.
* network_set::                     Set network properties.

High level functions
* netcellfun::                      Function netcellfun.
* netarrayfun::                     Function netarrayfun.
* install_vars::                    Distribute Octave variables.

Medium level functions
* rfeval::                          Single remote function evaluation.

Low level functions
* psend::                           Sending Octave variables.
* precv::                           Receiving Octave variables.
* reval::                           Remote command evaluation.
* select_sockets::                  Call Unix @code{select} for data
                                      connections.

* Example::                         Example
@end menu

@c ------------------------------------------------------------------

@node Security
@section Security considerations
@cindex security

Over a connection to a server of the parallel package arbitrary Octave
commands can be executed at the server machine. This means that any
change can be done to the server system and the resident data, only
limited by the rights of the system account under which the server runs.

By default, the server is started with authentication and encryption
enabled, to avoid unauthorized access. If the server is started with
authentication disabled (maybe to avoid the encryption overhead), it
must be cared for that no TCP connection by unauthorized persons is
possible to the server ports, possibly by running the client and all
server machines behind a firewall and assuring that only trusted persons
have access to any machine behind the firewall. This scenario might be
achievable in home-nets.

The server currently uses port 12502 for receiving commands and port
12501 for data exchange.

The client and the servers used by the client with @code{pconnect} must
agree on using authentication or not.

Do not start the server as root.

@c ------------------------------------------------------------------

@node Authentication
@section Generating authentication keys
@cindex authentication
@mfnindex parallel_generate_srp_data

@c include function helptext here
@DOCSTRING(parallel_generate_srp_data)

@c ------------------------------------------------------------------

@node pserver
@section Starting servers
@mfnindex pserver

@c include function helptext here
@DOCSTRING(pserver)

@c ------------------------------------------------------------------

@node pconnect
@section Establishing cluster connections
@mfnindex pconnect

@c include function helptext here
@DOCSTRING(pconnect)

@c ------------------------------------------------------------------

@node sclose
@section Closing cluster connections
@mfnindex sclose

@c include function helptext here
@DOCSTRING(sclose)

@c ------------------------------------------------------------------

@node network_get_info
@section Get network information
@mfnindex network_get_info

@c include function helptext here
@DOCSTRING(network_get_info)

@c ------------------------------------------------------------------

@node network_set
@section Set network properties
@mfnindex network_set

@c include function helptext here
@DOCSTRING(network_set)

@c ------------------------------------------------------------------

@node netcellfun
@section Function netcellfun
@mfnindex netcellfun

@c include function helptext here
@DOCSTRING(netcellfun)

@c ------------------------------------------------------------------

@node netarrayfun
@section Function netarrayfun
@mfnindex netarrayfun

@c include function helptext here
@DOCSTRING(netarrayfun)

@c ------------------------------------------------------------------

@node install_vars
@section Distribute Octave variables
@mfnindex install_vars

@c include function helptext here
@DOCSTRING(install_vars)

@c ------------------------------------------------------------------

@node rfeval
@section Single remote function evaluation
@mfnindex rfeval

@c include function helptext here
@DOCSTRING(rfeval)

@c ------------------------------------------------------------------

@node psend
@section Sending Octave variables
@mfnindex psend

@c include function helptext here
@DOCSTRING(psend)

@c ------------------------------------------------------------------

@node precv
@section Receiving Octave variables
@mfnindex precv

@c include function helptext here
@DOCSTRING(precv)

@c ------------------------------------------------------------------

@node reval
@section Remote command evaluation
@mfnindex reval

@c include function helptext here
@DOCSTRING(reval)

@c ------------------------------------------------------------------

@node select_sockets
@section Call Unix @code{select} for data connections
@mfnindex select sockets

@c include function helptext here
@DOCSTRING(select_sockets)

@c ------------------------------------------------------------------

@node Example
@section Example
@cindex example

@example

# From Octave prompt, generate authentication files, set user name to
# 'test'. When prompted for a password, press <enter>.
parallel_generate_srp_data ('test')

# From Octave prompt, get location of the generated files.
authpath = fullfile (a = pkg ("prefix"), "parallel-srp-data")

Copy server files to servers, authpath is assumed to be
"/home/test/octave/parallel-srp-data/", the same directory is assumed to
exist on the servers. From the system shell, do e.g.:

scp -r /home/test/octave/parallel-srp-data/server server1:/home/test/octave/parallel-srp-data/
scp -r /home/test/octave/parallel-srp-data/server server2:/home/test/octave/parallel-srp-data/

Start server at remote machines. From the system shell, do e.g.:

ssh server1 'octave --eval "pserver"'
ssh server2 'octave --eval "pserver"'

# From Octave prompt, connect the cluster.
conns = pconnect (@{"server1", "server2"@})

# And perform some parallel execution. Single function calls take 1
# second each.
results = netcellfun (conns, @ (x) @{x, pause(1)@}@{:@}, num2cell (1:30))

# Close network.
sclose (conns)

@end example

@c ------------------------------------------------------------------

@node Further functions
@chapter Functions possibly helpful in parallel execution

@menu
* fsave fload::                 Transfer variable within the local
                                  machine over an Octave stream.
* select::                      Call Unix @code{select} on Octave
                                  streams.
@end menu

@c ------------------------------------------------------------------

@node fsave fload
@section Transfer variable within the local machine over an Octave stream
@mfnindex fsave
@mfnindex fload

@c include function helptext here
@DOCSTRING(fsave)

@c include function helptext here
@DOCSTRING(fload)

@c ------------------------------------------------------------------

@node select
@section Call Unix @code{select} on Octave streams
@mfnindex select

Note that for cluster connections @ref{select_sockets} should be used
instead.

@c include function helptext here
@DOCSTRING(select)

@c ------------------------------------------------------------------

@node Limitations
@chapter Limitations of high- and medium-level functions
@cindex limitations

Note that @ref{netcellfun}, @ref{netarrayfun}, and @ref{rfeval}, but
even @ref{parcellfun} and @ref{pararrayfun}, execute code in separate
Octave processes. This causes some limitations.

For the function handles passed as arguments to @ref{parcellfun},
@ref{pararrayfun}, @ref{netcellfun}, @ref{netarrayfun}, and
@ref{rfeval}, the following limitations may apply:

@itemize
@item In Octave versions before 5.1, anonymous functions may only be
passed if they don't use @code{varargin} and don't contain nested
anonymous functions.
@item If a handle to a named function, written in a function file,
is passed, this function must exist on the server machine. This is
usually no problem for @ref{parcellfun} and @ref{pararrayfun}.
@item Named functions defined in the command line interface or by
scripts are not exported to the working sessions used by
@ref{parcellfun} or @ref{pararrayfun}, and not automatically to the
server for remote parallel execution.
@item For handles to subfunctions or to private functions limitations
depending on the used Octave version may apply.
@end itemize

Anonymous functions should be usable as usual, since the function
specification sent to the server will include the anonymous functions
context.

If @ref{parcellfun} or @ref{pararrayfun} (and of course the
cluster-related functions, too) are called from within a function with
subfunctions, the subfunctions won't be visible in parallel execution.

There is no way to set global variables for the function called by
@code{parcellun} or @code{pararrayfun}. For cluster execution, setting
global variables is possible, e.g. with @ref{install_vars}; however,
@code{netcellfun} and @code{netarrayfun} won't 'see' global variables if
they use @code{parcellfun} internally (which is the default at remote
machines with more than one available processor core).

@c ------------------------------------------------------------------

@node Documentation
@chapter Function parallel_doc to view documentation
@cindex documentation
@mfnindex parallel_doc

@c include function helptext here
@DOCSTRING(parallel_doc)

@c ------------------------------------------------------------------

@node Function index
@unnumbered Index of functions in parallel

@printindex mfn

@c ------------------------------------------------------------------

@node Concept index
@unnumbered Concept index

@printindex cp

@bye