File: pvm-4.html

package info (click to toggle)
slpvm 0.1.5-11
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,072 kB
  • ctags: 254
  • sloc: sh: 2,624; ansic: 1,012; makefile: 154
file content (386 lines) | stat: -rw-r--r-- 12,545 bytes parent folder | download | duplicates (6)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
 <TITLE> S-Lang PVM Module Reference: Master-Slave Function Reference</TITLE>
 <LINK HREF="pvm-5.html" REL=next>
 <LINK HREF="pvm-3.html" REL=previous>
 <LINK HREF="pvm.html#toc4" REL=contents>
</HEAD>
<BODY>
<A HREF="pvm-5.html">Next</A>
<A HREF="pvm-3.html">Previous</A>
<A HREF="pvm.html#toc4">Contents</A>
<HR>
<H2><A NAME="s4">4.</A> <A HREF="pvm.html#toc4">Master-Slave Function Reference</A></H2>



<H2><A NAME="pvm_ms_kill"></A> <A NAME="ss4.1">4.1</A> <A HREF="pvm.html#toc4.1"><B>pvm_ms_kill</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Send a "task complete" message to a specific task</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_kill (Int_Type mtid, Int_Type stid)</CODE></P>
<DT><B> Description </B><DD><P>This function may be used to send a "task complete" message
to a specific PVM process.  The first argument gives
the task identifier of the destination process.  The second
argument gives the task identifier of the sending process.</P>
<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
  tid = pvm_mytid ();
  ptid = pvm_parent ();
  pvm_ms_kill (ptid, tid);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_slave_exit">pvm_ms_slave_exit</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_set_num_processes_per_host"></A> <A NAME="ss4.2">4.2</A> <A HREF="pvm.html#toc4.2"><B>pvm_ms_set_num_processes_per_host</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Set the maximum number of simultaneous processes per host</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_set_num_processes_per_host (Int_Type num_processes)</CODE></P>
<DT><B> Description </B><DD><P>This function is used to set the maximum number of simultaneous
processes per host.  The master process normally runs as many
simultaneous processes as possible;  by setting the maximum
number of simultaneous processes per host, one can limit the
processing load per host.</P>
<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
  pvm_ms_set_num_processes_per_host (2);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_run_master">pvm_ms_run_master</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_set_debug"></A> <A NAME="ss4.3">4.3</A> <A HREF="pvm.html#toc4.3"><B>pvm_ms_set_debug</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Set the debug flag</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_set_debug (Int_Type debug)</CODE></P>
<DT><B> Description </B><DD><P>This function may be used to control whether debugging
information is printed out during execution.  Debugging
information is printed if the flag is non-zero.</P>
<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
  pvm_ms_set_debug (1);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_set_num_processes_per_host">pvm_ms_set_num_processes_per_host</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_slave_exit"></A> <A NAME="ss4.4">4.4</A> <A HREF="pvm.html#toc4.4"><B>pvm_ms_slave_exit</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Cause a normal exit of a slave process from the PVM</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_slave_exit (Int_Type exit_status)</CODE></P>
<DT><B> Description </B><DD><P>To exit the PVM, a slave process calls this function to
send its exit status to the parent process and to notify
the local <CODE>pvmd</CODE> of its exit.</P>
<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
    pvm_ms_slave_exit (exit_status);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_run_slave">pvm_ms_run_slave</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_run_slave"></A> <A NAME="ss4.5">4.5</A> <A HREF="pvm.html#toc4.5"><B>pvm_ms_run_slave</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Execute the slave's assigned task in a subshell, then exit the PVM</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_run_slave (String_Type argv[])</CODE></P>
<DT><B> Description </B><DD><P>A slave process calls this function to run a command in a
subshell and then exit the PVM.  The command line is
constructed by concatenting the elements of an array of
strings, <CODE>argv</CODE>, delimited by spaces. The integer return
value from the <CODE>system</CODE> call provides the exit status
for the slave process.  After sending this value to its
parent process, the slave notifies the PVM and exits.</P>
<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
   pvm_ms_run_slave (argv);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_slave_exit">pvm_ms_slave_exit</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_run_master"></A> <A NAME="ss4.6">4.6</A> <A HREF="pvm.html#toc4.6"><B>pvm_ms_run_master</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Submit a list of tasks to the PVM</P>
<DT><B> Usage </B><DD><P><CODE>Struct_Type exit_status[] = pvm_ms_run_master (String_Type pgms[])</CODE></P>
<DT><B> Description </B><DD><P>This function is used to submit a managed list of tasks to
the PVM.  The task list manager will try to ensure that all
tasks are completed and, upon completion of the task list,
will return an array of structures containing information
about the results of each task.</P>

<DT><B> Example </B><DD><P>To run the Unix command <I>ps xu</I> on a number of different
hosts:
<BLOCKQUOTE><CODE>
<PRE>
    variable slave_argv = Array_Type[n];
    slave_argv[*] = ["ps", "axu"];
    exit_status = pvm_ms_run_master (slave_argv);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_add_new_slave">pvm_ms_add_new_slave</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_add_new_slave"></A> <A NAME="ss4.7">4.7</A> <A HREF="pvm.html#toc4.7"><B>pvm_ms_add_new_slave</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Add a new slave to the managed list</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_add_new_slave (String_Type argv[])</CODE></P>
<DT><B> Description </B><DD><P>This function may be used to add a new slave process
while pvm_ms_run_master() is running, usually as a result
of handling a message.</P>
<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
    pvm_ms_add_new_slave ("vex");
</PRE>
</CODE></BLOCKQUOTE>
</P>
<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_run_master">pvm_ms_run_master</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_set_message_callback"></A> <A NAME="ss4.8">4.8</A> <A HREF="pvm.html#toc4.8"><B>pvm_ms_set_message_callback</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Set a callback for handling user-defined messages</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_set_message_callback (Ref_Type func)</CODE></P>
<DT><B> Description </B><DD><P>This function may be used to handle user-defined messages
be sent from slave processes back to the master process.</P>
<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>

 static define handle_user_message (msgid, tid)
 {
    switch (msgid)
      {
       case USER_SLAVE_RESULT:
           recv_results (tid);
           start_task (tid);
      }
      {
       case USER_SLAVE_READY:
           start_task (tid);
      }
      {
         % default:
           return 0;
      }
    return 1;
 }

 pvm_ms_set_message_callback (&amp;handle_user_message);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_set_idle_host_callback">pvm_ms_set_idle_host_callback</A>, 
<A HREF="#pvm_ms_set_slave_exit_failed_callback">pvm_ms_set_slave_exit_failed_callback</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_set_slave_exit_failed_callback"></A> <A NAME="ss4.9">4.9</A> <A HREF="pvm.html#toc4.9"><B>pvm_ms_set_slave_exit_failed_callback</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Set a hook to be called when a slave exits on failure</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_set_slave_exit_failed_callback (Ref_Type func)</CODE></P>
<DT><B> Description </B><DD><P>This function may be used to have the master process perform a
specified action whenever a slave process exits without having
completed its assigned task.</P>
<P>This is primarily useful in the context where each command-line
submitted to <CODE>pvm_ms_run_master</CODE> represents a task which
itself communicates with the PVM, performing potentially many
additional tasks which are independently managed by the
process that called <CODE>pvm_ms_run_master</CODE>.</P>
<P>For example, consider a case in which initialization of slave
processes is very expensive but, once initialized, a single
slave process may perform many tasks.  In this case, the
master process may spawn a small number of slaves and then
repeatedly send each slave a task to perform.  Each slave
performs its task, sends the result to the master, and then
waits for another task. The managing process must keep track
of which tasks have been completed and which remain. If a
slave exits while working on a task, it is important that the
manager process be notified that that task in progress was not
completed and that it should be reassigned to another slave.</P>

<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
   static define slave_exit_failed_callback (msgid, tid)
   {
      variable t = find_task_tid (tid);

      if (orelse {t == NULL} {t.status == FINISHED})
        return;

      % mark the unfinished task "READY" so that it will
      % be assigned to another slave

      t.tid = -1;
      t.status = READY;
   }

   pvm_ms_set_slave_exit_failed_callback (&amp;slave_exit_failed_callback);
</PRE>
</CODE></BLOCKQUOTE>
</P>

<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_set_message_callback">pvm_ms_set_message_callback</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_set_slave_spawned_callback"></A> <A NAME="ss4.10">4.10</A> <A HREF="pvm.html#toc4.10"><B>pvm_ms_set_slave_spawned_callback</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Set the slave spawned callback hook</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_set_slave_spawned_callback (Ref_Type func)</CODE></P>
<DT><B> Description </B><DD><P>This function may be used to specify a callback function to be
called whenever a slave process has been spawned.  The callback
function will be called with three arguments: the slave task
id, the name of the host running the slave process, and an
array of strings representing the argument list passed to the
slave.</P>

<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
   static define slave_spawned_callback (tid, host, argv)
   {
      vmessage ("Slave running %s spawned on %s with task-id %d",
                argv[0], host, tid);
   }
   pvm_ms_set_slave_spawned_callback (&amp;slave_spawned_callback);
</PRE>
</CODE></BLOCKQUOTE>
</P>

<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_set_message_callback">pvm_ms_set_message_callback</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_set_idle_host_callback"></A> <A NAME="ss4.11">4.11</A> <A HREF="pvm.html#toc4.11"><B>pvm_ms_set_idle_host_callback</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Set the idle host hook</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_set_idle_host_callback (Ref_Type func)</CODE></P>
<DT><B> Description </B><DD><P>This function may be used to specify a callback function to be
called whenever a new host is added to the virtual machine.</P>
<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
 static define idle_host_callback ()
 {
    loop (Max_Num_Processes_Per_Host)
      {
         variable slave_argv = build_slave_argv (0);
         pvm_ms_add_new_slave (slave_argv);
      }
 }
 pvm_ms_set_idle_host_callback (&amp;idle_host_callback);
</PRE>
</CODE></BLOCKQUOTE>
</P>

<DT><B> See Also </B><DD><P><CODE>
<A HREF="#pvm_ms_set_message_callback">pvm_ms_set_message_callback</A></CODE></P>
</DL>
</P>


<H2><A NAME="pvm_ms_set_hosts"></A> <A NAME="ss4.12">4.12</A> <A HREF="pvm.html#toc4.12"><B>pvm_ms_set_hosts</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Set list of hosts to use</P>
<DT><B> Usage </B><DD><P><CODE>pvm_ms_set_hosts (String_Type hosts[])</CODE></P>
<DT><B> Description </B><DD><P>This function may be used to specify which hosts will be used
to perform distributed calculations.  The default is to use
all hosts in the current PVM.</P>
<DT><B> Example </B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
      pvm_ms_set_hosts (["vex", "pirx", "aluche"]);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<DT><B> See Also </B><DD><P><CODE>
<A HREF="pvm-5.html#pvm_addhosts">pvm_addhosts</A></CODE></P>
</DL>
</P>



<HR>
<A HREF="pvm-5.html">Next</A>
<A HREF="pvm-3.html">Previous</A>
<A HREF="pvm.html#toc4">Contents</A>
</BODY>
</HTML>