-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# coding: utf-8 | ||
|
||
import sys | ||
import numpy as np | ||
import os | ||
import time | ||
from datetime import datetime | ||
from pynq import Xlnk | ||
from pynq import Overlay | ||
|
||
# load our design overlay | ||
overlay = Overlay('mem_test.bit') | ||
print("mem_test.bit loaded") | ||
|
||
myIP = overlay.mem_test_0 | ||
|
||
print("myIP.mmio.base_addr = ", myIP.mmio.base_addr) | ||
print("myIP.mmio.length = ", myIP.mmio.length) | ||
print("myIP.mmio.virt_base = ", myIP.mmio.virt_base) | ||
print("myIP.mmio.virt_offset = ", myIP.mmio.virt_offset) | ||
|
||
xlnk = Xlnk() | ||
|
||
t1 = time.time() | ||
|
||
input_data = xlnk.cma_array(shape=(256*512,), dtype=np.int32) | ||
|
||
for i in range(256*512): | ||
input_data[i] = 1 | ||
|
||
myIP.write(0x18, input_data.physical_address) | ||
print("input_data.physical_address = ", input_data.physical_address) | ||
|
||
print("0x00 = ", myIP.read(0x00)) | ||
|
||
t2 = time.time() | ||
t = t2 - t1 | ||
print("Preparing input data time: ", str(t)) | ||
|
||
isready = 0; | ||
myIP.write(0x00, 1) | ||
|
||
while( isready != 6 ): | ||
print("0x00 = ", isready) | ||
isready = myIP.read(0x00) | ||
|
||
print("Last 0x00 = ", myIP.read(0x00)) | ||
|
||
t3 = time.time() | ||
t = t3 - t2 | ||
#tbatch = tbatch + t | ||
#print("Computation finished") | ||
print("PL Time: ", str(t)) | ||
|
||
print("Return value: ", myIP.read(0x10)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
neighbor_list = [] | ||
offset_list = [0] | ||
edge_list = [] | ||
|
||
graph_file = open("graph/test.tsv") | ||
lines = graph_file.readlines() | ||
|
||
degree_count = 0 | ||
prev_node = 0 | ||
|
||
for line in lines: | ||
node_a, node_b, _ = map(int, line.split()) | ||
if prev_node != node_b: | ||
offset_list.append(degree_count) | ||
|
||
prev_node = node_b | ||
if node_a < node_b: | ||
edge_list.extend([node_b, node_a]) | ||
else: | ||
neighbor_list.append(node_a) | ||
degree_count += 1 | ||
|
||
offset_list.append(degree_count) | ||
|
||
graph_file.close() | ||
|
||
print("neighbor_list size = ", len(neighbor_list)) | ||
print("offset_list size = ", len(offset_list)) | ||
print("edge_list size = ", len(edge_list)) | ||
|
||
f = open("test_parsed.tsv", "w") | ||
f.write("%d %d %d\n" % (len(neighbor_list), len(offset_list), len(edge_list))) | ||
f.write(" ".join(str(e) for e in neighbor_list) + "\n") | ||
f.write(" ".join(str(e) for e in offset_list) + "\n") | ||
f.write(" ".join(str(e) for e in edge_list) + "\n") | ||
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# coding: utf-8 | ||
|
||
import sys | ||
import numpy as np | ||
import os | ||
import time | ||
from datetime import datetime | ||
from pynq import Xlnk | ||
from pynq import Overlay | ||
|
||
# load our design overlay | ||
overlay = Overlay('intersect_hw.bit') | ||
print("intersect_hw.bit loaded") | ||
|
||
myIP = overlay.intersect_0 | ||
|
||
xlnk = Xlnk() | ||
|
||
t1 = time.time() | ||
|
||
input_a = xlnk.cma_array(shape=(4096,), dtype=np.int32) | ||
input_b = xlnk.cma_array(shape=(4096,), dtype=np.int32) | ||
|
||
for i in range(4096): | ||
input_a[i] = i | ||
input_b[i] = i + 1 | ||
|
||
myIP.write(0x18, input_a.physical_address) | ||
myIP.write(0x20, input_b.physical_address) | ||
|
||
myIP.write(0x28, 2) | ||
myIP.write(0x30, 2) | ||
|
||
|
||
t2 = time.time() | ||
t = t2 - t1 | ||
print("Preparing input data time: ", str(t)) | ||
|
||
isready = 0; | ||
myIP.write(0x00, 1) | ||
|
||
while( isready != 6 ): | ||
isready = myIP.read(0x00) | ||
|
||
t3 = time.time() | ||
t = t3 - t2 | ||
#tbatch = tbatch + t | ||
#print("Computation finished") | ||
print("PL Time: ", str(t)) | ||
|
||
print("Return value: ", myIP.read(0x10)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# coding: utf-8 | ||
|
||
import sys | ||
import numpy as np | ||
import os | ||
import time | ||
from datetime import datetime | ||
from pynq import Xlnk | ||
from pynq import Overlay | ||
|
||
# load our design overlay | ||
overlay = Overlay('triangle_counting.bit') | ||
print("triangle_counting.bit loaded") | ||
|
||
myIP = overlay.triangle_counting_0 | ||
|
||
t0 = time.time() | ||
|
||
neighbor_list = [] | ||
offset_list = [0] | ||
edge_list = [] | ||
|
||
graph_file = open("graph/soc-Epinions1_adj.tsv") | ||
# graph_file = open("graph/test.tsv") | ||
lines = graph_file.readlines() | ||
|
||
degree_count = 0 | ||
prev_node = 0 | ||
|
||
for line in lines: | ||
node_a, node_b, _ = map(int, line.split()) | ||
if prev_node != node_b: | ||
offset_list.append(degree_count) | ||
|
||
prev_node = node_b | ||
if node_a < node_b: | ||
edge_list.extend([node_b, node_a]) | ||
else: | ||
neighbor_list.append(node_a) | ||
degree_count += 1 | ||
|
||
offset_list.append(degree_count) | ||
|
||
print("neighbor_list size= ", len(neighbor_list)) | ||
print("offset_list size= ", len(offset_list)) | ||
print("edge_list size= ", len(edge_list)) | ||
|
||
t1 = time.time() | ||
|
||
print("Finished reading graph file. ") | ||
t = t1 - t0 | ||
print("Reading input file time: ", str(t)) | ||
|
||
xlnk = Xlnk() | ||
|
||
neighbor = xlnk.cma_array(shape=(len(neighbor_list),), dtype=np.int32) | ||
offset = xlnk.cma_array(shape=(len(offset_list),), dtype=np.int32) | ||
edge = xlnk.cma_array(shape=(len(edge_list),), dtype=np.int32) | ||
progress = xlnk.cma_array(shape=(5,), dtype=np.int32) | ||
|
||
neighbor[:] = neighbor_list | ||
offset[:] = offset_list | ||
edge[:] = edge_list | ||
|
||
# neighbor[:] = [2, 4, 5, 3, 4, 5, 4, 5, 5] | ||
# offset[:] = [0, 0, 3, 6, 8, 9, 9] | ||
# edge[:] = [5, 4, 5, 3, 5, 2, 5, 1, 4, 3, 4, 2, 4, 1, 3, 2, 2, 1] | ||
|
||
myIP.write(0x18, neighbor.physical_address) | ||
myIP.write(0x20, offset.physical_address) | ||
myIP.write(0x28, edge.physical_address) | ||
myIP.write(0x30, len(edge_list)) | ||
myIP.write(0x38, progress.physical_address) | ||
|
||
# for i in range(neighbor.size): | ||
# print("neighbor[%d] = %d" % (i, neighbor[i])) | ||
|
||
# for i in range(offset.size): | ||
# print("offset[%d] = %d" % (i, offset[i])) | ||
|
||
# for i in range(edge.size): | ||
# print("edge[%d] = %d" % (i, edge[i])) | ||
|
||
t2 = time.time() | ||
t = t2 - t1 | ||
print("Preparing input data time: ", str(t)) | ||
|
||
isready = 0; | ||
myIP.write(0x00, 1) | ||
|
||
while( isready != 6 ): | ||
# print(progress[0], progress[1], progress[2], progress[3], progress[4]) | ||
isready = myIP.read(0x00) | ||
|
||
t3 = time.time() | ||
t = t3 - t2 | ||
#tbatch = tbatch + t | ||
#print("Computation finished") | ||
print("PL Time: ", str(t)) | ||
|
||
print("Return value: ", myIP.read(0x10)) |