Module: CodeRunner::Moab
Class Method Summary collapse
Instance Method Summary collapse
- #batch_script ⇒ Object
- #batch_script_file ⇒ Object
- #cancel_job ⇒ Object
- #error_file ⇒ Object
- #execute ⇒ Object
- #get_run_status(job_no, current_status) ⇒ Object
- #max_ppn ⇒ Object
- #mpi_prog ⇒ Object
- #nprocstot ⇒ Object
- #output_file ⇒ Object
- #queue_status ⇒ Object
- #run_command ⇒ Object
Class Method Details
.configure_environment ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/coderunner/system_modules/moab.rb', line 4 def self.configure_environment eputs "Configuring Hector" conf = <<EOF eval `modulecmd bash swap PrgEnv-pgi PrgEnv-gnu` eval `modulecmd bash load fftw/3.2.2` export XTPE_LINK_TYPE=dynamic export LD_LIBRARY_PATH=/opt/xt-libsci/10.4.1/gnu/lib/44:$LD_LIBRARY_PATH EOF Kernel.change_environment_with_shell_script(conf) end |
Instance Method Details
#batch_script ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/coderunner/system_modules/moab.rb', line 67 def batch_script nodes, ppn = @nprocs.split(/x/) (eputs "Warning: number of nodes is not recommended (8, 16, 32, 64, 128, 256, 512, 1024, 2048 or 4096 recommended)"; sleep 0.2) unless [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096].include? nodes.to_i (eputs "Warning: number of wall mins is not recommended (20, 60, 180, 360, 720 recomended)"; sleep 0.2) unless [20, 60, 180, 360, 720].include? @wall_mins.to_i eputs "Warning: Underuse of nodes (#{ppn} cores per node instead of #{max_ppn})" if ppn.to_i < max_ppn raise "Error: cores per node cannot excede #{max_ppn}" if ppn.to_i > max_ppn # raise "Error: project (i.e. budget) not specified" unless @project ppn ||= max_ppn if @wall_mins ep @wall_mins hours = (@wall_mins / 60).floor mins = @wall_mins.to_i % 60 secs = ((@wall_mins - @wall_mins.to_i) * 60).to_i end eputs "Allotted wall time is " + sprintf("%02d:%02d:%02d", hours, mins, secs) nprocstot = nodes.to_i * ppn.to_i <<EOF #!/bin/bash --login #PBS -N #{executable_name}.#{job_identifier} #PBS -l mppwidth=#{nprocstot} #PBS -l mppnppn=#{ppn} #{@wall_mins ? "#PBS -l walltime=#{sprintf("%02d:%02d:%02d", hours, mins, secs)}" : ""} #{@project ? "#PBS -A #@project" : ""} ### start of jobscript cd $PBS_O_WORKDIR echo "workdir: $PBS_O_WORKDIR" echo "Submitting #{nodes}x#{ppn} job on #{CodeRunner::SYS} for project #@project..." EOF end |
#batch_script_file ⇒ Object
59 60 61 |
# File 'lib/coderunner/system_modules/moab.rb', line 59 def batch_script_file "#{executable_name}_#{job_identifier}.sh" end |
#cancel_job ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/coderunner/system_modules/moab.rb', line 103 def cancel_job if ((prefix = ENV['CODE_RUNNER_LAUNCHER']).size > 0 rescue false) fname = ENV['HOME'] + "/.coderunner_to_launch_#{prefix}/#{$$}.stop" File.open(fname, 'w'){|file| file.puts "\n"} else `qdel #{@job_no}` end end |
#error_file ⇒ Object
112 113 114 |
# File 'lib/coderunner/system_modules/moab.rb', line 112 def error_file return "#{executable_name}.#{job_identifier}.e#@job_no" end |
#execute ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/coderunner/system_modules/moab.rb', line 44 def execute if ((prefix = ENV['CODE_RUNNER_LAUNCHER']).size > 0 rescue false) launch_id = "#{Time.now.to_i}#{$$}" fname = ENV['HOME'] + "/.coderunner_to_launch_#{prefix}/#{launch_id}" File.open(fname + '.start', 'w'){|file| file.puts "cd #{Dir.pwd};#{run_command}"} sleep 1 until FileTest.exist? fname + '.pid' pid = File.read(fname + '.pid').to_i FileUtils.rm fname + '.pid' return pid else File.open(batch_script_file, 'w'){|file| file.puts batch_script + run_command + "\n"} pid = %x[qsub #{batch_script_file}].to_i end end |
#get_run_status(job_no, current_status) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/coderunner/system_modules/moab.rb', line 120 def get_run_status(job_no, current_status) if ((prefix = ENV['CODE_RUNNER_LAUNCHER']).size > 0 rescue false) return :Unknown end line = current_status.split(/\n/).grep(Regexp.new(job_no.to_s))[0] unless line return :Unknown else if line =~ /\sQ\s/ return :Queueing elsif line =~ /\sR\s/ return :Running elsif line =~ /\sH\s/ return :Queueing elsif line =~ /\sC\s/ return :Unknown else ep 'line', line raise 'Could not get run status' end end end |
#max_ppn ⇒ Object
63 64 65 |
# File 'lib/coderunner/system_modules/moab.rb', line 63 def max_ppn raise "Please define max_ppn for your system" end |
#mpi_prog ⇒ Object
24 25 26 |
# File 'lib/coderunner/system_modules/moab.rb', line 24 def mpi_prog "aprun -n #{nprocstot} -N #{ppn}" end |
#nprocstot ⇒ Object
28 29 30 31 32 |
# File 'lib/coderunner/system_modules/moab.rb', line 28 def nprocstot nodes, ppn = @nprocs.split(/x/) nprocstot = nodes.to_i * ppn.to_i end |
#output_file ⇒ Object
116 117 118 |
# File 'lib/coderunner/system_modules/moab.rb', line 116 def output_file return "#{executable_name}.#{job_identifier}.o#@job_no" end |
#queue_status ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/coderunner/system_modules/moab.rb', line 15 def queue_status if ((prefix = ENV['CODE_RUNNER_LAUNCHER']).size > 0 rescue false) %x[cat #{ENV['HOME']}/.coderunner_to_launch_#{prefix}/queue_status.txt] + %x[cat #{ENV['HOME']}/.coderunner_to_launch_#{prefix}/queue_status2.txt] else %x[qstat -q consort | grep $USER] end end |
#run_command ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/coderunner/system_modules/moab.rb', line 33 def run_command # "qsub #{batch_script_file}" if (ENV['CODE_RUNNER_LAUNCHER'].size > 0 rescue false) return %[mpiexec -np #{@nprocs} #{executable_location}/#{executable_name} #{parameter_string} > #{output_file} 2> #{error_file}] else nodes, ppn = @nprocs.split(/x/) nprocstot = nodes.to_i * ppn.to_i "#{mpi_prog} #{executable_location}/#{executable_name} #{parameter_string}" end end |