19 cores=0, infrastructure=[], verbose=
False):
29 simDir = os.getcwd() +
"/" + simDir
33 if not os.path.exists(simDir):
35 print(
'Creating directory for simulation output: ' + simDir)
39 if not os.path.exists(smcTable):
40 raise RuntimeError(
'smcTable does not exist')
47 numCmd =
int(
ceil(numCmdTotal/cores))
48 cores =
int(
ceil(numCmdTotal/numCmd))
49 print(
"Number of commands %d, per script %d, number of scripts: %d" % (numCmdTotal, numCmd, cores))
51 onMercuryCloud =
False
53 print(
"Adjusting script for mercuryCloud")
54 buildDir = open(
'build').
read().
split()[0]
55 print(
"Copy files to cluster (rsync -avz %s $cloud:) and execute ./run.sh in the sim directory before continuing" % material)
56 elif infrastructure ==
"AWS":
57 print(
"Adjusting script for AWS")
60 print(
"Adjusting script for msm3")
61 buildDir = open(
'build').
read().
split()[0]
63 print(
"1) cd %r\n2) Adjust node numbers run.sh.\n3) Execute 'source ./run.sh'" % simDir)
68 open(simDir +
"/run.sh",
"w").
write(
"#!/bin/bash\nchmod +x *.sh\n")
69 for i
in range(cores):
71 open(simDir+
"/run.sh",
"a").
write(
"nohup ./"+
str(i)+
".sh &\n")
72 elif infrastructure ==
"AWS":
73 os.remove(simDir+
"/run.sh")
77 n = nodes[i%len(nodes)]
80 open(simDir +
"/run.sh",
"a").
write(
"sleep 3\n ssh %s \"cd \"`pwd`\"; nohup ./%d.sh > %s.out\"&\n" % (n,i,i))
89 params = file.readline()
92 for line
in file.readlines():
94 params = line.split()[2:]
96 params =
tuple(i
for i
in params)
98 paramString = paramStringTemplate % params
99 paramString +=
"-param _"+material+
"_"+
"_".join(params)
103 for executable
in exeNames:
104 if numCmdCounter == 0:
106 open(simDir +
str(coresCounter) +
".sh",
"w").
write(
"")
107 cmd =
'%s/%s %s\n' % (buildDir, executable, paramString)
109 open(simDir+
str(coresCounter)+
".sh",
"a").
write(
"#!/bin/sh\n" + cmd)
110 numCmdCounter = (numCmdCounter+1)%numCmd
114 for executable
in exeNames:
115 cmd =
'cd %s; %s/%s %s' % (simDir, buildDir, executable, paramString)
117 while len(freeCores) == 0:
118 print(
"No free cores, waiting for nodes to free up")
122 node = freeCores.pop()
123 outname = paramString.replace(
" ",
"")
124 sshcmd =
"sleep 1\n ssh %s \"%s\"" % (node, cmd +
' &> ' + executable +
'_' + outname +
'.out &')
126 subprocess.check_output(sshcmd, shell=
True)
128 for executable
in exeNames:
129 cmd =
'cd %s && %s/%s %s' % (simDir, buildDir, executable, paramString)
131 print(
"Running in serial: ./%s %s" % (executable, paramString))
132 subprocess.check_output(cmd, shell=
True)
133 if infrastructure ==
"AWS":
138 print(
"Runs finished.")
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 startAndWaitForSimulationsToFinish(simDir, samples)
Definition: simulateAWS.py:146