Debian Codegraph @

hmmer/test-speed/speed-master.pl

raw
1 #! /usr/bin/perl
2
3 # The top level script that runs speed benchmarks
4 #
5 # Usage:
6 # ./speed-master.pl <top_builddir> <top_srcdir> <resultdir> <nproc> <nthread> <joblist> <querydb> <targetdb> <script>
7 #
8 # <top_builddir>: Top level directory for finding executables to be
9 # benchmarked. This is passed on to the <script>
10 # without modification; that script uses it to
11 # construct appropriate paths to executables.
12 #
13 # <top_srcdir>: Top level directory for finding scripts or data
14 # files. This too will simply be passed on to the
15 # <script> without modification.
16 #
17 # <resultdir>: A directory for holding all <nproc> temporary files
18 # created by the benchmark. This name should be short
19 # and unique; it will also be used to construct job
20 # names on the cluster, as <resultdir.$i>.
21 #
22 # <nproc>: how many processes to parallelize over in our cluster.
23 #
24 # <nthread>: how many threads to run in each timed process.
25 # This is passed on to the <script> verbatim.
26 #
27 # <joblist>: Name of a file containing a list of job names, one word per
28 # line. This filename will simply be passed on to the
29 # <script>, which then uses it to pull appropriate test
30 # queries out of <querydb>. Thus it will usually be a
31 # list of query names.
32 #
33 # <querydb>: File to fetch queries listed in <joblist> from.
34 # Passed to <script> without modification.
35 #
36 # <targetdb>: File to search and time the search.
37 # Passed to <script> without modification.
38 #
39 # <script>: This script is executed on each of <nproc>
40 # processes, on an appropriately constructed subset of the
41 # benchmark queries.
42 #
43 # The <script> must take the following arguments:
44 # <top_builddir> <top_srcdir> <resultdir> <tblfile> <nthread> <querydb> <targetdb> <outfile>
45 #
46 # Examples of HMMER3 benchmark:
47 # ./speed-master.pl ~/releases/hmmer-release/build-icc ~/releases/hmmer-release sA-new 100 1 speedA.list Pfam-A.hmm pfamseq-shuf ./x-hmmsearch
48 #
49
50 $top_builddir = shift;
51 $top_srcdir = shift;
52 $resultdir = shift;
53 $nproc = shift;
54 $nthread = shift;
55 $joblist = shift;
56 $querydb = shift;
57 $targetdb = shift;
58 $driver = shift;
59
60 # Make the result directory
61 if (-e $resultdir) { die("$resultdir exists");}
62 system("mkdir $resultdir");
63
64 # Suck in the job list
65 open(JOB_TBL, $joblist) || die;
66 $n = 0;
67 while (<JOB_TBL>) { ($jobline[$n++]) = $_; }
68 close JOB_TBL;
69
70 # Create <ncpu> subtables in memory (interleaved)
71 for ($i = 0; $i < $n; $i++)
72 {
73 $subtbl[$i % $nproc] .= $jobline[$i];
74 }
75
76 # Output the <nproc> subtables to the work directory, as tbl.$n
77 for ($i = 0; $i < $nproc; $i++)
78 {
79 open(SUBTBL, ">$resultdir/tbl.$i") || die ("Failed to create $resultdir/tbl.$i");
80 print SUBTBL $subtbl[$i];
81 close SUBTBL;
82 }
83
84 # Ask slurm for 4G RAM per thread.
85 $memrequest = 4000 * $nthread;
86
87 # Write a slurm array script
88 # I'd love to make these jobs exclusive, since we're speed benchmarking,
89 # but we only have 16 nodes (each with 36 cores).
90 #
91 open(SLURMSCRIPT, ">$resultdir.sh") || die("failed to create slurm script");
92 print SLURMSCRIPT <<EOF;
93 #! /bin/bash
94 #SBATCH -t 6-00:00
95 #SBATCH --mem $memrequest
96 #SBATCH -p eddy
97 #SBATCH -c $nthread
98 #SBATCH -N 1
99 #SBATCH -o $resultdir/tbl.%a.slurm
100 $driver $top_builddir $top_srcdir $resultdir $resultdir/tbl.\${SLURM_ARRAY_TASK_ID} $nthread $querydb $targetdb $resultdir/tbl.\${SLURM_ARRAY_TASK_ID}.out
101 EOF
102
103 # Submit the job array.
104 #
105 $maxidx = $nproc-1;
106 system("sbatch --array=0-$maxidx $resultdir.sh");
107