Skip to content

Commit

Permalink
Continue ongoing concurrent request support
Browse files Browse the repository at this point in the history
  • Loading branch information
dpretet committed Sep 5, 2023
1 parent 9d9e136 commit 2397cc7
Show file tree
Hide file tree
Showing 8 changed files with 1,696 additions and 2,032 deletions.
5 changes: 4 additions & 1 deletion rtl/friscv_memfy.sv
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ module friscv_memfy

// Continue to accept if IDLE.READY and didn't reach yet maximum of
// outstanding requests available
assign memfy_ready = memfy_ready_fsm & !rd_or_full & !stall_bus;
assign memfy_ready = memfy_ready_fsm & !max_rd_or & !max_wr_or & !stall_bus;


////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -673,6 +673,9 @@ module friscv_memfy
$fwrite(f, "(@ %0t) Exception encountered: store misaligned\n", $realtime);

`endif

if (load_misaligned || store_misaligned)
$error("Memfy exceptions");
memfy_exceptions[`LD_MA] <= load_misaligned;
memfy_exceptions[`ST_MA] <= store_misaligned;
end
Expand Down
4 changes: 2 additions & 2 deletions rtl/friscv_memfy_ordering.sv
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module friscv_memfy_ordering

generate

if (AXI_ORDERING == 0) begin
if (AXI_ORDERING == 0) begin : STRICT_ORDERING

assign pending_wr = (wr_or_cnt!={MAX_OR_W{1'b0}} && !(wr_or_cnt=={{(MAX_OR_W-1){1'b0}}, 1'b1} & bvalid)) ? 1'b1 : 1'b0;
assign pending_rd = (rd_or_cnt!={MAX_OR_W{1'b0}} && !(rd_or_cnt=={{(MAX_OR_W-1){1'b0}}, 1'b1} & rvalid)) ? 1'b1 : 1'b0;
Expand All @@ -151,7 +151,7 @@ module friscv_memfy_ordering
// Advanced mode, using LUT for read / write request tracking, providing
// better performance
////////////////////////////////////////////////////////////////////////
end else begin
end else begin: WEAK_ORDERING

assign push_wr = memfy_valid && memfy_ready && memfy_opcode==`STORE;
assign pull_wr = bvalid & bready;
Expand Down
1,499 changes: 752 additions & 747 deletions test/apps/tests/repl.v

Large diffs are not rendered by default.

178 changes: 92 additions & 86 deletions test/apps/tests/repl/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "xoshiro128plusplus.h"
#include "pool_arena.h"
#include "tty.h"
#include "soc_mapping.h"

// -----------------------------------------------------------------------------------------------
// Benchmarks global variables
Expand All @@ -19,12 +20,12 @@ int xoshi_bench(int max_iterations);
int pool_arena_bench(int max_iterations);

struct perf {
int active_start;
int active_end;
int sleep_start;
int sleep_end;
int stall_start;
int stall_end;
int active_start;
int active_end;
int sleep_start;
int sleep_end;
int stall_start;
int stall_end;
};

struct meter {
Expand All @@ -34,9 +35,9 @@ struct meter {
int instret_end;
int cycles;
int instret;
struct perf instreq_perf;
struct perf instcpl_perf;
struct perf proc_perf;
struct perf instreq_perf;
struct perf instcpl_perf;
struct perf proc_perf;
};

struct meter bench;
Expand Down Expand Up @@ -140,26 +141,31 @@ int benchmark(int argc, char *argv[]) {
// Execute benchmarks
// -----------------------------------------------------------------

// printf("Test 1\n");
if (chacha20_bench(nb_iterations)) {
ret += 1;
printf("Chacha20 computation failed\n");
}

printf("Test 2\n");
if (matrix_bench(nb_iterations)) {
ret += 1;
printf("Matrix computation failed\n");
}

printf("Test 3\n");
if (printf_bench(nb_iterations)) {
ret += 1;
printf("Printf computation failed\n");
}

printf("Test 4\n");
if (xoshi_bench(nb_iterations)) {
ret += 1;
printf("Xoshiro128++ computation failed\n");
}

printf("Test 5\n");
if (pool_arena_bench(nb_iterations)) {
ret += 1;
printf("Pool Arena computation failed\n");
Expand Down Expand Up @@ -190,30 +196,30 @@ int benchmark(int argc, char *argv[]) {

printf("\nReporting:\n");

printf("\nGeneral statistics:\n");
printf("\nGeneral statistics:\n");
printf(" - Start time: %d\n", bench.cycle_start);
printf(" - End time: %d\n", bench.cycle_end);
printf(" - Total elapsed time: %d cycles\n", bench.cycles);
printf(" - Instret start: %d\n", bench.instret_start);
printf(" - Instret end: %d\n", bench.instret_end);
printf(" - Retired instructions: %d\n", bench.instret);

printf("\nInstruction Bus Request:\n");
printf(" - active cycles: %d\n", bench.instreq_perf.active_end - bench.instreq_perf.active_start);
printf(" - sleep cycles: %d\n", bench.instreq_perf.sleep_end - bench.instreq_perf.sleep_start);
printf(" - stall cycles: %d\n", bench.instreq_perf.stall_end - bench.instreq_perf.stall_start);
printf("\nInstruction Bus Request:\n");
printf(" - active cycles: %d\n", bench.instreq_perf.active_end - bench.instreq_perf.active_start);
printf(" - sleep cycles: %d\n", bench.instreq_perf.sleep_end - bench.instreq_perf.sleep_start);
printf(" - stall cycles: %d\n", bench.instreq_perf.stall_end - bench.instreq_perf.stall_start);

printf("\nInst Bus Completion:\n");
printf(" - active cycles: %d\n", bench.instcpl_perf.active_end - bench.instcpl_perf.active_start);
printf(" - sleep cycles: %d\n", bench.instcpl_perf.sleep_end - bench.instcpl_perf.sleep_start);
printf(" - stall cycles: %d\n", bench.instcpl_perf.stall_end - bench.instcpl_perf.stall_start);
printf("\nInst Bus Completion:\n");
printf(" - active cycles: %d\n", bench.instcpl_perf.active_end - bench.instcpl_perf.active_start);
printf(" - sleep cycles: %d\n", bench.instcpl_perf.sleep_end - bench.instcpl_perf.sleep_start);
printf(" - stall cycles: %d\n", bench.instcpl_perf.stall_end - bench.instcpl_perf.stall_start);

printf("\nProcessing Bus:\n");
printf(" - active cycles: %d\n", bench.proc_perf.active_end - bench.proc_perf.active_start);
printf(" - sleep cycles: %d\n", bench.proc_perf.sleep_end - bench.proc_perf.sleep_start);
printf(" - stall cycles: %d\n", bench.proc_perf.stall_end - bench.proc_perf.stall_start);
printf("\nProcessing Bus:\n");
printf(" - active cycles: %d\n", bench.proc_perf.active_end - bench.proc_perf.active_start);
printf(" - sleep cycles: %d\n", bench.proc_perf.sleep_end - bench.proc_perf.sleep_start);
printf(" - stall cycles: %d\n", bench.proc_perf.stall_end - bench.proc_perf.stall_start);

printf("\nAlgorithms:\n");
printf("\nAlgorithms:\n");
printf("- Chacha20 execution: %d cycles\n", chacha20.cycles);
printf("- Matrix execution: %d cycles\n", matrix.cycles);
printf("- Printf execution: %d cycles\n", print.cycles);
Expand Down Expand Up @@ -464,80 +470,80 @@ int xoshi_bench(int max_iterations) {

int pool_arena_bench(int max_iterations) {

char pool[ARENA_SIZE];
int p=0;
void * pts[MAX_CHUNK];
unsigned int chunk_size = 1;
char * array;
char pool[ARENA_SIZE];
int p=0;
void * pts[MAX_CHUNK];
unsigned int chunk_size = 1;
char * array;

arena.cycle_start = 0;
arena.cycle_end = 0;
arena.cycles = 0;

asm volatile("csrr %0, 0xC00" : "=r"(arena.cycle_start));

// Erase first the pool memory zone
for (int i=0;i<ARENA_SIZE;i++)
pool[i] = '\0';
// Create a pool arena in memory
pool_init(&pool, ARENA_SIZE);
/* printf("Pool arena: %p\n", &pool); */

while (chunk_size < ARENA_SIZE) {
// Erase pointers
for (int i=0;i<16;i++) {
pts[i] = NULL;
}
// Allocate as much blocks as possible and stop at first fail
/* printf("Allocate chunks\n"); */
p = 0;
while (p<MAX_CHUNK) {
pts[p] = pool_malloc(chunk_size);
if (pts[p] == NULL)
break;
printf("%p\n", pts[p]);
p++;
}


// Init the chunks with data
for (int i=0;i<16;i++) {
if (pts[i] != NULL) {
array = pts[i];
for (int j=0;j<chunk_size;j++)
array[j] = i;
}
}
// Check back data
for (int i=0;i<16;i++) {
if (pts[i] != NULL) {
array = pts[i];
for (int j=0;j<chunk_size;j++)
if (array[j] != i) {
printf("ERROR: pool arena failed during data check\n");
return 1;
}
}
}
// Free the pointers
/* printf("Free chunks\n"); */
p = 0;
while (p<MAX_CHUNK) {
if (pts[p] != NULL)
pool_free(pts[p]);
else
break;
p++;
}

pool_check();
chunk_size += 1;
}
// Erase first the pool memory zone
for (int i=0;i<ARENA_SIZE;i++)
pool[i] = '\0';
// Create a pool arena in memory
pool_init(&pool, ARENA_SIZE);
/* printf("Pool arena: %p\n", &pool); */

while (chunk_size < ARENA_SIZE) {
// Erase pointers
for (int i=0;i<16;i++) {
pts[i] = NULL;
}
// Allocate as much blocks as possible and stop at first fail
/* printf("Allocate chunks\n"); */
p = 0;
while (p<MAX_CHUNK) {
pts[p] = pool_malloc(chunk_size);
if (pts[p] == NULL)
break;
printf("%p\n", pts[p]);
p++;
}


// Init the chunks with data
for (int i=0;i<16;i++) {
if (pts[i] != NULL) {
array = pts[i];
for (int j=0;j<chunk_size;j++)
array[j] = i;
}
}
// Check back data
for (int i=0;i<16;i++) {
if (pts[i] != NULL) {
array = pts[i];
for (int j=0;j<chunk_size;j++)
if (array[j] != i) {
printf("ERROR: pool arena failed during data check\n");
return 1;
}
}
}
// Free the pointers
/* printf("Free chunks\n"); */
p = 0;
while (p<MAX_CHUNK) {
if (pts[p] != NULL)
pool_free(pts[p]);
else
break;
p++;
}

pool_check();
chunk_size += 1;
}

asm volatile("csrr %0, 0xC00" : "=r"(arena.cycle_end));

arena.cycles = arena.cycle_end - arena.cycle_start;


return 0;
return 0;
}
Loading

0 comments on commit 2397cc7

Please sign in to comment.