Skip to content

Commit

Permalink
enable mcycle in matadd examples (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
davideschiavone authored Oct 19, 2023
1 parent 27fb6ad commit df569a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions sw/applications/example_matadd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ int main()
int N = WIDTH;
int M = HEIGHT;
uint32_t errors = 0;
unsigned int instr, cycles, ldstall, jrstall, imstall;
unsigned int instr, cycles;

//enable mcycle csr
CSR_CLEAR_BITS(CSR_REG_MCOUNTINHIBIT, 0x1);

CSR_WRITE(CSR_REG_MCYCLE, 0);

//execute the kernel
matrixAdd(m_a, m_b, m_c, N, M);

CSR_READ(CSR_REG_MCYCLE, &cycles) ;

//stop the HW counter used for monitoring
CSR_READ(CSR_REG_MCYCLE, &cycles);

errors = check_results(m_c, N, M);

Expand Down
5 changes: 4 additions & 1 deletion sw/applications/example_matfadd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,14 @@ int main()
int N = WIDTH;
int M = HEIGHT;
uint32_t errors = 0;
unsigned int instr, cycles, ldstall, jrstall, imstall;
unsigned int instr, cycles;

//enable FP operations
CSR_SET_BITS(CSR_REG_MSTATUS, (FS_INITIAL << 13));

//enable mcycle csr
CSR_CLEAR_BITS(CSR_REG_MCOUNTINHIBIT, 0x1);

CSR_WRITE(CSR_REG_MCYCLE, 0);

//execute the kernel
Expand Down

0 comments on commit df569a8

Please sign in to comment.