File: master

package info (click to toggle)
slpvm 0.1.5-17
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,184 kB
  • sloc: sh: 2,624; ansic: 1,012; makefile: 161
file content (48 lines) | stat: -rwxr-xr-x 1,092 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
#!/usr/bin/env slsh

require ("pvm_ms");

variable Slave_Pgm= path_concat (getcwd(), "slave");
if (__argc != 3)
{
   () = fprintf (stderr, "%s <remote-cmd> <N>\n", __argv[0]);
   exit (1);
}

static variable Cmd = __argv[1];
static variable N = integer (__argv[2]);

static define slave_spawned_callback (tid, host, argv)
{
   vmessage ("Slave running %s spawned on %s with task-id %d\n",
	     argv[0], host, tid);
}
pvm_ms_set_slave_spawned_callback (&slave_spawned_callback);

static define main ()
{
   variable pgm_argvs = Array_Type[N];
   variable pgm_argv = [Slave_Pgm, Cmd];

   pgm_argvs[*] = pgm_argv;

   % Make sure these variables are set up on the remote end
   %pvm_export ("SLSH_CONF_DIR");
   %pvm_export ("SLSH_PATH");
   
   pvm_ms_set_debug (0);
   %pvm_ms_set_hosts ("vex", "verus", "aluche");
   pvm_ms_set_num_processes_per_host (2);

   variable exit_status = pvm_ms_run_master (pgm_argvs);

   foreach (exit_status)
     {
	variable s = ();
	() = fprintf (stdout, "%s [exit %d]==>\n%s\n\n", 
		      Cmd, s.exit_status, s.stdout);
     }
   
   exit (0);
}
main ();