Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e08c7c9dd1b857b726c60eb9fae4602ee1a47a10
[simgrid.git] / teshsuite / smpi / MBI / simgrid.py
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).
3
4 import re
5 import os
6 from MBIutils import *
7
8 class Tool(AbstractTool):
9     def identify(self):
10         return "SimGrid wrapper"
11
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')):
14             return
15
16         here = os.getcwd() # Save where we were
17         os.chdir(rootdir)
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)
21         else:
22             subprocess.run("rm -rf tools/simgrid && git clone --depth=1 https://framagit.org/simgrid/simgrid.git tools/simgrid", shell=True, check=True)
23
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)
28
29         # Back to our previous directory
30         os.chdir(here)
31
32
33     def ensure_image(self):
34         AbstractTool.ensure_image(self, "-x simgrid")
35
36     def setup(self, rootdir):
37         os.environ['PATH'] = os.environ['PATH'] + ":" + rootdir + "/builds/SimGrid/bin"
38         os.environ['VERBOSE'] = '1'
39
40     def run(self, execcmd, filename, binary, id, timeout, batchinfo):
41         cachefile = f'{binary}_{id}'
42
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')
50
51         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 --cfg=smpi/pedantic:true")
52         if re.search("Concurrency", binary):  # DPOR reduction in simgrid cannot deal with RMA calls as they contain mutexes
53             execcmd = execcmd.replace("smpirun", "smpirun --cfg=model-check/reduction:none")
54         execcmd = execcmd.replace('${EXE}', binary)
55         execcmd = execcmd.replace('$zero_buffer', "--cfg=smpi/buffering:zero")
56         execcmd = execcmd.replace('$infty_buffer', "--cfg=smpi/buffering:infty")
57
58         run_cmd(
59             buildcmd=f"smpicc {filename} -trace-call-location -g -Wl,-znorelro -Wl,-znoseparate-code -o {binary}",
60             execcmd=execcmd,
61             cachefile=cachefile,
62             filename=filename,
63             binary=binary,
64             timeout=timeout,
65             batchinfo=batchinfo)
66
67     def teardown(self): 
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) 
70
71     def parse(self, cachefile):
72         if os.path.exists(f'{cachefile}.timeout') or os.path.exists(f'logs/simgrid/{cachefile}.timeout'):
73             return 'timeout'
74         if not (os.path.exists(f'{cachefile}.txt') or os.path.exists(f'logs/simgrid/{cachefile}.txt')):
75             return 'failure'
76
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()
79
80         if re.search('Compilation of .*? raised an error \(retcode: ', output):
81             return 'UNIMPLEMENTED'
82
83         if re.search('MBI_MSG_RACE', output):
84             return 'MBI_MSG_RACE'
85
86         if re.search('MC is currently not supported here', output):
87             return 'failure'
88
89         if re.search('DEADLOCK DETECTED', output):
90             return 'deadlock'
91         if re.search('returned MPI_ERR', output):
92             return 'mpierr'
93         if re.search('Not yet implemented', output):
94             return 'UNIMPLEMENTED'
95         if re.search('CRASH IN THE PROGRAM', output):
96             return 'failure'
97         if re.search('Probable memory leaks in your code: SMPI detected', output):
98             return 'resleak'
99         if re.search('DFS exploration ended.', output):
100             return 'OK'
101
102         print (f">>>>[ INCONCLUSIVE ]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ({cachefile})")
103         print(output)
104         print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
105         return 'other'