summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMac Mollison <mollison@cs.unc.edu>2010-02-11 20:21:14 -0500
committerMac Mollison <mollison@cs.unc.edu>2010-02-11 20:21:14 -0500
commitc8eacbf0dce8e2cc1acf6bfb0232302bba592e34 (patch)
treed78308bcc094481a1393dd824c9eb9bdf4e47387
parenta92bbe8cf94f28b250cf023b3e4cfea148738468 (diff)
Num. CPUs produced by trace_reader, not hardcoded
-rw-r--r--gedf_test.py13
-rw-r--r--sanitizer.py5
-rw-r--r--trace_reader.py8
3 files changed, 20 insertions, 6 deletions
diff --git a/gedf_test.py b/gedf_test.py
index 58b88cd..5a3c0c4 100644
--- a/gedf_test.py
+++ b/gedf_test.py
@@ -4,10 +4,6 @@
4 4
5# G-EDF Test 5# G-EDF Test
6 6
7# TODO:
8# - Currently assumes 4 CPUs
9
10
11############################################################################### 7###############################################################################
12# Imports 8# Imports
13############################################################################### 9###############################################################################
@@ -22,21 +18,26 @@ import copy
22def gedf_test(stream): 18def gedf_test(stream):
23 19
24 # Two lists to model the system: tasks occupying a CPU and tasks eligible 20 # Two lists to model the system: tasks occupying a CPU and tasks eligible
25 # to do so. 21 # to do so. Also, m = the number of CPUs.
26 eligible = [] 22 eligible = []
27 on_cpu = [] 23 on_cpu = []
24 m = None
28 25
29 # Time of the last record we saw. Only run the G-EDF test when the time 26 # Time of the last record we saw. Only run the G-EDF test when the time
30 # is updated. 27 # is updated.
31 last_time = None 28 last_time = None
32 29
33 for record in stream: 30 for record in stream:
31 if record.record_type != "event":
32 if record.record_type == "meta" and record.type_name == "num_cpus":
33 m = record.num_cpus
34 continue
34 35
35 # Check for inversion starts and ends and yield them. 36 # Check for inversion starts and ends and yield them.
36 # Only to the check when time has moved forward. 37 # Only to the check when time has moved forward.
37 # (It is common to have records with simultaneous timestamps.) 38 # (It is common to have records with simultaneous timestamps.)
38 if last_time is not None and last_time != record.when: 39 if last_time is not None and last_time != record.when:
39 errors = _gedf_check(eligible,on_cpu,record.when,4) 40 errors = _gedf_check(eligible,on_cpu,record.when,m)
40 for error in errors: 41 for error in errors:
41 yield error 42 yield error
42 43
diff --git a/sanitizer.py b/sanitizer.py
index c9f79bf..79315cc 100644
--- a/sanitizer.py
+++ b/sanitizer.py
@@ -16,6 +16,11 @@ def sanitizer(stream):
16 16
17 for record in stream: 17 for record in stream:
18 18
19 # Ignore records which are not events (e.g. the num_cpus record)
20 if record.record_type != 'event':
21 yield record
22 continue
23
19 # All records with job < 2 are garbage 24 # All records with job < 2 are garbage
20 if record.job < 2: 25 if record.job < 2:
21 continue 26 continue
diff --git a/trace_reader.py b/trace_reader.py
index 31f1812..2e5f65d 100644
--- a/trace_reader.py
+++ b/trace_reader.py
@@ -35,6 +35,14 @@ import struct
35# Generator function returning an iterable over records in a trace file. 35# Generator function returning an iterable over records in a trace file.
36def trace_reader(files): 36def trace_reader(files):
37 37
38 # Yield a record indicating the number of CPUs, used by the G-EDF test
39 class Obj: pass
40 record = Obj()
41 record.record_type = "meta"
42 record.type_name = "num_cpus"
43 record.num_cpus = len(files)
44 yield record
45
38 # Create iterators for each file and a buffer to store records in 46 # Create iterators for each file and a buffer to store records in
39 file_iters = [] # file iterators 47 file_iters = [] # file iterators
40 file_iter_buff = [] # file iterator buffers 48 file_iter_buff = [] # file iterator buffers