Skip to content

Instantly share code, notes, and snippets.

@zakandrewking
Last active December 17, 2015 03:29
Show Gist options
  • Save zakandrewking/5544071 to your computer and use it in GitHub Desktop.
Save zakandrewking/5544071 to your computer and use it in GitHub Desktop.
calculate runtime for carver
# Never waste brainpower on selecting your queue again.
# Future unnecessary feature: weigh queue options based on current wait times.
import math, time
t = float( raw_input('Time per solution (hr) : '))
c = int( raw_input('Number of problems : '))
m = int( raw_input('Memory per core (GB) : '))
max_mem = 20
if m <= 4:
max_ppn = 3
elif m <= 5:
max_ppn = 4
elif m <= 6.826:
max_ppn = 3
elif m <= 10:
max_ppn = 2
elif m <= max_mem:
max_ppn = 1
else:
raise Exception('memory requirement must be less than %d Mb' % max_mem)
max_nodes = [64, 32, 16]
max_time = [24, 36, 48] # hours
walltime_sec = None
for m_n, m_t in zip(max_nodes, max_time):
total_time = t * c
max_cores = 512
desired_cores = min(max_cores, c)
nodes = min(m_n, math.ceil(desired_cores/max_ppn))
cores = nodes * max_ppn
desired_walltime = t * math.ceil(float(c) / float(cores)) # hr
if desired_walltime <= m_t:
walltime_sec = desired_walltime * 3600
break
if walltime_sec==None:
raise Exception('Cannot find matching solution')
hr = math.floor(walltime_sec / 3600)
min = math.floor((walltime_sec - hr*3600) / 60)
sec = math.ceil(walltime_sec - hr*3600 - min*60)
print '#PBS -l walltime=%02d:%02d:%02d' % (hr, min, sec)
print '#PBS -l nodes=%d:ppn=%d' % (nodes, max_ppn)
print '#PBS -l pvmem=%dGB' % m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment