COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
test-mpi-scalability.py
Go to the documentation of this file.
1 #!python
2 # -*- coding: utf-8 -*-
3 
4 import matplotlib
5 matplotlib.use('AGG')
6 import sys
7 import subprocess
8 import numpy as np
9 import pylab
10 import os
11 
12 # process arguments
13 mpi_run = sys.argv[1]
14 test_command = sys.argv[2]
15 max_nb_procs = int(sys.argv[3])
16 
17 # build a list of the number of processes to use
18 nb_procs_lst = [1]
19 while 2*nb_procs_lst[-1] <= max_nb_procs:
20  nb_procs_lst.append(2*nb_procs_lst[-1])
21 
22 search_str = 'time" type="numeric/double">'
23 
24 testmap = {}
25 
26 for nb_procs in nb_procs_lst:
27  cmd = [mpi_run]
28  cmd.append('-np')
29  cmd.append(str(nb_procs))
30  cmd.append(test_command)
31  for extra_arg in sys.argv[4:len(sys.argv)]:
32  cmd.append(extra_arg)
33 
34  print "running",
35  for arg in cmd:
36  print arg,
37  print '\n',
38 
39  p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
40 
41  if p.wait() != 0:
42  for line in p.stdout:
43  print line,
44  for line in p.stderr:
45  print line,
46  raise RuntimeError("Test exited with error")
47 
48  for line in p.stdout:
49  idx = line.find(search_str)
50  if idx > 0:
51  testname = line[0:idx].split('"')[-1].strip()
52  timing = float(line[idx+len(search_str):-1].split('<')[0])
53  if not testmap.has_key(testname):
54  testmap[testname] = []
55  testmap[testname].append(timing)
56 
57 nb_procs_arr = np.array(nb_procs_lst)
58 for testname in testmap:
59  timing_arr = np.array(testmap[testname])
60  pylab.plot(nb_procs_arr, timing_arr)
61  pylab.plot(nb_procs_arr, timing_arr, 'ko')
62 
63  pylab.xlabel('Number of processes')
64  pylab.ylabel('Time (s)')
65  pylab.title(testname)
66  pylab.grid(True)
67  pylab.axis([0, max_nb_procs+1, 0, max(timing_arr)*1.05])
68 
69  fig_filename = testname + '-timing.png'
70  pylab.savefig(fig_filename)
71  print '<DartMeasurementFile name="' + testname + ' scaling graph" type="image/png">' + os.path.join(os.path.dirname(test_command), fig_filename) + '</DartMeasurementFile>'
72  pylab.clf()
Real max(const Real a, const Real b)
Maximum between two scalars.
Definition: Terminals.hpp:228
Send comments to:
COOLFluiD Web Admin