root/trunk/tsuite/slow/run_parallel.pl
| Revision 2065, 3.6 kB (checked in by peter, 8 months ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | # I have written a little perl script that runs the test suite in |
| 4 | # parallel on suitable machines. The syntax is: |
| 5 | # |
| 6 | # run_parallel.pl cloudy.exe |
| 7 | # |
| 8 | # or |
| 9 | # |
| 10 | # run_parallel.pl cloudy.exe 16 |
| 11 | # |
| 12 | # where the first parameter is the name of the Cloudy executable. |
| 13 | # If the parameter is completely omitted (or a "." is entered), it |
| 14 | # will default to "../../source/cloudy.exe". You can also supply the |
| 15 | # name of one of the sys_xxx directories, in which case the path will |
| 16 | # default to "../../source/sys_xxx/cloudy.exe". In all other cases |
| 17 | # cloudy.exe should either be in your search path, or the full pathname |
| 18 | # should be used. The second number is the number of processors to use. |
| 19 | # It can be any number >= 0. The second number is optional and will |
| 20 | # default to the number of processosrs on your computer (this number is |
| 21 | # only correctly determined under Linux and Windows, it will be set to |
| 22 | # 1 on other systems). |
| 23 | # |
| 24 | # If the number of processors is set to 0, the script will exit after |
| 25 | # creating the Makefile (i.e., the test suite will not be run). |
| 26 | # |
| 27 | # NB NB - The script will first delete any remaining output from a |
| 28 | # previous run of the test suite by calling the script clean_tsuite.pl |
| 29 | # (this includes calls with the number of processors set to 0) ! |
| 30 | # |
| 31 | # The script uses "gmake" (GNU make) to run the test cases. In case |
| 32 | # that doesn't exist, you can try replacing the two calls below with |
| 33 | # "make". If the version is not too old, that should work as well |
| 34 | # provided it supports the -j parameter for parallel execution. |
| 35 | # |
| 36 | # Peter van Hoof |
| 37 | |
| 38 | if( -d "../../source/$ARGV[0]" ) { |
| 39 | $exe = "../../source/$ARGV[0]/cloudy.exe"; |
| 40 | } |
| 41 | else { |
| 42 | $exe = "$ARGV[0]"; |
| 43 | } |
| 44 | |
| 45 | if( "$ARGV[1]" eq "" ) { |
| 46 | # the following should work under Windows. |
| 47 | $nproc = $ENV{'NUMBER_OF_PROCESSORS'}; |
| 48 | if( $nproc eq "" ) |
| 49 | { |
| 50 | # this branch is for non-Windows |
| 51 | if( -r "/proc/cpuinfo" ) |
| 52 | { |
| 53 | # this branch is for Linux |
| 54 | $nproc = 0; |
| 55 | open( foo, "</proc/cpuinfo" ); |
| 56 | while( <foo> ) |
| 57 | { |
| 58 | if( /^processor/ ) |
| 59 | { |
| 60 | ++$nproc; |
| 61 | } |
| 62 | } |
| 63 | close( foo ); |
| 64 | } |
| 65 | else |
| 66 | { |
| 67 | # we don't know how to determine the number of CPUs |
| 68 | $nproc = 1; |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | else { |
| 73 | $nproc = $ARGV[1]; |
| 74 | } |
| 75 | |
| 76 | # clean up first |
| 77 | if( -e "./clean_tsuite.pl" ) { |
| 78 | system "./clean_tsuite.pl"; |
| 79 | } |
| 80 | else { |
| 81 | die "./clean_tsuite.pl not found!"; |
| 82 | } |
| 83 | |
| 84 | $all = "all: "; |
| 85 | $rules = ""; |
| 86 | $i = 0; |
| 87 | |
| 88 | # this funny sequence is to assure that the heavy jobs are upfront... |
| 89 | while( defined( $input = glob("h*.in [A-Za-gi-z]*.in") ) ) { |
| 90 | $i++; |
| 91 | $output = $input; |
| 92 | $output2 = $input; |
| 93 | $output =~ s/\.in/.out/gi; |
| 94 | $output2 =~ s/\.in/.err/gi; |
| 95 | $all = "$all$output "; |
| 96 | if( $i%4 == 0 ) { |
| 97 | $all = "$all\\\n\t"; |
| 98 | } |
| 99 | $rules = "$rules$output: $input\n"; |
| 100 | $rules = "$rules\t$exe < $input > $output 2> $output2\n" |
| 101 | } |
| 102 | open( foo, ">Makefile" ); |
| 103 | print foo $all; |
| 104 | print foo "\n"; |
| 105 | print foo $rules; |
| 106 | close foo; |
| 107 | |
| 108 | # if number of processors is 0 only create Makefile and exit |
| 109 | if( $nproc > 0 ) { |
| 110 | print "\nNow I will run the test suite using $nproc processors\n\n"; |
| 111 | |
| 112 | # this does the heavy lifting... |
| 113 | # try make instead if gmake doesn't exist on your system |
| 114 | system "gmake -i -j $nproc"; |
| 115 | |
| 116 | # this was produced by the optimizers and is not really part of the test suite |
| 117 | # its presence will fool the checkall.pl script.... |
| 118 | unlink "optimal.in"; |
| 119 | |
| 120 | if( $nproc > 1 ) { |
| 121 | # just in case func_trans_read was run before func_trans_punch was complete |
| 122 | unlink "func_trans_read.out"; |
| 123 | # try make instead if gmake doesn't exist on your system |
| 124 | system "gmake -i -j $nproc"; |
| 125 | } |
| 126 | |
| 127 | # now do the checking |
| 128 | system "./checkall.pl"; |
| 129 | } |
Note: See TracBrowser
for help on using the browser.
