Changeset 1977

Show
Ignore:
Timestamp:
04/28/08 12:01:52 (2 weeks ago)
Author:
peter
Message:

tsuite/auto/run_parallel.pl:

Set default # of processors to all available processors (Linux & Windows only).

tsuite/auto/runall.pl:

Replace runall.pl with stub that simply calls run_parallel.pl.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tsuite/auto/runall.pl

    r1881 r1977  
    1 #perl -w 
     1#!/usr/bin/perl 
     2 
     3# This script calls the run_parallel.pl script to run the test suite 
     4# in parallel on suitable machines. The syntax is: 
    25# 
    3 # This is a perl script to run all the input files in a directory. 
    4 # this IS NOT the main auto run script that happens every night  
    5 # that is autorun.pl 
     6# runall.pl cloudy.exe 
    67# 
    7 # It is designed to be executed from the directory where the input files live. 
    8 # The string "$exe" must be modified to point to your executable version 
    9 # of cloudy. 
     8# or 
     9
     10# runall.pl cloudy.exe 16 
     11
     12# where the first parameter is the name of the Cloudy executable. It 
     13# should either be in your search path, or the full pathname should 
     14# be used. The second number is the number of processors to use. It 
     15# can be any number >= 0. However, using numbers larger than roughly 
     16# 16 will not give any speed advantage since the time will then be 
     17# set by the longest running test sims. The second number is optional 
     18# and will default to the number of processosrs on your computer 
     19# (this number is only correctly determined under Linux and Windows, 
     20# it will be set to 1 on other systems). 
     21
     22# If the number of processors is set to 0, the script will exit after 
     23# creating the Makefile (i.e., the test suite will not be run). 
     24
     25# NB NB - The script will first delete any remaining output from a 
     26# previous run of the test suite by calling the script clean_tsuite.pl 
     27# (this includes calls with the number of processors set to 0) ! 
     28
     29# The script uses "gmake" (GNU make) to run the test cases. In case 
     30# that doesn't exist, you can try replacing the two calls below with 
     31# "make". If the version is not too old, that should work as well 
     32# provided it supports the -j parameter for parallel execution. 
     33
     34# Peter van Hoof 
    1035 
    11 # after all the models are run the "checkall.pl" script can be run 
    12 # to check that everything went ok 
    13  
    14 # if there is already an exe file in this dir, back it up before 
    15 # bringing in a new one, in case we need to run the old models 
    16 if(-e "trunk.exe" ) 
    17 
    18    system("copy \"trunk.exe\" \"cloudy_bak.exe\" "); 
    19 
    20  
    21 # the path to the executable version of the code 
    22  
    23 #$exe = "c:/projects/cloudy/trunk/icl/release/cloudy_icl.exe"; 
    24 #$exe = "c:/projects/cloudy/trunk/source/sys_icl/cloudy.exe"; 
    25  
    26 #$exe = "c:/Projects/Cloudy/trunk/debug/trunk.exe"; 
    27 $exe = "c:/projects/cloudy/trunk/release/trunk.exe"; 
    28  
    29 #$exe = "c:/Projects/Cloudy/trunk/vs08/debug/vs08.exe"; 
    30 #$exe = "c:/projects/cloudy/trunk/vs08/release/vs08.exe"; 
    31  
    32 #$exe = "c:/projects/cloudy/newmole/debug/newmole.exe"; 
    33 #$exe = "c:/projects/cloudy/newmole/icl/release/cloudy_icl.exe"; 
    34  
    35 #$exe = "c:/projects/cloudy/trunk/gcc/release/cloudy_gcc.exe"; 
    36 #$exe = "c:/projects/cloudy/trunk/source/sys_gcc/cloudy.exe"; 
    37  
    38 # count total number of sims we compute 
    39 $nMod = 0; 
    40  
    41 # sets number to skip - will start tests after skipping the first 
    42 # nSkip in alphabetical order.  set to 0 to so all sims 
    43 $nSkip = 0; 
    44  
    45 # total number to do, usually much larger than the total 
    46 # to do them all 
    47 $nLimit = 700; 
    48  
    49 # loop over the *.in files 
    50 # and runs the test, producinig the *.out files 
    51 while ( defined( $input = glob("*.in") ) ) 
    52 
    53         if ( $nMod>=$nSkip  && $nMod < $nLimit ) 
    54         { 
    55                 print( "$input going to " ); 
    56                 $output = $input; 
    57                 $output =~ s/\.in//gi; 
    58                 if( -e "$output".".out" ) 
    59                 { 
    60                         rename( "$output".".out" , "$output".".bak" ); 
    61                 } 
    62                 $out = "$output".".out"; 
    63                 print("$output\n"); 
    64                 # actually execute the code, first uses nice 
    65 #               system "nice -n 5 $exe < $input  > $out"; 
    66                 system "$exe < $input  > $out"; 
    67         } 
    68         ++$nMod; 
    69 
    70  
    71 print("\n=========================\n"); 
    72 printf( "\n %i simulations were computed, and %i were skipped.\n ",$nMod,$nSkip); 
    73 print("Now use the checkall.pl script to check results.\n"); 
    74 print("=========================\n"); 
     36system "./run_parallel.pl @ARGV"; 
  • trunk/tsuite/auto/run_parallel.pl

    r1456 r1977  
    33# I have written a little perl script that runs the test suite in 
    44# parallel on suitable machines. The syntax is: 
     5# 
     6# run_parallel.pl cloudy.exe 
     7# 
     8# or 
    59# 
    610# run_parallel.pl cloudy.exe 16 
     
    913# should either be in your search path, or the full pathname should 
    1014# be used. The second number is the number of processors to use. It 
    11 # can be any number >= 1. However, using numbers larger than roughly 
     15# can be any number >= 0. However, using numbers larger than roughly 
    1216# 16 will not give any speed advantage since the time will then be 
    13 # set by the longest running test sims. 
     17# set by the longest running test sims. The second number is optional 
     18# and will default to the number of processosrs on your computer 
     19# (this number is only correctly determined under Linux and Windows, 
     20# it will be set to 1 on other systems). 
     21
     22# If the number of processors is set to 0, the script will exit after 
     23# creating the Makefile (i.e., the test suite will not be run). 
     24
     25# NB NB - The script will first delete any remaining output from a 
     26# previous run of the test suite by calling the script clean_tsuite.pl 
     27# (this includes calls with the number of processors set to 0) ! 
    1428# 
    1529# The script uses "gmake" (GNU make) to run the test cases. In case 
     
    1731# "make". If the version is not too old, that should work as well 
    1832# provided it supports the -j parameter for parallel execution. 
    19 # The script may need some other tinkering too, but I find it very 
    20 # useful here. 
     33
    2134# Peter van Hoof 
    2235 
    2336if( "$ARGV[0]" eq "" ) { 
    24     print "The name for the cloudy binary must be supplied...\n"; 
     37    print "The path to the cloudy binary must be supplied as the first parameter to this script...\n"; 
    2538    exit; 
    2639} 
    2740 
    2841if( "$ARGV[1]" eq "" ) { 
    29     print "The number of processors must be supplied...\n"; 
    30     exit; 
     42#     the following should work under Windows. 
     43    $nproc = $ENV{'NUMBER_OF_PROCESSORS'}; 
     44    if( $nproc eq "" ) 
     45    { 
     46#         this branch is for non-Windows 
     47        if( -r "/proc/cpuinfo" ) 
     48        { 
     49#             this branch is for Linux 
     50            $nproc = 0; 
     51            open( foo, "</proc/cpuinfo" ); 
     52            while( <foo> ) 
     53            { 
     54                if( /^processor/ ) 
     55                { 
     56                    ++$nproc; 
     57                } 
     58            } 
     59            close( foo ); 
     60        } 
     61        else 
     62        { 
     63#             we don't know how to determine the number of CPUs 
     64            $nproc = 1; 
     65        } 
     66    } 
     67
     68else { 
     69    $nproc = $ARGV[1]; 
    3170} 
    3271 
     
    4786    $i++; 
    4887    $output = $input; 
     88    $output2 = $input; 
    4989    $output =~ s/\.in/.out/gi; 
     90    $output2 =~ s/\.in/.err/gi; 
    5091    $all = "$all$output "; 
    5192    if( $i%4 == 0 ) { 
     
    5394    } 
    5495    $rules = "$rules$output: $input\n"; 
    55     $rules = "$rules\t$ARGV[0] < $input > $output\n" 
     96    $rules = "$rules\t$ARGV[0] < $input > $output 2> $output2\n" 
    5697} 
    5798open( foo, ">Makefile" ); 
     
    62103 
    63104# if number of processors is 0 only create Makefile and exit 
    64 if( $ARGV[1] > 0 ) { 
     105if( $nproc > 0 ) { 
     106    print "\nNow I will run the test suite using $nproc processors\n\n"; 
     107 
    65108#     this does the heavy lifting... 
    66109#     try make instead if gmake doesn't exist on your system 
    67     system "gmake -i -j $ARGV[1]"; 
     110    system "gmake -i -j $nproc"; 
    68111 
    69112#     this was produced by the optimizers and is not really part of the test suite 
     
    71114    unlink "optimal.in"; 
    72115 
    73     if( $ARGV[1] > 1 ) { 
     116    if( $nproc > 1 ) { 
    74117#         just in case func_trans_read was run before func_trans_punch was complete 
    75118        unlink "func_trans_read.out"; 
    76119#         try make instead if gmake doesn't exist on your system 
    77         system "gmake -i -j $ARGV[1]"; 
     120        system "gmake -i -j $nproc"; 
    78121    } 
    79122