Force per-global-thread stack allocation

It's easy to miss setting SM_ENABLE according to our memory hierarchy,
which leads to data races in the stack that's hard to catch.  So be safe
and force enable per-core stack allocation.
This commit is contained in:
Hansung Kim
2023-10-22 01:54:21 -07:00
parent 92ed21f83f
commit 6563ed696e

View File

@@ -77,11 +77,14 @@ init_regs:
# allocate stack region for a threads on the processor # allocate stack region for a threads on the processor
# set stack pointer # set stack pointer
li sp, SMEM_BASE_ADDR # load stack base address li sp, SMEM_BASE_ADDR # load stack base address
#if SM_ENABLE # NOTE(hansung): Force per-global-thread stack allocation, since
csrr a0, CSR_LTID # get local thread id # we're experimenting with different memory hierarchy (i.e. no private cache)
#else # and it's easy to miss setting SM_ENABLE accordingly.
# #if SM_ENABLE
# csrr a0, CSR_LTID # get local thread id
# #else
csrr a0, CSR_GTID # get global thread id csrr a0, CSR_GTID # get global thread id
#endif # #endif
sll a1, a0, STACK_LOG2_SIZE sll a1, a0, STACK_LOG2_SIZE
sub sp, sp, a1 sub sp, sp, a1