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).
9 class Tool(mbi.AbstractTool):
11 return "SimGrid wrapper"
13 def build(self, rootdir, cached=True):
14 if cached and (os.path.exists(f"{rootdir}/builds/SimGrid/bin/smpicc") or os.path.exists('/usr/bin/simgrid-mc')):
17 here = os.getcwd() # Save where we were
19 # Get a GIT checkout. Either create it, or refresh it
20 if os.path.exists("tools/simgrid/.git"):
21 subprocess.run("cd tools/simgrid && git pull && cd ../..", shell=True, check=True)
23 subprocess.run("rm -rf tools/simgrid && git clone --depth=1 https://framagit.org/simgrid/simgrid.git tools/simgrid", shell=True, check=True)
25 # Build and install it
26 os.chdir("tools/simgrid")
27 subprocess.run(f"cmake -DCMAKE_INSTALL_PREFIX={rootdir}/builds/SimGrid -Denable_model-checking=ON .", shell=True, check=True)
28 subprocess.run("make -j$(nproc) install VERBOSE=1", shell=True, check=True)
30 # Back to our previous directory
34 def ensure_image(self, params=None, dockerparams=None):
35 mbi.AbstractTool.ensure_image(self, "-x simgrid")
37 def setup(self, rootdir):
38 os.environ['PATH'] = os.environ['PATH'] + ":" + rootdir + "/builds/SimGrid/bin"
39 os.environ['VERBOSE'] = '1'
41 def run(self, execcmd, filename, binary, num_id, timeout, batchinfo):
42 cachefile = f'{binary}_{num_id}'
44 if not os.path.exists("cluster.xml"):
45 with open('cluster.xml', 'w') as outfile:
46 outfile.write("<?xml version='1.0'?>\n")
47 outfile.write("<!DOCTYPE platform SYSTEM \"https://simgrid.org/simgrid.dtd\">\n")
48 outfile.write('<platform version="4.1">\n')
49 outfile.write(' <cluster id="acme" prefix="node-" radical="0-99" suffix="" speed="1Gf" bw="125MBps" lat="50us"/>\n')
50 outfile.write('</platform>\n')
52 execcmd = execcmd.replace("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")
53 execcmd = execcmd.replace('${EXE}', binary)
54 execcmd = execcmd.replace('$zero_buffer', "--cfg=smpi/buffering:zero")
55 execcmd = execcmd.replace('$infty_buffer', "--cfg=smpi/buffering:infty")
58 buildcmd=f"smpicc {filename} -trace-call-location -g -Wl,-znorelro -Wl,-znoseparate-code -o {binary}",
67 subprocess.run("find -type f -a -executable -exec rm -f {} +", shell=True, check=True) # Remove generated cruft (binary files)
68 subprocess.run("rm -f smpitmp-* core", shell=True, check=True)
70 def parse(self, cachefile):
71 if os.path.exists(f'{cachefile}.timeout') or os.path.exists(f'logs/simgrid/{cachefile}.timeout'):
73 if not (os.path.exists(f'{cachefile}.txt') or os.path.exists(f'logs/simgrid/{cachefile}.txt')):
76 with open(f'{cachefile}.txt' if os.path.exists(f'{cachefile}.txt') else f'logs/simgrid/{cachefile}.txt', 'r') as infile:
77 output = infile.read()
79 if re.search(r'Compilation of .*? raised an error \(retcode: ', output):
80 return 'UNIMPLEMENTED'
82 if re.search('MBI_MSG_RACE', output):
85 if re.search('MC is currently not supported here', output):
88 if re.search('Collective communication mismatch', output):
89 return 'Collective mismatch'
91 if re.search('DEADLOCK DETECTED', output):
93 if re.search('returned MPI_ERR', output):
95 if re.search('Not yet implemented', output):
96 return 'UNIMPLEMENTED'
97 if re.search('CRASH IN THE PROGRAM', output):
99 if re.search('Probable memory leaks in your code: SMPI detected', output):
101 if re.search('DFS exploration ended.', output):
104 print(f">>>>[ INCONCLUSIVE ]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ({cachefile})")
106 print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")