Skip to content

Commit

Permalink
Bump QE/GROMACS version to match NGC containers
Browse files Browse the repository at this point in the history
  • Loading branch information
vitduck committed Jul 26, 2022
1 parent 91e9b68 commit 804a274
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 90 deletions.
27 changes: 16 additions & 11 deletions src/bmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Bmt:
format = '%(message)s')
#format = '[%(levelname)-5s] %(message)s')

def __init__(self, count=1, prefix='./', outdir=None):
def __init__(self, repeat=1, prefix='./', outdir=None):
self.name = ''

# parse $SLUM_NODELIST
Expand All @@ -42,7 +42,7 @@ def __init__(self, count=1, prefix='./', outdir=None):
self.device = {}

# number of repeted measurements
self.count = count
self.repeat = repeat

# Build directory setup
self.bin = []
Expand Down Expand Up @@ -111,17 +111,21 @@ def build(self):
syscmd(cmd)

def run(self, redirect=0):
logging.info(f'{"Output":7} : {os.path.join(self.outdir, self.output)}')

# redirect output to file
if redirect:
syscmd(self.runcmd(), self.output)
for i in range(1, self.repeat+1):
if self.repeat > 1:
self.output = re.sub('log(\.\d+)?', f'log.{i}', self.output)

logging.info(f'{"Output":7} : {os.path.join(self.outdir, self.output)}')

# redirect output to file
if redirect:
syscmd(self.runcmd(), self.output)
else:
syscmd(self.runcmd())

self.parse()
else:
syscmd(self.runcmd())

time.sleep(3)
time.sleep(5)

def runcmd(self):
pass
Expand Down Expand Up @@ -166,6 +170,7 @@ def summary(self):

def add_argument(self):
self.parser.add_argument('-v', '--version' , action='version', version='%(prog)s ' + self.version)
self.parser.add_argument('--repeat' , type=int, help='number of repeated measurements')

def getopt(self):
self.add_argument()
Expand All @@ -183,7 +188,7 @@ def __cell_format(self, cell):

average = mean(cell)

if self.count > 1:
if self.repeat > 1:
formatted = "\n".join(list(map("{:.2f}".format, cell)) + [f'-<{average:.2f}>-'])
else:
formatted = f'{cell[0]:.2f}'
Expand Down
21 changes: 13 additions & 8 deletions src/gromacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import argparse

from utils import syscmd
from bmt_mpi import BmtMpi

class Gromacs(BmtMpi):
Expand Down Expand Up @@ -97,24 +98,27 @@ def run(self):
f'g{self.mpi.gpu}-'
f'l{self.nstlist}.log' )

for i in range(1, self.count+1):
if self.count > 1:
for i in range(1, self.repeat+1):
if self.repeat > 1:
self.output = re.sub('log(\.\d+)?', f'log.{i}', self.output)

super().run(1)

logging.info(f'{"Output":7} : {os.path.join(self.outdir, self.output)}')

syscmd(self.runcmd())

self.parse()

os.rename('md.log', self.output)

# clean redundant files
if os.path.exists('ener.edr'):
os.remove('ener.edr')
# if os.path.exists('ener.edr'):
# os.remove('ener.edr')

def execmd(self):
# gromacs MPI crashes unless thread is explicitly set to 1
cmd = [
self.bin,
'mdrun',
'-noconfout',
f'-s {self.input}',
f'-nsteps {str(self.nsteps)}',
f'-resetstep {self.resetstep}',
Expand All @@ -125,7 +129,8 @@ def execmd(self):
f'-npme {self.npme}',
f'-ntomp {self.mpi.omp}',
f'-nstlist {self.nstlist}',
f'-pin {self.pin}' ]
f'-pin {self.pin}',
'-noconfout']

if self.tunepme == False:
cmd.append('-notunepme')
Expand Down
6 changes: 1 addition & 5 deletions src/hpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,7 @@ def run(self):

self.output = f'HPL-n{self.mpi.node}-t{self.mpi.task}-o{self.mpi.omp}-g{self.mpi.gpu}.out'

for i in range(1, self.count+1):
if self.count > 1:
self.output = re.sub('out(\.\d+)?', f'out.{i}', self.output)

super().run(1)
super().run(1)

def execmd(self):
cmd = [self.bin]
Expand Down
4 changes: 2 additions & 2 deletions src/ior.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def run(self):
f'p{self.mpi.task}-'
f't{self.transfer}-'
f'b{self.block}-'
f's{self.segment}.out' )
f's{self.segment}.log' )

super().run(1)
super().run(1)

self.clean()

Expand Down
44 changes: 20 additions & 24 deletions src/iozone.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import re
import os
import argparse
import logging

from glob import glob
from utils import sync
from utils import sync, syscmd
from bmt import Bmt

class Iozone(Bmt):
Expand All @@ -19,11 +20,11 @@ def __init__(self, size='64M', record='1M', node=0, thread=0, **kwargs):
self.size = size
self.record = record
self.node = node or len(self.nodelist)
self.thread = thread or os.environ['SLURM_NTASKS_PER_NODE']
self.thread = thread or int(os.environ['SLURM_NTASKS_PER_NODE'])

self.src = ['http://www.iozone.org/src/current/iozone3_491.tgz']

self.header = ['node', 'thread', 'size', 'record', 'write(MB/s)', 'read(MB/s)', 'r_write(OPS)', 'r_read(OPS)']
self.header = ['node', 'thread', 'size', 'record', 'write(MB/s)', 'read(MB/s)', 'random_write(OPS)', 'random_read(OPS)']

self.parser.description = 'IOZONE Benchmark'

Expand Down Expand Up @@ -56,34 +57,29 @@ def run(self):
read_output = f'iozone-i1-n{self.node}-t{self.thread}-s{self.size}-r{self.record}.out'
random_output = f'iozone-i2-n{self.node}-t{self.thread}-s{self.size}-r{self.record}.out'

for i in range(1, self.count+1):
if self.count > 1:
for i in range(1, self.repeat+1):
if self.repeat > 1:
write_output = re.sub('out(\.\d+)?', f'out.{i}', write_output)
read_output = re.sub('out(\.\d+)?', f'out.{i}', read_output)
random_output = re.sub('out(\.\d+)?', f'out.{i}', random_output)

# write
self.mode = 0
self.output = write_output
self.run_mode(0, write_output)
self.run_mode(1, read_output)
self.run_mode(2, random_output)

self.clean()

sync(self.nodelist)
super().run(1)

# read
self.mode = 1
self.output = read_output
def run_mode(self, mode, output):
self.mode = mode
self.output = output

sync(self.nodelist)
super().run(1)

# random read/write
self.mode = 2
self.output = random_output
sync(self.nodelist)

logging.info(f'{"Output":7} : {os.path.join(self.outdir, self.output)}')

sync(self.nodelist)
super().run(1)
syscmd(self.runcmd(), output)

self.clean()
self.parse()

def runcmd(self):
cmd = [
Expand All @@ -100,7 +96,7 @@ def runcmd(self):
cmd += [
f'-s {self.size}', # file size per threads
f'-r {self.record}', # record size
f'-t {str(self.thread*self.node)}', # total number of threads
f'-t {self.thread*self.node}', # total number of threads
f'-+m {self.hostfile}', # hostfile: <hostname> <outdir> <iozone bin>
'-c', # includes close in timing calculation
'-e', # incldues flush in timing calculation
Expand Down
2 changes: 1 addition & 1 deletion src/openmpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def mpirun(self):
cmd = [
'mpirun',
'--allow-run-as-root',
f'--np {self.node*self.task}',
f'--np {int(self.node)*int(self.task)}',
f'--hostfile {self.hostfile}' ]

# process binding
Expand Down
14 changes: 5 additions & 9 deletions src/qe.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, input='Ausurf_512.in', npool=1, ntg=1, ndiag=1, nimage=1, neb
self.nimage = nimage
self.neb = neb

self.src = ['https://gitlab.com/QEF/q-e/-/archive/qe-6.8/q-e-qe-6.8.tar.gz']
self.src = ['https://gitlab.com/QEF/q-e/-/archive/qe-7.0/q-e-qe-7.0.tar.gz']

self.header = ['input', 'node', 'task', 'omp', 'gpu', 'nimage', 'npool', 'ntg', 'ndiag', 'time(s)']

Expand All @@ -37,8 +37,8 @@ def build(self):
scalapack = 'intel'

self.buildcmd = [
[f'cd {self.builddir}', 'tar xf q-e-qe-6.8.tar.gz'],
[f'cd {self.builddir}/q-e-qe-6.8/',
[f'cd {self.builddir}', 'tar xf q-e-qe-7.0.tar.gz'],
[f'cd {self.builddir}/q-e-qe-7.0/',
[f'./configure ',
f'--prefix={os.path.abspath(self.prefix)}',
f'--with-scalapack={scalapack}',
Expand Down Expand Up @@ -73,16 +73,12 @@ def run(self):
f'ni{self.nimage}-'
f'nk{self.npool}-'
f'nt{self.ntg}-'
f'nd{self.ndiag}.out' )
f'nd{self.ndiag}.log' )

if self.mpi.gpu:
self.output = re.sub(r'(-o\d+)', rf'\1-g{self.mpi.gpu}', self.output, 1)

for i in range(1, self.count+1):
if self.count > 1:
self.output = re.sub('out(\.\d+)?', f'out.{i}', self.output)

super().run(1)
super().run(1)

def execmd(self):
cmd = [
Expand Down
26 changes: 14 additions & 12 deletions src/qe_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,29 @@ def build(self):
# determine cuda_cc and runtime
runtime, cuda_cc = device_query(self.builddir)

# make.inc patch
patch = 'perl -pi -e "s/(cusolver)/\$1,curand/" make.inc'

# __GPU_MPI
if self.cuda_aware:
patch += ';perl -pi -e "s/^(DFLAGS.*)/\$1 -D__GPU_MPI/" make.inc'


# system hangs: https://gitlab.com/QEF/q-e/-/issues/475
self.buildcmd = [
[f'cd {self.builddir}', 'tar xf q-e-qe-6.8.tar.gz'],
[f'cd {self.builddir}/q-e-qe-6.8/',
[f'cd {self.builddir}', 'tar xf q-e-qe-7.0.tar.gz'],
[f'cd {self.builddir}/q-e-qe-7.0/',
[f'./configure',
f'--prefix={os.path.abspath(self.prefix)}',
f'--with-cuda={os.environ["NVHPC_ROOT"]}/cuda',
f'--with-cuda-cc={cuda_cc}',
f'--with-cuda-runtime={runtime}',
'--with-scalapack=no'],
patch,
'--with-scalapack=no']] ]

# make.inc patch (Q.E 6.8)
# self.buildcmd[-1] += [ 'perl -pi -e "s/(cusolver)/\$1,curand/" make.inc' ]

# __GPU_MPI
if self.cuda_aware:
self.buildcmd[-1] += [ 'perl -pi -e "s/^(DFLAGS.*)/\$1 -D__GPU_MPI/" make.inc' ]

self.buildcmd[-1] += [
'make -j 16 pw',
'make -j 16 neb',
'make install' ]]
'make install' ]

super(Qe, self).build()

Expand Down
4 changes: 2 additions & 2 deletions src/stream_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def build(self):
def run(self):
os.chdir(self.outdir)

self.output = f'stream-cuda-{self.arch}.out'

self.output = f'stream-cuda-{self.arch}.log'
super().run(1)

def runcmd(self):
Expand Down
4 changes: 2 additions & 2 deletions src/stream_omp.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def run(self):
os.environ['OMP_PROC_BIND'] = self.affinity
os.environ['OMP_NUM_THREADS'] = str(self.omp)

self.output = f'stream-{self.affinity}-omp_{self.omp}.out'
self.output = f'stream-{self.affinity}-omp_{self.omp}.log'

super().run(1)
super().run(1)

def runcmd(self):
return [self.bin]
Expand Down
Loading

0 comments on commit 804a274

Please sign in to comment.