fpga_synthesis merge
This commit is contained in:
32
runtime/tests/dev/Makefile
Normal file
32
runtime/tests/dev/Makefile
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
RISCV_TOOL_PATH ?= $(wildcard ../../../../riscv-gnu-toolchain/drops)
|
||||
|
||||
COMP = $(RISCV_TOOL_PATH)/bin/riscv32-unknown-elf-gcc
|
||||
# CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,linker.ld -ffreestanding -nostdlib
|
||||
CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,../../startup/vx_link.ld -ffreestanding -nostartfiles
|
||||
|
||||
DMP = $(RISCV_TOOL_PATH)/bin/riscv32-unknown-elf-objdump
|
||||
CPY = $(RISCV_TOOL_PATH)/bin/riscv32-unknown-elf-objcopy
|
||||
|
||||
|
||||
VX_STR = ../../startup/vx_start.S
|
||||
VX_INT = ../../intrinsics/vx_intrinsics.S
|
||||
VX_IO = ../../io/vx_io.S ../../io/vx_io.c
|
||||
VX_API = ../../vx_api/vx_api.c
|
||||
VX_TEST = ../common/tests.c
|
||||
|
||||
VX_MAIN = ./vx_dev_main.c
|
||||
|
||||
all: HEX DUMP ELF
|
||||
|
||||
DUMP: ELF
|
||||
$(DMP) -D vx_dev_main.elf > vx_dev_main.dump
|
||||
|
||||
HEX: ELF
|
||||
$(CPY) -O ihex vx_dev_main.elf vx_dev_main.hex
|
||||
|
||||
ELF:
|
||||
$(COMP) $(CC_FLAGS) $(VX_STR) $(VX_INT) $(VX_IO) $(VX_API) $(VX_TEST) $(VX_MAIN) -o vx_dev_main.elf
|
||||
|
||||
clean:
|
||||
rm -rf *.o *.elf *.dump *.hex *.qemu *.log *.debug
|
||||
115
runtime/tests/dev/vx_dev_main.c
Normal file
115
runtime/tests/dev/vx_dev_main.c
Normal file
@@ -0,0 +1,115 @@
|
||||
|
||||
#include "../../intrinsics/vx_intrinsics.h"
|
||||
#include "../../io/vx_io.h"
|
||||
#include "../common/tests.h"
|
||||
#include "../../vx_api/vx_api.h"
|
||||
|
||||
|
||||
// #include <utlist.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned * x;
|
||||
unsigned * y;
|
||||
unsigned * z;
|
||||
unsigned numColums;
|
||||
unsigned numRows;
|
||||
} mat_add_args_t;
|
||||
|
||||
|
||||
unsigned x[] = {5, 5, 5, 5,
|
||||
6, 6, 6, 6,
|
||||
7, 7, 7, 7,
|
||||
8, 8, 8, 8};
|
||||
|
||||
unsigned y[] = {1, 1, 1, 1,
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1};
|
||||
|
||||
unsigned z[] = {0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0};
|
||||
|
||||
void mat_add_kernel(void * void_arguments)
|
||||
{
|
||||
mat_add_args_t * arguments = (mat_add_args_t *) void_arguments;
|
||||
|
||||
unsigned wid = vx_warp_id();
|
||||
unsigned tid = vx_thread_id();
|
||||
|
||||
bool valid = (wid < arguments->numRows) && (tid < arguments->numColums);
|
||||
|
||||
__if (valid)
|
||||
{
|
||||
unsigned index = (wid * arguments->numColums) + tid;
|
||||
arguments->z[index] = arguments->x[index] + arguments->y[index];
|
||||
}
|
||||
__endif
|
||||
}
|
||||
|
||||
void vx_print_mat(unsigned * matPtr, int numRows, int numCols)
|
||||
{
|
||||
vx_print_str("---------------------\n");
|
||||
for (int i = 0; i < numRows; i++)
|
||||
{
|
||||
for (int j = 0; j < numCols; j++)
|
||||
{
|
||||
unsigned index = (i * numCols) + j;
|
||||
vx_print_hex(matPtr[index]);
|
||||
vx_print_str(" ");
|
||||
}
|
||||
vx_print_str("\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// Main is called with all threads active of warp 0
|
||||
vx_tmc(1);
|
||||
|
||||
// void * hellp = malloc(4);
|
||||
vx_print_str("Confirm Dev Main\n");
|
||||
|
||||
vx_print_str("vx_spawn_warps\n");
|
||||
|
||||
mat_add_args_t arguments;
|
||||
arguments.x = x;
|
||||
arguments.y = y;
|
||||
arguments.z = z;
|
||||
arguments.numColums = 4;
|
||||
arguments.numRows = 4;
|
||||
|
||||
|
||||
int numWarps = 4;
|
||||
int numThreads = 4;
|
||||
|
||||
// First kernel call
|
||||
vx_spawn_warps(numWarps, numThreads, mat_add_kernel, &arguments);
|
||||
vx_print_mat(z, arguments.numRows, arguments.numColums);
|
||||
|
||||
|
||||
arguments.x = z;
|
||||
arguments.y = y;
|
||||
arguments.z = z;
|
||||
arguments.numColums = 4;
|
||||
arguments.numRows = 4;
|
||||
|
||||
// Second Kernel Call
|
||||
vx_spawn_warps(numWarps, numThreads, mat_add_kernel, &arguments);
|
||||
vx_print_mat(z, arguments.numRows, arguments.numColums);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
87054
runtime/tests/dev/vx_dev_main.dump
Normal file
87054
runtime/tests/dev/vx_dev_main.dump
Normal file
File diff suppressed because it is too large
Load Diff
BIN
runtime/tests/dev/vx_dev_main.elf
Executable file
BIN
runtime/tests/dev/vx_dev_main.elf
Executable file
Binary file not shown.
5741
runtime/tests/dev/vx_dev_main.hex
Normal file
5741
runtime/tests/dev/vx_dev_main.hex
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user