Setting up, starting, and halting the PVM cluster

First, copy and paste the following text into a local file called pvmhosts:
	ariessrv
	aries3
	aries4
	aries5
	aries6
	aries7
	aries8
	aries9
	aries1
	aries2
	aries10
	aries11
	aries12
	aries13
	aries14
	aries15
	aries16
	aries17
	aries18
	aries19
	aries20
	aries21
	aries22
	aries23
	
This is the file that tells pvm what machines to use in its cluster.

Second, run this at a shell prompt:

$ pvm pvmhosts
This command starts the cluster with the machines specified in pvmhosts. At the pvm> prompt, you can do:
pvm> conf
to verify that the cluster is correctly set up. The output should look similar to this:
	pvm> conf
	conf
	24 hosts, 1 data format
						HOST     DTID     ARCH   SPEED       DSIG
					ariessrv    40000    LINUX    1000 0x00408841
					  aries1    80000    LINUX    1000 0x00408841
					  aries2    c0000    LINUX    1000 0x00408841
					  aries3   100000    LINUX    1000 0x00408841
					  aries4   140000    LINUX    1000 0x00408841
					  aries5   180000    LINUX    1000 0x00408841
					  aries6   1c0000    LINUX    1000 0x00408841
					  aries7   200000    LINUX    1000 0x00408841
					  aries8   240000    LINUX    1000 0x00408841
					  aries9   280000    LINUX    1000 0x00408841
					 aries10   2c0000    LINUX    1000 0x00408841
					 aries11   300000    LINUX    1000 0x00408841
					 aries12   340000    LINUX    1000 0x00408841
					 aries13   380000    LINUX    1000 0x00408841
					 aries14   3c0000    LINUX    1000 0x00408841
					 aries15   400000    LINUX    1000 0x00408841
					 aries16   440000    LINUX    1000 0x00408841
					 aries17   480000    LINUX    1000 0x00408841
					 aries18   4c0000    LINUX    1000 0x00408841
					 aries19   500000    LINUX    1000 0x00408841
					 aries20   540000    LINUX    1000 0x00408841
					 aries21   580000    LINUX    1000 0x00408841
					 aries22   5c0000    LINUX    1000 0x00408841
					 aries23   600000    LINUX    1000 0x00408841
	

At this point, hit Ctrl-D to exit PVM. You should notice a message about pvmd still running. This is because even though you have exit the controlling terminal, the cluster is still active. You can confirm this by running pvm again; it should connect to the still-running cluster, and you should be able to verify this by running the conf command. Keep in mind:

$ pvm pvmhosts
is to start a cluster, but only
$ pvm
is needed to connect to an existing one.

To halt the cluster, use the command halt at the pvm> prompt. This will kill the pvmd on every machine and cleanly exit. You should always use this when you are done running your simulations. Additionally, should your simulation ever crash, it is advisable to restart the cluster using halt from inside pvm and pvm pvmhosts from the shell.

Using RPVM inside R code

We will use RPVM inside R through the SNOW library. Therefore, the first line in your R code should be:
		library(snow)
	

To set up an RPVM cluster through SNOW, use the following command:

		cl_pvm <-makeCluster(nclus, type = "PVM");
	
In this code, cl_pvm is the variable that represents your cluster, and nclus is the number of nodes you want in the cluster. Note that this need not be the same number as the number of hosts in your pvmhosts file. You can think of the RPVM cluster as being built on top of the PVM cluster you built in the previous section. It must be started and stopped separately, from within R. As such, the nodes in the RPVM cluster may be a subset of the nodes in the PVM cluster.

To stop an RPVM cluster, use the command:

		stopCluster(cl_pvm);
	
where cl_pvm is the same variable as you used before for your cluster.

To run a function over the cluster, the clusterCall comnmand is used. The syntax for this command is as follows:

		clusterCall(cl_pvm, cluster_func, ...)
	
In this code, cl_pvm is the same variable as you used before for your cluster, cluster_func is the function you wish to distribute over the cluster, and ... are the arguments to that function. For example, if you had a function F = function(x, y), you might run it sequentially like this:
		F(1, 2)
	
To run the same thing over the cluster, you would do:
		clusterCall(cl_pvm, F, x=1, y=2)