-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrace_format.go
86 lines (72 loc) · 2.32 KB
/
trace_format.go
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
package main
import (
"strconv"
"strings"
)
type DimTraceEntry struct {
num_wkgrps_x uint64
num_wkgrps_y uint64
num_wkgrps_z uint64
wkgrp_size_x uint64
wkgrp_size_y uint64
wkgrp_size_z uint64
}
type ArithmeticTraceEntry struct {
pc uint64
instructions uint8
dependency_wait []uint64
}
type StoreTraceEntry struct {
bytes uint8
address uint64
trace_entry ArithmeticTraceEntry
}
type BarrierTraceEntry struct {
trace_entry ArithmeticTraceEntry
}
type LoadTraceEntry struct {
bytes uint8
address uint64
trace_entry ArithmeticTraceEntry
}
func NewDimTraceEntry(entry string) DimTraceEntry {
e := strings.Split(entry, " ")
jx, _ := strconv.ParseUint(e[1], 16, 64)
jy, _ := strconv.ParseUint(e[2], 16, 64)
jz, _ := strconv.ParseUint(e[3], 16, 64)
wx, _ := strconv.ParseUint(e[4], 16, 64)
wy, _ := strconv.ParseUint(e[5], 16, 64)
wz, _ := strconv.ParseUint(e[6], 16, 64)
return DimTraceEntry{jx, jy, jz, wx, wy, wz}
}
func NewLoadTraceEntry(e string) LoadTraceEntry{
entry := []rune(e)
bytes, _:= strconv.ParseUint(string(entry[2]), 16, 8)
address, _ := strconv.ParseUint(string(entry[4:16]), 16, 64)
trace_entry := NewArithmeticTraceEntry(entry[17:])
return LoadTraceEntry{uint8(bytes), address, trace_entry}
}
func NewStoreTraceEntry(e string) StoreTraceEntry {
entry := []rune(e)
bytes, _:= strconv.ParseUint(string(entry[2]), 16, 8)
address, _ := strconv.ParseUint(string(entry[4:16]), 16, 64)
trace_entry := NewArithmeticTraceEntry(entry[17:])
return StoreTraceEntry{uint8(bytes), address, trace_entry}
}
func NewBarrierTraceEntry(e string) BarrierTraceEntry{
entry := []rune(e)
trace_entry := NewArithmeticTraceEntry(entry[2:])
return BarrierTraceEntry{trace_entry}
}
func NewArithmeticTraceEntry(entry []rune) ArithmeticTraceEntry {
pc, _ := strconv.ParseUint(string(entry[:12]), 16, 64)
instructions, _ := strconv.ParseUint(string(entry[13]), 16, 8)
deps, _ := strconv.ParseUint(string(entry[15]), 16, 64)
dependency_wait := make([]uint64,deps)
if deps > 0 {
for i := uint64(0); i < deps; i++ {
dependency_wait[i], _ = strconv.ParseUint(string(entry[17+i*13:29+i*13]), 16, 64)
}
}
return ArithmeticTraceEntry{pc, uint8(instructions), dependency_wait}
}