fixed loader script stack setup

This commit is contained in:
Blaise Tine
2020-12-31 22:37:20 -05:00
parent e757a0e333
commit e4a00dd0d9
43 changed files with 157370 additions and 118082 deletions

View File

@@ -20,21 +20,24 @@ void vx_split(int predicate);
// Join
void vx_join();
// Return the warp's unique thread id
// Return active warp's thread id
int vx_thread_id();
// Return the core's unique warp id
int vx_warp_id();
// Return processsor unique core id
int vx_core_id();
// Return active core's local thread id
int vx_thread_lid();
// Return processsor global thread id
int vx_thread_gid();
// Return processsor global warp id
// Return active core's local warp id
int vx_warp_id();
// Return processsor's global warp id
int vx_warp_gid();
// Return processsor core id
int vx_core_id();
// Return the number of threads in a warp
int vx_num_threads();

View File

@@ -9,7 +9,6 @@ OUTPUT_ARCH(riscv)
ENTRY(_start)
SECTIONS
{
PROVIDE(__stack_top = 0x6ffff000);
. = 0x80000000;
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
@@ -191,10 +190,24 @@ SECTIONS
. = SEGMENT_START("ldata-segment", .);
. = ALIGN(32 / 8);
__BSS_END__ = .;
__global_pointer$ = MIN(__SDATA_BEGIN__ + 0x800,
__global_pointer = MIN(__SDATA_BEGIN__ + 0x800,
MAX(__DATA_BEGIN__ + 0x800, __BSS_END__ - 0x800));
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
. = DATA_SEGMENT_END (.);
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
}
__stack_usage = SIZEOF(.stack_dummy);
PROVIDE(__stack_top = 0xFF000000);
PROVIDE(__stack_size = 0x400);
PROVIDE(__stack = __stack_top);
ASSERT(__stack_usage <= __stack_size, "stack overflow")
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }

View File

@@ -47,6 +47,12 @@ vx_warp_gid:
.type vx_thread_id, @function
.global vx_thread_id
vx_thread_id:
csrr a0, CSR_WTID
ret
.type vx_thread_lid, @function
.global vx_thread_lid
vx_thread_lid:
csrr a0, CSR_LTID
ret

View File

@@ -6,7 +6,7 @@
extern "C" {
#endif
#define NUM_CORES_MAX 8
#define NUM_CORES_MAX 16
typedef struct {
func_t function;

View File

@@ -57,18 +57,20 @@ vx_set_sp:
# set global pointer register
.option push
.option norelax
la gp, __global_pointer$
la gp, __global_pointer
.option pop
# allocate stack region for a threads on the processor
# set stack pointer
csrr a1, CSR_GTID # get global thread id
slli a1, a1, 10 # multiply by 1024
csrr a2, CSR_LTID # get local thread id
slli a2, a2, 2 # multiply by 4
la sp, __stack_top$ # load stack base address
la sp, __stack_top # load stack base address
la a1, __stack_size # stack size
#if SM_ENABLE
csrr a2, CSR_LTID # get lobal thread id
#else
csrr a2, CSR_GTID # get global thread id
#endif
mul a1, a1, a2
sub sp, sp, a1 # sub thread block
add sp, sp, a2 # reduce addr collision for perf
# disable active warps except warp0
csrr a3, CSR_LWID # get local wid

View File

@@ -1,14 +1,13 @@
#include <vx_intrinsics.h>
// #include <utlist.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <vx_intrinsics.h>
#include <vx_print.h>
#include <vx_spawn.h>
typedef struct
{
unsigned * x;

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +1,5 @@
#include <vx_intrinsics.h>
// #include <utlist.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
// Newlib
#include <stdio.h>
#include <vx_print.h>
int main()
{

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff