summaryrefslogtreecommitdiffstats
path: root/unit_trace/stdout_printer.py
blob: 2e4c783470a6ead82b91ff61bf943bd1507e7af8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
###############################################################################
# Description
###############################################################################

# Prints records to standard out

###############################################################################
# Public functions
###############################################################################

def stdout_printer(stream,csize):
    for record in stream:
        if record.record_type == "event":
            _print_event(csize,record)
        elif record.record_type == "error" and record.type_name == 'Task_inversion_start':
            _print_inversion_start(csize,record,"Task_")
        elif record.record_type == "error" and record.type_name == 'Task_inversion_end':
            _print_inversion_end(csize,record,"Task_")
        elif record.record_type == "error" and record.type_name == 'Tasklet_inversion_start':
        	_print_inversion_start(csize,record,"Tasklet_")
        elif record.record_type == "error" and record.type_name == 'Tasklet_inversion_end':
        	_print_inversion_end(csize,record,"Tasklet_")
        elif record.record_type == "error" and record.type_name == 'Work_Item_inversion_start':
        	_print_inversion_start(csize,record,"Work_Item_")
        elif record.record_type == "error" and record.type_name == 'Work_Item_inversion_end':
        	_print_inversion_end(csize,record,"Work_Item_")
        
        #elif record.record_type == "error" and record.type_name == 'Tasklet_simultaneous_start':
        #	_print_simultaneous_start(csize,record,"Tasklet_")
        #elif record.record_type == "error" and record.type_name == 'Tasklet_simultaneous_end':
        #	_print_simultaneous_end(csize,record,"Tasklet_")
        #elif record.record_type == "error" and record.type_name == 'Work_Item_simultaneous_start':
        #	_print_simultaneous_start(csize,record,"Work_Item_")
        #elif record.record_type == "error" and record.type_name == 'Work_Item_simultaneous_end':
        #	_print_simultaneous_end(csize,record,"Work_Item_")	
        	
        	
        else:
            continue
        print ""

###############################################################################
# Private functions
###############################################################################

def _print_event(csize,record):
    print "Event ID: %d" % (record.id)
    print "Job: %d.%d" % (record.pid,record.job)
    print "CPU(cluster): %d(%d)" %(record.cpu, int(record.cpu/csize))
    if record.type_name == "release":
        print "Deadline: %d" % (record.deadline)
    elif record.type_name == 'tasklet_begin' or record.type_name == 'work_begin':
        print "Handling Klit thrread: %d" % (record.exe_pid)
    print "Type: %s" % (record.type_name)
    print "Time: %d" % (record.when)

def _print_inversion_start(csize,record,pi_type):
    print "Type: %s" % (pi_type+"Inversion start")
    print "Inversion Record IDs: (%d, U)" % (record.id)
    print "Triggering Event IDs: (%d, U)" % (record.triggering_event_id)
    print "Time: %d" % (record.job.inversion_start)
    print "Job: %d.%d" % (record.job.pid,record.job.job)
    print "Deadline: %d" % (record.job.deadline)
    print "Cluster: %d" % (record.job.cluster)
    if pi_type == "Tasklet_" or pi_type == "Work_Item_":   	
        print "Handling Klit thread: %d" % (record.job.exe_pid)
    print "Off CPU: ",
    for job in record.off_cpu:
        if job.cluster==record.job.cluster :
            print str(job) + " ",
    print
    print "On CPU: ",
    for job in record.on_cpu:
        if job.cluster==record.job.cluster :	
            print str(job) + " ",
    print #newline

def _print_inversion_end(csize,record,pi_type):
    print "Type: %s" % (pi_type+"Inversion end")
    print "Inversion record IDs: (%d, %d)" % (record.inversion_start_id,
        record.id)
    print("Triggering Event IDs: (%d, %d)" %
        (record.inversion_start_triggering_event_id,
        record.triggering_event_id))
    print "Time: %d" % (record.job.inversion_end)
    # NOTE: Here, we assume nanoseconds as the time unit.
    # May have to be changed in the future.
    print "Duration: %f ms" % (
        float(record.job.inversion_end - record.job.inversion_start)/1000000)
    print "Job: %d.%d" % (record.job.pid,record.job.job)
    print "Deadline: %d" % (record.job.deadline)
    print "Cluster: %d" % (record.job.cluster)
    if pi_type == "Tasklet_" or pi_type == "Work_Item_":   	
        print "Handling Klit thread: %d" % (record.job.exe_pid)
    print "Off CPU: ",
    for job in record.off_cpu:
        if job.cluster==record.job.cluster :
            print str(job) + " ",
    print
    print "On CPU: ",
    for job in record.on_cpu:
        if job.cluster==record.job.cluster :	
            print str(job) + " ",
    print #newline
    	
#def _print_simultaneous_start(csize,record,irq_type):
#    print "Type: %s" % (irq_type+"Simultaneous start")
#    print "Inversion Record IDs: (%d, U)" % (record.id)
#    print "Triggering Event IDs: (%d, U)" % (record.triggering_event_id)
#    print "Time: %d" % (record.job.simultaneous_start)
#    print "Job: %d.%d" % (record.job.pid,record.job.job)
    

#def _print_simultaneous_end(csize,record,irq_type):
#    print "Type: %s" % (irq_type+"Simultaneous end")
#    print "Inversion record IDs: (%d, %d)" % (record.simultaneous_start_id,
#        record.id)
#    print("Triggering Event IDs: (%d, %d)" %
#        (record.simultaneous_start_triggering_event_id,
#        record.triggering_event_id))
#    print "Time: %d" % (record.job.simultaneous_end)
#    # NOTE: Here, we assume nanoseconds as the time unit.
#    # May have to be changed in the future.
#    print "Duration: %f ms" % (
#        float(record.job.simultaneous_end - record.job.simultaneous_start)/1000000)
#    print "Job: %d.%d" % (record.job.pid,record.job.job)