Newsgroups: comp.parallel.pvm
From: Stuart D Blackburn <sdblackb@uncc.edu>
Subject: Re: Forcing PVM to spawn on all available hosts?
Organization: University of NC at Charlotte
Date: 2 May 1995 16:11:00 GMT
Message-ID: <3o5lik$spg@news.uncc.edu>

haferman@icaen.uiowa.edu (Jeff Haferman) wrote:
>
> 
> I'm programming in Fortran using PVM 3.3.4...
> 
> I have 4 hosts in my virtual machine, and I would like to
> spawn a task on each of the 4 machines.  However, using the
> syntax
>    call pvmfspawn('dompvm',PVMDEFAULT,'*',ntask,tids,info)
> sometimes results in pvm spawning multiple instances of 'dompvm'
> on a single host, and no instances on other hosts.
> 
> I could get around this using
>    call pvmfspawn('dompvm',PVMHOST,hostname,ntask,tids,info)
> but then I must explicitly give each hostname.  But since PVM has
> an internal list of all the hosts in the virtual machine, can
> I somehow tell it to use all of the available hosts?  (i.e. 
> "Start up a process on each available host, ignore your
> internal heuristic for task distribution")
> 
> The reason I want to do this is that each task requires 
> a significant portion of the memory available on each host,
> and spawning multiple tasks on each host will results in
> heavy swapping.
> 
> 
> -- 
> ==============================================================================
> +            Jeff Haferman                         PH: (319) 335-5384        +
> + Department of Mechanical Engineering             FX: (319) 335-5669        +
> +  and Center for Global and Regional            The University of Iowa      +
> +        Environmental Research                   Iowa City, IA  52242       +
> ==============================================================================
> + http://www.cgrer.uiowa.edu/people/haferman e-mail:haferman@icaen.uiowa.edu +
> ==============================================================================
> 
	There is a function called pvmfconfig for you to get configuration
information about your virtual machine. Among the info returned is a pointer
to an array of structures which contains info about each host including its
pvmd task ID, name, architecture, max. packet length, and relative speed.
Using this you can easily use a loop to spawn your process on all available
machines. As a test, I modified the hello program distributed with PVM
to start a hello_other process on all machines with the following code.
(I realize that this is C and you seem to be using Fortran, but there are
equivalent functions in PVM for both.)
	I hope that this helps.
--------------------------------------------------------------------
/* Hello2 which is the hello program except that it starts a hello_other process */
/* on every other machine in the vm */
#include <stdio.h>
#include "pvm3.h"

main()
{
	int i;
	int info;
	int nhosts, nproc = 0;
	int narch, bufid, tmptid;
	struct pvmhostinfo *host_ptr;
	char buf[100];
		
	printf("i'm t%x\n", pvm_mytid());

	/* spawn a hello_other process on every other host which is up */
	if ( info = pvm_config( &nhosts, &narch, &host_ptr) < 0 ) {
		printf("Warning pvm_config failed with value %i\n", info);
		pvm_exit();
		exit(1);
	} else {
		
		/* for each host in host_ptr list, spawn a hello_other process */
		for (i = 0; i < nhosts; i++)
		  if( pvm_spawn("hello_other", (char**)0, 1, host_ptr[i].hi_name,
		     1, &(tmptid)) == 1 )
		        nproc++;
		  else
		    	printf("Error: Could not start hello_other on %s\n", host_ptr[i].hi_name);

		for (i = 0; i < nproc; i++) {
		
		    bufid = pvm_recv(-1, -1);
		    pvm_bufinfo(bufid, (int*)0, (int*)0, &tmptid);
		    pvm_upkstr(buf);
		    printf("from t%x: %s\n", tmptid, buf);
		} /* End of for loop */
	} /* End of else */

	pvm_exit();
	exit(0);
}
--------------------------------------------------------------------
         _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
        _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
       _/_/   Stuart D. Blackburn, Computer Science Graduate Student   _/_/
      _/_/          University of North Carolina at Charlotte         _/_/ 
     _/_/    Graduate Teaching Assistant (CSCI 1201 and 1202 Labs)   _/_/
    _/_/      225 E. North St. (PO Box 1012), Albemarle, NC 28002   _/_/
   _/_/         Home: (704) 982 0763          Office: 547-4574     _/_/
  _/_/E-mail:sdblackb@uncc.edu (http://www.coe.uncc.edu/~sdblackb)_/_/
 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



