Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
OPAL
runOPAL
Commits
5e9d9c78
Commit
5e9d9c78
authored
Apr 23, 2018
by
snuverink_j
Browse files
remove runoptpilot script: optimiser integrated in OPAL, fixes #4
parent
dc3c5e59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
153 deletions
+1
-153
runOPAL/runOPAL.py
runOPAL/runOPAL.py
+1
-13
runOPAL/runoptpilot.py
runOPAL/runoptpilot.py
+0
-140
No files found.
runOPAL/runOPAL.py
View file @
5e9d9c78
...
...
@@ -12,7 +12,6 @@ Script that launches OPAL simulations
import
sys
,
os
,
shutil
,
glob
import
subprocess
from
simulation
import
Simulation
from
runoptpilot
import
Runoptpilot
from
opaldict
import
OpalDict
def
getNearestRestartStep
(
restart_pos
,
fn
):
...
...
@@ -57,7 +56,6 @@ def printUsage():
print
(
"--test does everything but submitting the job"
)
print
(
"--keep if same simulation has been run before, keep old data and abort"
)
print
(
"--nobatch run opal locally not using the batch system and waits until the job is done"
)
print
(
"--optPilot run optPilot (at the moment with default MOGA settings on host merlinl01.psi.ch)"
)
print
(
"--info=<num> steers the std-output of OPAL. The range is 0 < num < 6 (default), from minimal to maximum output"
)
print
(
"--queue=<qname> defines in which queue the job goes. Overwrites QUEUE (deprecated SGE_QUEUE)"
)
print
(
"--hypert=<num> defines the number of Hyper-Threads used. Default 0"
)
...
...
@@ -102,7 +100,6 @@ def main(argv):
doTest
=
False
doKeep
=
False
doNobatch
=
False
doOptPilot
=
False
restart_step
=
-
99
restart_file
=
""
queue
=
""
...
...
@@ -126,8 +123,6 @@ def main(argv):
doKeep
=
True
elif
arg
.
startswith
(
"--nobatch"
):
doNobatch
=
True
elif
arg
.
startswith
(
"--optPilot"
):
doOptPilot
=
True
elif
arg
.
startswith
(
"--info"
):
info
=
arg
.
split
(
"="
)[
1
]
elif
arg
.
startswith
(
"--queue"
):
...
...
@@ -178,14 +173,7 @@ def main(argv):
opaldict
.
addUserValues
(
argv
)
opaldict
.
scale
()
if
doOptPilot
:
opt
=
Runoptpilot
(
opaldict
)
qid
=
opt
.
run
(
N
,
baseFileName
,
restart_step
,
inputfilePath
,
tmplFile
,
oinpFile
,
restart_file
,
doTest
,
doKeep
,
doNobatch
)
if
doNobatch
:
print
(
"... finished!
\n
"
)
else
:
print
(
"SGE-ID= {}
\n
"
.
format
(
qid
))
elif
not
opaldict
.
hasRanges
():
if
not
opaldict
.
hasRanges
():
sim
=
Simulation
(
opaldict
)
qid
=
sim
.
run
(
N
,
baseFileName
,
restart_step
,
inputfilePath
,
tmplFile
,
oinpFile
,
restart_file
,
doTest
,
doKeep
,
doNobatch
,
info
,
queue
,
hypert
,
quiet
)
if
doNobatch
:
...
...
runOPAL/runoptpilot.py
deleted
100644 → 0
View file @
dc3c5e59
"""
Runoptpilot class handles sge job related things
@author: Andreas Adelmann <andreas.adelmann@psi.ch>
@author: Yves Ineichen <yves.ineichen@psi.ch>
@version: 0.1
"""
import
sys
,
re
,
os
,
string
,
fileinput
,
shutil
,
glob
,
subprocess
#,commands
import
time
class
Runoptpilot
:
def
__init__
(
self
,
opaldict
):
self
.
opaldict
=
opaldict
self
.
dirname
=
""
def
isOldMpiVersion
(
self
):
mpistr
=
os
.
environ
.
get
(
'OPENMPI'
)
mpiver
=
mpistr
.
partition
(
"-"
)[
2
].
partition
(
'-'
)[
0
]
mpiv
=
mpiver
.
split
(
"."
)
if
mpiv
[
0
]
==
"1"
and
mpiv
[
1
]
>=
"4"
:
return
False
else
:
return
True
def
createDirectory
(
self
,
dirname
,
doKeep
):
# If there's already an file remove it...
if
os
.
path
.
isdir
(
self
.
dirname
):
if
doKeep
:
print
(
'KEEP existing directory '
,
self
.
dirname
)
return
False
else
:
print
(
'REMOVE existing directory '
,
self
.
dirname
)
shutil
.
rmtree
(
self
.
dirname
)
# create directory
os
.
mkdir
(
self
.
dirname
)
return
True
def
run
(
self
,
N
,
baseFileName
,
restart_step
,
inputfilePath
,
tmplFile
,
oinpFile
,
restart_file
,
doTest
,
doKeep
,
doNobatch
):
CORES
=
int
(
self
.
opaldict
[
'CORES'
])
if
CORES
==
0
:
CORES
=
1
#hostname = commands.getoutput("hostname")
p
=
subprocess
.
Popen
([
'hostname'
],
stdout
=
subprocess
.
PIPE
)
hostname
,
err
=
p
.
communicate
()
time
=
os
.
getenv
(
"SGE_TIME"
,
"s_rt=11:59:00,h_rt=12:00:00"
)
ram
=
os
.
getenv
(
"SGE_RAM"
,
"4"
)
optpilotexepath
=
os
.
getenv
(
"OPT_PILOT_EXE_PATH"
)
queue
=
os
.
getenv
(
"SGE_QUEUE"
,
"prime_bd.q"
)
resultDir
=
os
.
getenv
(
"RESULTDIR"
,
"results"
);
maxGenerations
=
os
.
getenv
(
"MAXGENERATIONS"
,
"100"
);
initialPopulation
=
os
.
getenv
(
"INITIALPOPULATION"
,
"62"
);
#independentGens = os.getenv("INDEPENDENTGENS", "62");
numCoworkers
=
os
.
getenv
(
"NUMCOWORKERS"
,
"1"
)
numMasters
=
os
.
getenv
(
"NUMMASTERS"
,
"1"
)
dumpDat
=
os
.
getenv
(
"DUMPDAT"
,
"1"
)
solSynch
=
os
.
getenv
(
"SOLSYNCH"
,
"1"
)
tmpDir
=
os
.
getenv
(
"SIMTMPDIR"
,
".tmp"
)
mutProb
=
os
.
getenv
(
"MUTATIONPROB"
,
"0.5"
)
if
(
hostname
.
startswith
(
"merlin"
)):
print
(
'Done with setup of the optPilot simulation and executing the job on '
+
str
(
CORES
)
+
' cores...
\n
'
)
self
.
WriteSGEOrteMerlin
(
optpilotexepath
,
baseFileName
,
CORES
,
time
,
ram
,
maxGenerations
,
initialPopulation
,
numCoworkers
,
numMasters
,
dumpDat
,
solSynch
,
resultDir
,
tmpDir
,
mutProb
)
if
not
doTest
:
qid
=
commands
.
getoutput
(
'qsub -V -q '
+
queue
+
' -pe openmpi '
+
str
(
CORES
)
+
' runopt.sge | awk
\'
{print $3}
\'
'
)
print
(
'Done with setup of the optPilot simulation and submitting the job to '
,
queue
,
'with '
,
CORES
,
'cores
\n
'
)
else
:
print
(
'Done with setup of the optPilot simulation but no batch sumbmission
\n
'
)
elif
not
doNobatch
:
print
(
"optPilot is running only on Merlin for now
\n
"
)
def
WriteSGEOrteMerlin
(
self
,
optpilotexepath
,
oinpFile
,
cores
,
time
,
ram
,
maxGenerations
,
initialPopulation
,
numCoworkers
,
numMasters
,
dumpDat
,
solSynch
,
resultDir
,
tmpDir
,
mutProb
):
title
=
oinpFile
.
partition
(
"."
)[
0
]
myfile
=
open
(
'runopt.sge'
,
'w'
)
s1
=
"#!/bin/bash
\n
"
s1
+=
"#$ -cwd
\n
"
s1
+=
"#$ -j y
\n
"
s1
+=
"#$ -N "
+
title
+
"
\n
"
s1
+=
"#$ -pe openmpi "
+
str
(
cores
)
+
"
\n
"
s1
+=
"#$ -q prime_bd.q
\n
"
s1
+=
"#$ -v LD_LIBRARY_PATH,OPT_PILOT_HOME,OPT_PILOT_DIR,OPT_PILOT_EXE_PATH,OPENMPI,OPENMPI_DIR
\n
"
s1
+=
"#$ -l "
+
time
+
",ram="
+
ram
+
"G
\n
"
s1
+=
"# Set the environment variables:
\n
"
s1
+=
"if [ -n
\"
$OPENMPI
\"
]; then
\n
"
s1
+=
" MPIEXEC=$OPENMPI/bin/mpiexec
\n
"
s1
+=
"elif [ -n
\"
$OPENMPI_DIR
\"
]; then
\n
"
s1
+=
" MPIEXEC=$OPENMPI_DIR/bin/mpiexec
\n
"
s1
+=
"fi
\n
"
s1
+=
"export OMP_NUM_THREADS=1
\n
"
s1
+=
"export OMPI_MCA_btl='self,sm,openib'
\n
"
s1
+=
"####################################################
\n
"
s1
+=
"# BEGIN DEBUG
\n
"
s1
+=
"# Print the SGE environment on master host:
\n
"
s1
+=
"####################################################
\n
"
s1
+=
"echo
\"
=== SGE job JOB_NAME=$JOB_NAME JOB_ID=$JOB_ID
\"
\n
"
s1
+=
"####################################################
\n
"
s1
+=
"echo DATE=`date`
\n
"
s1
+=
"echo HOSTNAME=`hostname`
\n
"
s1
+=
"echo PWD=`pwd`
\n
"
s1
+=
"echo NSLOTS=$NSLOTS
\n
"
s1
+=
"echo PE_HOSTFILE=$PE_HOSTFILE
\n
"
s1
+=
"cat $PE_HOSTFILE
\n
"
s1
+=
"# END DEBUG
\n
"
s1
+=
"####################################################
\n
"
s1
+=
"THEEXE="
+
optpilotexepath
+
"/pisa-opal.exe
\n
"
s1
+=
"####################################################
\n
"
s1
+=
"# START SIMULATION
\n
"
s1
+=
"#
\n
"
s1
+=
"rm -f *_results.dat *.0
\n
"
s1
+=
"rm -f *.trace
\n
"
s1
+=
"rm -rf "
+
tmpDir
+
"
\n
"
s1
+=
"#
\n
"
s1
+=
"export FIELDMAPS="
+
os
.
getenv
(
'FIELDMAPS'
)
+
"
\n
"
s1
+=
"export DISTRIBUTIONS="
+
os
.
getenv
(
'DISTRIBUTIONS'
)
+
"
\n
"
s1
+=
"export TEMPLATES="
+
os
.
getenv
(
'TEMPLATES'
)
+
"
\n
"
s1
+=
"export SIMTMPDIR=`pwd`/tmp
\n
"
s1
+=
"export FNBASE="
+
oinpFile
+
"
\n
"
s1
+=
"rm -rf $SIMTMPDIR && mkdir $SIMTMPDIR
\n
"
s1
+=
"#
\n
"
s1
+=
"export CMD=
\"
$THEEXE --inputfile=$TEMPLATES/"
+
oinpFile
+
".tmpl --outdir=$PWD/"
+
resultDir
+
" --outfile="
+
oinpFile
+
".dat"
s1
+=
" --maxGenerations="
+
maxGenerations
+
" --initialPopulation="
+
initialPopulation
+
" --sol-synch="
+
solSynch
+
" --num-coworkers="
+
numCoworkers
s1
+=
" --num-masters="
+
numMasters
+
" --dump-dat="
+
dumpDat
+
" --gene-mutation-probability="
+
mutProb
+
"
\"
\n
"
s1
+=
"MPICMD=
\"
$MPIEXEC --prefix $OPENMPI_DIR -x LD_LIBRARY_PATH -x OMP_NUM_THREADS -x OMPI_MCA_btl -np $NSLOTS -machinefile $TMPDIR/machines $CMD
\"
\n
"
s1
+=
"echo
\"
Command to run:
\"
\n
"
s1
+=
"echo $MPICMD
\n
"
s1
+=
"#
\n
"
s1
+=
"$MPICMD
\n
"
myfile
.
write
(
s1
)
myfile
.
close
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment