dma and demo kernels

This commit is contained in:
Richard Yan
2024-06-07 18:11:19 -07:00
parent 33066af56e
commit 7cf59c9480
27 changed files with 1731 additions and 51 deletions

View File

@@ -5,7 +5,8 @@
#endif
#define SMEM_BASE 0xff000000
#define SMEM_SIZE 0x4000
//#define SMEM_SIZE 0x4000
#define SMEM_SIZE 0x10000
#define SMEM_MASK (SMEM_SIZE - 1)
#define SMEM_ADDR_END (SMEM_BASE + SMEM_SIZE)
@@ -31,10 +32,13 @@
// 0: k = 0, no accumulation
// 1: k % 2 = 0, buffer regions 0
// 2: k % 2 = 1, buffer regions 1
// 8, 9: memory ops
// 8: tile-sized move-in (unused)
// 8, 9, 10, 11: memory ops
// 8: tile-sized move-in stride
// 9: tile-sized move-out
// 10: tile-sized move-in, buffer regions 0
// 11: tile-sized move-in, buffer regions 1
#define GEMMINI_CISC_CMD_I(x) asm("csrwi 0xacc, "#x)
#define GEMMINI_CISC_CMD_R(x) asm("csrw 0xacc, %0" :: "r" (x))
#define GEMMINI_STATUS() ({uint32_t status; asm volatile ("csrr %0, 0xacc" : "=r" (status)); status;})
// convert normal matrix i,j into tiled smem offset
@@ -62,6 +66,9 @@
/* sprintf((char *) PRINT_BUF, "%llx %llx %d\n", rs1, rs2, funct); */ \
}
#define loop_matmul_skips(skip_lda, skip_ldb, skip_ldd, skip_ex, skip_stc) \
(((skip_lda) | ((skip_ldb) << 1) | ((skip_ldd) << 2) | ((skip_ex) << 3) | ((skip_stc) << 4)) << 3)
#define sp_tiled_matmul_full_spad_ws(A_sp_addr_start, B_sp_addr_start, D_sp_addr_start, C_dst_sp_addr_start,\
I, J, K, pad_I, pad_J, pad_K, a_transpose, b_transpose, full_C, low_D, acc, act, skips) \
gemmini_loop_ws_spad(I, J, K, pad_I, pad_J, pad_K, A_sp_addr_start, (B_sp_addr_start) + (K) * (J) * DIM, NULL, \

View File

@@ -10,8 +10,8 @@ ENTRY(_start)
MEMORY {
DRAM0 (rwx): ORIGIN = 0x80000000, LENGTH = 512M
DRAM1 (rwx): ORIGIN = 0xa0000000, LENGTH = 32K
DRAM2 (rwx): ORIGIN = 0xa1000000, LENGTH = 32K
DRAM1 (rwx): ORIGIN = 0xa0000000, LENGTH = 16M
DRAM2 (rwx): ORIGIN = 0xa1000000, LENGTH = 16M
}
SECTIONS
@@ -69,6 +69,7 @@ SECTIONS
/* .gnu.warning sections are handled specially by elf.em. */
*(.gnu.warning)
}
.fini :
{
KEEP (*(SORT_NONE(.fini)))
@@ -128,6 +129,7 @@ SECTIONS
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
@@ -135,6 +137,18 @@ SECTIONS
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.htif_pad : {
. = ALIGN(0x1000);
}
. = ALIGN(0x1000);
.tohost : {
*(.tohost)
/* . += 0x100; */
}
. = ALIGN(0x1000);
.ctors :
{
/* gcc uses crtbegin.o to find the start of
@@ -216,6 +230,8 @@ SECTIONS
MAX(__DATA_BEGIN__ + 0x800, __BSS_END__ - 0x800));
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }

View File

@@ -150,3 +150,4 @@ vx_wspawn_wait:
.weak __dso_handle
__dso_handle:
.long 0

7
kernel/tohost.S Normal file
View File

@@ -0,0 +1,7 @@
.section ".tohost","aw",@progbits
.align 6
.globl tohost
tohost: .dword 0
.align 6
.globl fromhost
fromhost: .dword 0