PandA-2024.02
mmult.c
Go to the documentation of this file.
1 #define rank 32
2 #define tile_rank 2
3 
4 /* AXI pragmas */
5 #pragma HLS interface port = a mode = m_axi offset = direct bundle = gmem0
6 #pragma HLS interface port = b mode = m_axi offset = direct bundle = gmem1
7 #pragma HLS interface port = output mode = m_axi offset = direct bundle = gmem2
8 
9 /* Cache pragmas */
10 #pragma HLS cache bundle = gmem0 line_count = 16 line_size = 16 bus_size = 32 ways = 1 num_write_outstanding = 2 rep_policy = \
11  lru write_policy = wt
12 #pragma HLS cache bundle = gmem1 line_count = 32 line_size = 16 bus_size = 32 ways = 1 num_write_outstanding = 2 rep_policy = \
13  tree write_policy = wt
14 #pragma HLS cache bundle = gmem2 line_count = 16 line_size = 16 bus_size = 32 ways = 1 num_write_outstanding = 4 rep_policy = \
15  tree write_policy = wb
16 
17 void mmult(int* a, int* b, int* output)
18 {
19  int running = 0;
20 
21  for(unsigned c_tile = 0; c_tile < tile_rank; c_tile++)
22  {
23  for(unsigned r_tile = 0; r_tile < tile_rank; r_tile++)
24  {
25  for(unsigned r = 0; r < rank / tile_rank; r++)
26  {
27  for(unsigned c = 0; c < rank / tile_rank; c++)
28  {
29  output[(r + r_tile * rank / tile_rank) * rank + (c + c_tile * rank / tile_rank)] = 0;
30  }
31  }
32  for(unsigned i_tile = 0; i_tile < tile_rank; i_tile++)
33  {
34  for(unsigned c = 0; c < rank / tile_rank; c++)
35  {
36  for(unsigned r = 0; r < rank / tile_rank; r++)
37  {
38  running = 0;
39  for(unsigned index = 0; index < rank / tile_rank; index++)
40  {
41  unsigned aIndex = (r + r_tile * rank / tile_rank) * rank + (index + i_tile * rank / tile_rank);
42  unsigned bIndex = (index + i_tile * rank / tile_rank) * rank + (c + c_tile * rank / tile_rank);
43  running += a[aIndex] * b[bIndex];
44  }
45  output[(r + r_tile * rank / tile_rank) * rank + (c + c_tile * rank / tile_rank)] += running;
46  }
47  }
48  }
49  }
50  }
51 }
#define tile_rank
Definition: mmult.c:2
volatile int output[DIM_Y][DIM_X]
Definition: los.h:1
#define index(x, y)
Definition: Keccak.c:74
#define rank
Definition: mmult.c:1
void mmult(int *a, int *b, int *output)
Definition: mmult.c:17

Generated on Mon Feb 12 2024 13:02:48 for PandA-2024.02 by doxygen 1.8.13