17 def runSimulations(smcTable, simDir, buildDir, paramStringTemplate, exeNames, material, onNode=False, nodes=[], cores=0, verbose=False):
19 print(
"Running make in the build directory %s" % buildDir)
21 output = subprocess.check_output(
'make -j 8 -C ' + buildDir, shell=
True)
24 raise RuntimeError(
'Calling make in the buildDirectory failed')
27 simDir = os.getcwd() +
"/" + simDir
31 if not os.path.exists(simDir):
33 print(
'Creating directory for simulation output: ' + simDir)
37 if not os.path.exists(smcTable):
38 raise RuntimeError(
'smcTable does not exist')
45 numCmd =
int(
ceil(numCmdTotal/cores))
46 cores =
int(
ceil(numCmdTotal/numCmd))
47 print(
"Number of commands %d, per script %d, number of scripts: %d" % (numCmdTotal, numCmd, cores))
49 onMercuryCloud =
False
51 print(
"Adjusting script for mercuryCloud")
52 buildDir = open(
'build').
read().
split()[0]
54 print(
"Copy files to cluster (rsync -avz %s $cloud:) and execute ./run.sh in the sim directory before continuing" % material)
56 print(
"Adjusting script for msm3")
57 buildDir = open(
'build').
read().
split()[0]
59 print(
"1) cd %r\n2) Adjust node numbers run.sh.\n3) Execute 'source ./run.sh'" % simDir)
64 open(simDir+
"/run.sh",
"w").
write(
"#!/bin/bash\nchmod +x *.sh\nmake -j 16 -C %s\n" % buildDir)
65 for i
in range(cores):
67 open(simDir+
"/run.sh",
"a").
write(
"nohup ./"+
str(i)+
".sh &\n")
69 n = nodes[i%len(nodes)]
72 open(simDir +
"/run.sh",
"a").
write(
"sleep 3\n ssh %s \"cd \"`pwd`\"; nohup ./%d.sh > %s.out\"&\n" % (n,i,i))
78 params = file.readline()
81 for line
in file.readlines():
83 params = line.split()[2:]
85 params =
tuple(i
for i
in params)
87 paramString = paramStringTemplate % params
88 paramString +=
"-param _"+material+
"_"+
"_".join(params)
92 for executable
in exeNames:
93 if numCmdCounter == 0:
95 open(simDir +
str(coresCounter) +
".sh",
"w").
write(
"")
96 cmd =
'%s/%s %s\n' % (buildDir, executable, paramString)
98 open(simDir+
str(coresCounter)+
".sh",
"a").
write(cmd)
99 numCmdCounter = (numCmdCounter+1)%numCmd
103 for executable
in exeNames:
104 cmd =
'cd %s; %s/%s %s' % (simDir, buildDir, executable, paramString)
106 while len(freeCores) == 0:
107 print(
"No free cores, waiting for nodes to free up")
111 node = freeCores.pop()
112 outname = paramString.replace(
" ",
"")
113 sshcmd =
"sleep 1\n ssh %s \"%s\"" % (node, cmd +
' &> ' + executable +
'_' + outname +
'.out &')
115 subprocess.check_output(sshcmd, shell=
True)
117 for executable
in exeNames:
118 cmd =
'cd %s && %s/%s %s' % (simDir, buildDir, executable, paramString)
120 print(
"Running in serial: ./%s %s" % (executable, paramString))
121 subprocess.check_output(cmd, shell=
True)
122 print(
"Runs started. Rerun this script for analysis.")
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::enable_if_t< PacketLoad, PacketType > read(const TensorMapper &tensorMapper, const StorageIndex &NCIndex, const StorageIndex &CIndex, const StorageIndex &ld)
read, a template function used for loading the data from global memory. This function is used to guar...
Definition: TensorContractionSycl.h:162
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 ceil(const bfloat16 &a)
Definition: BFloat16.h:644
str
Definition: compute_granudrum_aor.py:141
void split(const DoubleVector &in_vector, Vector< DoubleVector * > &out_vector_pt)
Definition: double_vector.cc:1413
def runSimulations(smcTable, simDir, buildDir, paramStringTemplate, exeNames, material, onNode=False, nodes=[], cores=0, verbose=False)
Definition: simulate.py:17