[torquedev] sorting node names in pbstop

Gareth.Williams at csiro.au Gareth.Williams at csiro.au
Thu Aug 28 16:07:04 MDT 2008


Hi Jonathan,

I happen to know this has already been fixed.  In the version I have,
the foreach line is:
        foreach my $node ( node_sort_func($server, $allnodes->{$server})
) {
And there are multiple options for the node_sort_func.

You should get a more recent version of pbstop as described near the top
of the script.

#  Latest version of this software may be found at:
#      http://www-rcf.usc.edu/~garrick/perl-PBS
#  Please send comments to garrick at usc.edu.

Cheers,

Gareth 

> -----Original Message-----
> From: torquedev-bounces at supercluster.org 
> [mailto:torquedev-bounces at supercluster.org] On Behalf Of 
> Jonathan Billings
> Sent: Friday, 29 August 2008 4:32 AM
> To: torquedev at supercluster.org
> Subject: [torquedev] sorting node names in pbstop
> 
> Hi,
> 
> I noticed that pbstop (from .../torque-2.3.3/contrib) used the default
> alphanumeric sort in perl for node names when displaying the list of
> nodes for the grid.  Since I've used a couple clusters that had an
> unfortunate naming scheme that didn't zero justify the numbers, the
> grid wouldn't have the cluster nodes in the correct order.
> 
> For example, on an SGI altix, the node r1i3n10 sorts before r1i3n2,
> and on a rocks cluster, compute-1-10 sorts before compute-1-2.
> 
> I've created a patch that fixes this behavior by only comparing the
> numeric parts of the node name (and falling back to the normal
> comparison when no numbers are found.
> 
> Here's the patch I'm using.  I realize this is a purely cosmetic fix
> but I think the 'pbstop' utility is useful.
> 
> --- torque-2.3.3/contrib/pbstop.pbstopfix	2008-08-28 
> 14:15:01.000000000 -0400
> +++ torque-2.3.3/contrib/pbstop	2008-08-28 
> 14:25:34.000000000 -0400
> @@ -730,7 +730,19 @@
>      foreach my $server (keys %$allnodes ) {
>  
>          my (@cluster, @ts);
> -        foreach my $node ( sort keys %{$allnodes->{$server}} ) {
> +        foreach my $node ( sort {
> +            # turn the string into an array of numbers
> +            my @a = $a =~ /(\d+)/g;
> +            my @b = $b =~ /(\d+)/g;
> +            my $t;
> +            # iterate through the arrays, comparing each element
> +            while (@a and @b) {
> +                return $t if ($t = shift(@a) <=> shift(@b)) != 0;
> +            }
> +            # Return an alphanumeric sort if all numbers match or
> +            # if there are no numbers.
> +            return $a cmp $b;
> +        } keys %{$allnodes->{$server}} ) {
>              $$allnodes{$server}{$node}{np} > $maxnodegrid
>                  ? push(@ts, $node)
>                  : push(@cluster, $node);
> 
> 
> -- 
> Jonathan Billings <jsbillin at umich.edu>
> The College of Language, Science and Arts
> LS&A IT - Research Systems and Support
> _______________________________________________
> torquedev mailing list
> torquedev at supercluster.org
> http://www.supercluster.org/mailman/listinfo/torquedev
> 
> 


More information about the torquedev mailing list