Newsgroups: comp.parallel.pvm
From: john@elroy.jpl.nasa.gov (John Wright)
Subject: Re: Multiprocessor Question
Organization: Image Analysis Systems Group, JPL
Date: 24 Oct 1995 14:34:59 GMT
Message-ID: <46itij$2nh@elroy.jpl.nasa.gov>

In article <46gf0r$aq1@netnews.upenn.edu>,
Jeff Taylor <jeff@Adeno.wistar.upenn.edu> wrote:
>	OK I've received some helpful replies explaining that only one pvmd
>is needed and that the SGIMP pvmd should be smart enough to spawn processes
>on different nodes.  This seems to be true but I still have some questions 
>and I'll use the 'hitc.f and hitc_slave.f' examples that came with the 
>distribution.  
>	When hitc begins it calls pvmfconfig to find out how many hitc_slaves 
>to spawn.  This call fails in that it only counts my SGIMP machine as one 
>instead of 8.  For example if I start pvm only on the SGIMP, pvmfconfig will 
>return 1.  If I force the issue by adding a line to hitc.f that says "nhost=8"
>then all is well and eight hitc_slaves are spawned, one on each processor.  
>	I would like to be able to add this SGIMP host (or any other host in
>my cluster) dynamically from my application when it isn't too busy so it 
>would be helpful if pvmd could recognize that there are multiple processors
>available.  I suppose I could check the PVM_ARCH variable and if it is SGIMP
>increase nhost by 8 instead of 1, but what if I have multiple SGIMP hosts with
>different numbers of processors?
>
>Thanks for your help, PVM is great!
>
>Jeff Taylor
>

My trick was to use the speed value in the hostfile to encode
the number of cpus on each host.  Since the speed value isn't
used for much by pvm, I use the 10 least significant bits to
contain the number of cpus.  This allows for speeds in the
same order of magnitude as pvm expects (1024 vs 1000) while
allowing my code to determine the number of cpus on each host.
Just call pvm_config and then mask off the upper bits.  The
following example illustrates how to check for a given host
in the network and then determine how many cpus it has:

        status = pvm_config(&num_hosts, &num_archs, &host_ptr);
        if(pvm_mstat(hostname) != PvmOk) {
            fprintf(stderr,"Whoops - Host %s not in virtual
net.\n",hostname);
            host_status = HOST_UNAVAILABLE;
        } else {
            host_status = HOST_IDLE;
            for(i=0; i<num_hosts; i++) {
                if(!strcmp(hostname,host_ptr[i].hi_name)) {
                        name = strdup(host_ptr[i].hi_name);
                        architecture = strdup(host_ptr[i].hi_arch);
                        speed = host_ptr[i].hi_speed;
                        if(speed != 1000) {
                                num_cpus = speed & 0x3ff;
                                speed = speed & ~0x3ff;
                        } else {
                                num_cpus = 1;
                        }
 
Hope this helps.

John


-- 
John.R.Wright@jpl.nasa.gov
---Signature under construction---
(I quail at the impossibility of capturing the 
essence of myself in four lines in an ASCII file)

