source: misc/tools/acceptance_tests/test_latency_bandwidth.py @ 7276

Last change on this file since 7276 was 7276, checked in by ole, 14 years ago

Merged numpy branch back into the trunk.

In ~/sandpit/anuga/anuga_core/source
svn merge -r 6246:HEAD ../../branches/numpy .

In ~/sandpit/anuga/anuga_validation
svn merge -r 6417:HEAD ../branches/numpy_anuga_validation .

In ~/sandpit/anuga/misc
svn merge -r 6809:HEAD ../branches/numpy_misc .

For all merges, I used numpy version where conflicts existed

The suites test_all.py (in source/anuga) and validate_all.py passed using Python2.5 with numpy on my Ubuntu Linux box.

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#!/bin/env python
2
3'''Testlet to run the LatencyBandwidth test.'''
4
5import os
6import time
7import test_utils as util
8
9Processor_Numbers = [2, 4, 8, 16]
10
11name = 'Running latency/bandwidth test'
12
13def test(logfile):
14    result = True
15
16    (cluster, domain) = util.get_hostname()
17
18    # get python to run
19    python_env_var = os.getenv('PYTHON')
20
21    # compile C code
22    obj_file = 'ctiming_%s' % cluster
23    cmd = ('mpicc ctiming.c -lm -o %s' % obj_file)
24    util.log_print_nl(logfile, 'Compiling ctiming.c:')
25    util.log_print_nl(logfile,cmd)
26    (_, fd) = os.popen4(cmd)
27    output = fd.read()
28    status = fd.close()
29    if status:
30        util.log_print_nl(logfile, 'ERRORS COMPILING')
31        util.log_print(logfile, output)
32        return False
33
34    util.log_print_nl(logfile)
35
36    # run the tests
37    results = []
38    machines_file = os.path.join('~', '.machines_%s' % cluster)
39    for num_procs in Processor_Numbers:
40        cmd = ('mpirun -nolocal -np %2d -hostfile %s %s'
41               % (num_procs, machines_file, obj_file))
42        util.log_print(logfile, cmd + ' ...')
43        (_, fd) = os.popen4(cmd)
44        output = fd.readlines()
45        status = fd.close()
46        if status:
47            util.log_print_nl(logfile, 'ERRORS')
48            util.log_print(logfile, '\n'.join(output))
49            return False
50
51        estimated_bandwidth = None
52        estimated_latency = None
53        for line in output:
54            if line.startswith('Estimated bandwith'):
55                (_, estimated_bandwidth) = line.split(': ', 1)
56                estimated_bandwidth = estimated_bandwidth.strip()
57                (estimated_bandwidth, _) = estimated_bandwidth.split(' ', 1)
58            if line.startswith('Estimated latency'):
59                (_, estimated_latency) = line.split(': ', 1)
60                estimated_latency = estimated_latency.strip()
61                (estimated_latency, _) = estimated_latency.split(' ', 1)
62
63        if estimated_bandwidth is None or estimated_latency is None:
64            util.log_print_nl(logfile, 'ERRORS')
65            util.log_print(logfile, '\n'.join(output))
66            return False
67           
68        results.append((num_procs, float(estimated_bandwidth), int(estimated_latency)))
69        util.log_print_nl(logfile, 'done')
70
71    # interpret the results
72    util.log_print(logfile, '\nResults of latency/bandwidth test on %s\n' % cluster)
73    util.log_print(logfile, '%s\t%s\t%s\n' % ('#procs', 'b/width', 'latency'))
74   
75    for (num_processors, estimated_bandwidth, estimated_latency) in results:
76        util.log_print(logfile, '%d\t%.1f\t%d\n'
77                       % (num_processors, estimated_bandwidth, estimated_latency))
78
79    os.remove(obj_file)
80
81    return result
82
83
84if __name__ == '__main__':
85    import sys
86
87    logfile = 'test.log'
88    if len(sys.argv) > 1:
89        logfile = sys.argv[1]
90
91    try:
92        os.remove(logfile)
93    except:
94        pass
95
96    if not test(logfile):
97        sys.exit(10)
98
99    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.