-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_conflicts.py
More file actions
42 lines (33 loc) · 962 Bytes
/
read_conflicts.py
File metadata and controls
42 lines (33 loc) · 962 Bytes
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
#!/usr/bin/env python
# encoding: utf-8
from gen_nodes import Call
'''
Read confliciing pairs from a file
Each line of the file should have the following format:
rank1-seqId1, rank2-seqId2
Return nodes of conflicting accesses
'''
def read_conflicting_accesses(path, total_ranks):
conflicts = []
pairs = []
for rank in range(total_ranks):
conflicts.append([])
f = open(path, "r")
lines = f.readlines()
f.close()
for line in lines:
pair = line.replace(" ", "").split(",")
tmp = pair[0].split("-")
func = tmp[0]
rank = int(tmp[1])
seq_id = int(tmp[2])
c1 = Call(rank, seq_id, func);
tmp = pair[1].split("-")
func = tmp[0]
rank = int(tmp[1])
seq_id = int(tmp[2])
c2 = Call(rank, seq_id, func);
conflicts[c1.rank].append(c1)
conflicts[c2.rank].append(c2)
pairs.append([c1, c2])
return conflicts, pairs