Skip to content

Commit 6a71717

Browse files
Rajat SarkariGitHub Enterprise
authored andcommitted
Chain example updated to show speedup
2 parents dfc93f3 + 1746e56 commit 6a71717

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

cpp_kernels/kernel_chain/details.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,20 @@ and simple kernel.
2626
2727
#pragma HLS INTERFACE s_axilite port = return bundle = control
2828
#pragma HLS INTERFACE ap_ctrl_chain port = return bundle = control
29+
30+
Following is the real log reported while running the design on U200
31+
platform with 10 iterations:
32+
33+
::
34+
35+
--------------------------------------------------
36+
Performance Summary
37+
--------------------------------------------------
38+
-------------------------+-------------------------
39+
Kernel(10 iterations) | Wall-Clock Time (s)
40+
-------------------------+-------------------------
41+
krnl_chain_mmult | 0.00305935
42+
krnl_simple_mmult | 0.00534336
43+
-------------------------+-------------------------
44+
Speedup: | 1.74657
45+
-------------------------+-------------------------

cpp_kernels/kernel_chain/src/host.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <array>
1919
#include <iostream>
2020

21-
#define MAT_DIM 8
21+
#define MAT_DIM 32
2222
#define MAT_SIZE MAT_DIM* MAT_DIM
2323
#define NUM_TIMES 10
2424
////////////////////UTILITY FUNCTION///////////////

cpp_kernels/kernel_chain/src/krnl_chain_mmult.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ void krnl_chain_mmult(int* a, int* b, int* c, int* d, int* output, int dim) {
4545
int tmp = dim;
4646
strm_ctrl_trans1.write(tmp);
4747

48-
#pragma HLS STREAM variable = strm_ctrl_trans1 depth = 2
49-
#pragma HLS STREAM variable = strm_ctrl_trans2 depth = 2
50-
#pragma HLS STREAM variable = strm_ctrl_trans3 depth = 2
51-
#pragma HLS STREAM variable = strm_ctrl_trans4 depth = 2
52-
#pragma HLS STREAM variable = strm_ctrl_trans5 depth = 2
48+
#pragma HLS STREAM variable = strm_ctrl_trans1 depth = 1024
49+
#pragma HLS STREAM variable = strm_ctrl_trans2 depth = 1024
50+
#pragma HLS STREAM variable = strm_ctrl_trans3 depth = 1024
51+
#pragma HLS STREAM variable = strm_ctrl_trans4 depth = 1024
52+
#pragma HLS STREAM variable = strm_ctrl_trans5 depth = 1024
5353

54-
#pragma HLS STREAM variable = strm_a depth = 64
55-
#pragma HLS STREAM variable = strm_b depth = 64
56-
#pragma HLS STREAM variable = strm_c depth = 64
57-
#pragma HLS STREAM variable = strm_d depth = 64
54+
#pragma HLS STREAM variable = strm_a depth = 4096
55+
#pragma HLS STREAM variable = strm_b depth = 4096
56+
#pragma HLS STREAM variable = strm_c depth = 4096
57+
#pragma HLS STREAM variable = strm_d depth = 4096
5858

5959
#pragma HLS DATAFLOW
6060

cpp_kernels/kernel_chain/src/krnl_mmult.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
#ifndef __KRNL_MMULT__
1717
#define __KRNL_MMULT__
1818
#define DWIDTH 32
19-
#define MAT_DIM 8
19+
#define MAT_DIM 32
2020
// typedef ap_axis<DWIDTH, 0, 0, 0> pkt;
2121
typedef int pkt;
2222
// Template to avoid signature conflict in sw_em
2323
template <int DUMMY = 0>
2424
void mm2s(int* a, hls::stream<pkt>& strm_a, hls::stream<int>& strm_ctrl_trans1, hls::stream<int>& strm_ctrl_trans2) {
2525
int dim = strm_ctrl_trans1.read();
26+
strm_ctrl_trans2.write(dim);
2627
int size = dim * dim;
2728

2829
// Auto-pipeline is going to apply pipeline to this loop
@@ -33,7 +34,6 @@ void mm2s(int* a, hls::stream<pkt>& strm_a, hls::stream<int>& strm_ctrl_trans1,
3334

3435
strm_a.write(p1);
3536
}
36-
strm_ctrl_trans2.write(dim);
3737
}
3838

3939
// Template to avoid signature conflict in sw_em
@@ -44,6 +44,7 @@ void mmult(hls::stream<pkt>& strm_a,
4444
hls::stream<pkt>& strm_out,
4545
hls::stream<int>& strm_ctrl_trans3) {
4646
int dim = strm_ctrl_trans2.read();
47+
strm_ctrl_trans3.write(dim);
4748
int size = dim * dim;
4849

4950
int buf_a[MAT_DIM][MAT_DIM];
@@ -96,7 +97,6 @@ void mmult(hls::stream<pkt>& strm_a,
9697

9798
strm_out.write(temp);
9899
}
99-
strm_ctrl_trans3.write(dim);
100100
}
101101

102102
// Template to avoid signature conflict in sw_em

0 commit comments

Comments
 (0)