1 # Copyright 2021-2022. The MBI project. All rights reserved.
2 # This program is free software; you can redistribute it and/or modify it under the terms of the license (GNU GPL).
8 class Tool(AbstractTool):
10 return "SimGrid wrapper"
12 def build(self, rootdir, cached=True):
13 if cached and (os.path.exists(f"{rootdir}/builds/SimGrid/bin/smpicc") or os.path.exists('/usr/bin/simgrid-mc')):
16 here = os.getcwd() # Save where we were
18 # Get a GIT checkout. Either create it, or refresh it
19 if os.path.exists("tools/simgrid/.git"):
20 subprocess.run("cd tools/simgrid && git pull && cd ../..", shell=True, check=True)
22 subprocess.run("rm -rf tools/simgrid && git clone --depth=1 https://framagit.org/simgrid/simgrid.git tools/simgrid", shell=True, check=True)
24 # Build and install it
25 os.chdir("tools/simgrid")
26 subprocess.run(f"cmake -DCMAKE_INSTALL_PREFIX={rootdir}/builds/SimGrid -Denable_model-checking=ON .", shell=True, check=True)
27 subprocess.run("make -j$(nproc) install VERBOSE=1", shell=True, check=True)
29 # Back to our previous directory
33 def ensure_image(self):
34 AbstractTool.ensure_image(self, "-x simgrid")
36 def setup(self, rootdir):
37 os.environ['PATH'] = os.environ['PATH'] + ":" + rootdir + "/builds/SimGrid/bin"
38 os.environ['VERBOSE'] = '1'
40 def run(self, execcmd, filename, binary, id, timeout, batchinfo):
41 cachefile = f'{binary}_{id}'
43 if not os.path.exists("cluster.xml"):
44 with open('cluster.xml', 'w') as outfile:
45 outfile.write("<?xml version='1.0'?>\n")
46 outfile.write("<!DOCTYPE platform SYSTEM \"https://simgrid.org/simgrid.dtd\">\n")
47 outfile.write('<platform version="4.1">\n')
48 outfile.write(' <cluster id="acme" prefix="node-" radical="0-99" suffix="" speed="1Gf" bw="125MBps" lat="50us"/>\n')
49 outfile.write('</platform>\n')
51 execcmd = re.sub("mpirun", "smpirun -wrapper simgrid-mc -platform ./cluster.xml -analyze --cfg=smpi/finalization-barrier:on --cfg=smpi/list-leaks:10 --cfg=model-check/max-depth:10000", execcmd)
52 if re.search("Concurrency", binary): # DPOR reduction in simgrid cannot deal with RMA calls as they contain mutexes
53 execcmd = re.sub("smpirun", "smpirun --cfg=model-check/reduction:none", execcmd)
54 execcmd = re.sub('\${EXE}', binary, execcmd)
55 execcmd = re.sub('\$zero_buffer', "--cfg=smpi/buffering:zero", execcmd)
56 execcmd = re.sub('\$infty_buffer', "--cfg=smpi/buffering:infty", execcmd)
59 buildcmd=f"smpicc {filename} -trace-call-location -g -Wl,-znorelro -Wl,-znoseparate-code -o {binary}",
68 subprocess.run("find -type f -a -executable | xargs rm -f", shell=True, check=True) # Remove generated cruft (binary files)
69 subprocess.run("rm -f smpitmp-* core", shell=True, check=True)
71 def parse(self, cachefile):
72 if os.path.exists(f'{cachefile}.timeout') or os.path.exists(f'logs/simgrid/{cachefile}.timeout'):
74 if not (os.path.exists(f'{cachefile}.txt') or os.path.exists(f'logs/simgrid/{cachefile}.txt')):
77 with open(f'{cachefile}.txt' if os.path.exists(f'{cachefile}.txt') else f'logs/simgrid/{cachefile}.txt', 'r') as infile:
78 output = infile.read()
80 if re.search('Compilation of .*? raised an error \(retcode: ', output):
81 return 'UNIMPLEMENTED'
83 if re.search('MBI_MSG_RACE', output):
86 if re.search('MC is currently not supported here', output):
89 if re.search('DEADLOCK DETECTED', output):
91 if re.search('returned MPI_ERR', output):
93 if re.search('Not yet implemented', output):
94 return 'UNIMPLEMENTED'
95 if re.search('CRASH IN THE PROGRAM', output):
97 if re.search('Probable memory leaks in your code: SMPI detected', output):
99 if re.search('DFS exploration ended.', output):
102 print (f">>>>[ INCONCLUSIVE ]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ({cachefile})")
104 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")