mutiple fixes: parallel printf, fixed cycle in cache, opencl refactored vecadd and sgemm, regen opencl kernels with hard-float, fixed vortex io bus interface, fixed dpi floats APi to support multicore mode, make vlsim multicore default, make rtlsim multi-core default, removed POCL binaries from repository, updated Makefiles to use external POCL

This commit is contained in:
Blaise Tine
2020-09-19 14:45:42 -04:00
parent 80f929eb61
commit f6f95e0c46
146 changed files with 116779 additions and 194258 deletions

View File

@@ -1,11 +1,11 @@
RISCV_TOOLCHAIN_PATH ?= ~/dev/riscv-gnu-toolchain/drops
RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain
CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc
AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar
DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump
CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy
CFLAGS += -O3 -march=rv32im -mabi=ilp32
CFLAGS += -O3 -march=rv32imf -mabi=ilp32f
CFLAFS += -nostartfiles -ffreestanding -fno-exceptions -Wl,--gc-sections
CFLAGS += -I./include -I../hw

View File

@@ -1,17 +1,19 @@
#ifndef VX_IO_H
#define VX_IO_H
#ifndef VX_PRINT_H
#define VX_PRINT_H
#include <stdbool.h>
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
void vx_print_hex(unsigned);
void vx_printf(const char *, unsigned);
void vx_prints(const char * str);
void vx_printx(unsigned value);
void vx_printv(const char * str, unsigned value);
void vx_print_str(const char *);
void vx_printc(unsigned, char c);
int vx_vprintf(const char* format, va_list va);
int vx_printf(const char * format, ...);
int vx_putchar(int c);
#ifdef __cplusplus
}

View File

@@ -1,30 +1,14 @@
#include <VX_config.h>
.type vx_print_str, @function
.global vx_print_str
vx_print_str:
addi sp, sp, -12
sw ra, 0(sp)
sw a1, 4(sp)
bl:
lbu a1,0(a0)
beqz a1,be
jal vx_printc
addi a0, a0, 1
j bl
be:
lw ra, 0(sp)
lw a1, 4(sp)
addi sp, sp, 12
ret
.type vx_printc, @function
.global vx_printc
vx_printc:
.type vx_putchar, @function
.global vx_putchar
vx_putchar:
la t0, print_addr
lw t0, 0(t0)
sw a1, 0(t0)
csrr t1, CSR_GTID
slli t1, t1, 16
or t1, t1, a0
sw t1, 0(t0)
ret
.section .data

View File

@@ -1,38 +1,165 @@
#include <vx_print.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
static char * hextoa[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
void vx_print_hex(unsigned f)
{
// vx_print_str(hextoa[f]);
if (f < 16)
{
vx_print_str(hextoa[f]);
return;
static const char* skip_flags(const char* format) {
for (;;) {
int c = *format++;
switch (c) {
case '-':
case '+':
case ' ':
case '#': break;
default : {
return --format;
}
}
}
int temp;
int sf = 32;
bool start = false;
do
{
temp = (f >> (sf - 4)) & 0xf;
if (temp != 0) start = true;
if (start) vx_print_str(hextoa[temp]);
sf -= 4;
} while(sf > 0);
return NULL;
}
static const char* skip_width(const char* format) {
if (*format == '*') {
++format;
} else {
char *endptr;
strtol(format, &endptr, 10);
format = endptr;
}
return format;
}
void vx_printf(const char * c, unsigned f)
{
vx_print_str(c);
vx_print_hex(f);
vx_print_str("\n");
static const char* skip_precision(const char* format) {
if (*format == '.') {
++format;
if (*format == '*') {
++format;
} else {
char *endptr;
strtol(format, &endptr, 10);
format = endptr;
}
}
return format;
}
static const char* skip_modifier(const char* format) {
switch (*format) {
case 'h':
format++;
if (*format == 'h') {
format++;
}
break;
case 'l':
++format;
if (*format == 'l') {
++format;
}
break;
case 'j':
case 'z':
case 't':
case 'L':
++format;
break;
default:
break;
}
return format;
}
static const char* parse_format(const char* format, va_list va) {
char buffer[64];
char fmt[64];
const char* p = format;
p = skip_flags(p);
p = skip_width(p);
p = skip_precision(p);
p = skip_modifier(p);
++p;
int i;
fmt[0] = '%';
for (i = 0; i < (p - format); ++i) {
fmt[i+1] = format[i];
}
fmt[i+1] = 0;
int len = vsnprintf(buffer, 256, fmt, va);
for (i = 0; i < len; ++i) {
vx_putchar(buffer[i]);
}
return p;
}
int vx_vprintf(const char* format, va_list va) {
if (format == NULL)
return -1;
const char* p = format;
int c = *p++;
while (c) {
if (c == '%') {
p = parse_format(p, va);
c = *p++;
} else {
vx_putchar(c);
c = *p++;
}
}
return (int)(p - format);
}
int vx_printf(const char * format, ...) {
va_list va;
va_start(va, format);
int ret = vx_vprintf(format, va);
va_end(va);
return ret;
}
static const char hextoa[] = "0123456789abcdef";
void vx_prints(const char * str) {
int c = *str++;
while (c) {
vx_putchar(c);
c = *str++;
}
}
void vx_printx(unsigned value) {
if (value < 16) {
vx_putchar(hextoa[value]);
} else {
int i = 32;
bool start = false;
do {
int temp = (value >> (i - 4)) & 0xf;
if (temp != 0)
start = true;
if (start)
vx_putchar(hextoa[temp]);
i-= 4;
} while (i != 0);
}
vx_putchar('\n');
}
void vx_printv(const char * str, unsigned value) {
vx_prints(str);
vx_printx(value);
}
#ifdef __cplusplus

View File

@@ -1,4 +1,4 @@
RISCV_TOOLCHAIN_PATH ?= ~/dev/riscv-gnu-toolchain/drops
RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain
VORTEX_RT_PATH ?= $(wildcard ../..)
CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc
@@ -6,7 +6,7 @@ AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar
DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump
CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy
CFLAGS += -march=rv32im -mabi=ilp32 -O3 -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld
CFLAGS += -march=rv32imf -mabi=ilp32f -O3 -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld
CFLAGS += -nostartfiles -ffreestanding -fno-exceptions -Wl,--gc-sections
CFLAGS += -I$(VORTEX_RT_PATH)/include

View File

@@ -53,16 +53,13 @@ void mat_add_kernel(void * void_arguments)
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++)
{
vx_printf("---------------------\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_printf("0x%x ", matPtr[index]);
}
vx_print_str("\n");
vx_printf("\n");
}
}
@@ -72,9 +69,9 @@ int main()
vx_tmc(1);
// void * hellp = malloc(4);
vx_print_str("Confirm Dev Main\n");
vx_printf("Confirm Dev Main\n");
vx_print_str("vx_spawn_warps\n");
vx_printf("vx_spawn_warps\n");
mat_add_args_t arguments;
arguments.x = x;

View File

@@ -1,4 +1,4 @@
RISCV_TOOLCHAIN_PATH ?= ~/dev/riscv-gnu-toolchain/drops
RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain
VORTEX_RT_PATH ?= $(wildcard ../..)
CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc
@@ -6,7 +6,7 @@ AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar
DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump
CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy
CFLAGS += -march=rv32im -mabi=ilp32 -O3 -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld
CFLAGS += -march=rv32imf -mabi=ilp32f -O3 -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld
CFLAGS += -nostartfiles -ffreestanding -fno-exceptions -Wl,--gc-sections
CFLAGS += -I$(VORTEX_RT_PATH)/include

View File

@@ -1,4 +1,4 @@
RISCV_TOOLCHAIN_PATH ?= ~/dev/riscv-gnu-toolchain/drops
RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain
VORTEX_RT_PATH ?= $(wildcard ../..)
CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc
@@ -6,7 +6,7 @@ AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar
DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump
CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy
CFLAGS += -march=rv32im -mabi=ilp32 -O3 -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld
CFLAGS += -march=rv32imf -mabi=ilp32f -O3 -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld
CFLAGS += -nostartfiles -ffreestanding -fno-exceptions -Wl,--gc-sections
CFLAGS += -I$(VORTEX_RT_PATH)/include

View File

@@ -1,4 +1,4 @@
RISCV_TOOLCHAIN_PATH ?= ~/dev/riscv-gnu-toolchain/drops
RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain
VORTEX_RT_PATH ?= $(wildcard ../..)
CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc
@@ -6,8 +6,8 @@ AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar
DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump
CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy
CFLAGS += -march=rv32im -mabi=ilp32 -O3 -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld
CFLAGS += -nostartfiles -ffreestanding -fno-exceptions -Wl,--gc-sections
CFLAGS += -march=rv32imf -mabi=ilp32f -O3 -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld
CFLAGS += -nostartfiles -ffreestanding -fno-exceptions -Wl,--gc-sections
CFLAGS += -I$(VORTEX_RT_PATH)/include -I../../../hw
LDFLAGS += $(VORTEX_RT_PATH)/libvortexrt.a

View File

@@ -1,13 +1,11 @@
#include "tests.h"
#include <stdbool.h>
#include <vx_intrinsics.h>
#include <vx_print.h>
#include <vx_spawn.h>
#include <VX_config.h>
typedef struct
{
typedef struct {
unsigned * x;
unsigned * y;
unsigned * z;
@@ -15,7 +13,6 @@ typedef struct
unsigned numRows;
} mat_add_args_t;
unsigned x[] = {5, 5, 5, 5,
6, 6, 6, 6,
7, 7, 7, 7,
@@ -31,8 +28,7 @@ unsigned z[] = {0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0};
void mat_add_kernel(void * void_arguments)
{
void mat_add_kernel(void * void_arguments) {
mat_add_args_t * arguments = (mat_add_args_t *) void_arguments;
unsigned wid = vx_warp_id();
@@ -49,73 +45,60 @@ void mat_add_kernel(void * void_arguments)
// __endif
}
int main()
{
// ensure single thread
vx_tmc(1);
int main() {
vx_printf("Let's start... (This might take a while)\n");
vx_print_str("Let's start... (This might take a while)\n");
unsigned what[36];
bool passed = true;
for (int i = 0; i < 36; i++)
{
for (int i = 0; i < 36; i++) {
what[i] = i;
// vx_print_hex(i);
// vx_printf(": ", what[i]);
if (what[i] != i)
{
if (what[i] != i) {
passed = false;
vx_printf("T1 Fail On ", i);
vx_printf("T1 Fail On %d", i);
}
}
for (int i = 0; i < 36; i++)
{
// vx_print_hex(i);
// vx_printf(": ", what[i]);
if (what[i] != i)
{
for (int i = 0; i < 36; i++) {
if (what[i] != i) {
passed = false;
vx_printf("T2 Fail on ", i);
vx_printf("T2 Fail on %d", i);
}
}
if (passed)
{
vx_print_str("Wr->read and repeat(Wr) tests passed!\n");
if (passed) {
vx_printf("Wr->read and repeat(Wr) tests passed!\n");
}
vx_print_str("Simple Main\n");
vx_printf("Simple Main\n");
// TMC test
test_tmc();
// Control Divergence Test
vx_print_str("test_divergence\n");
vx_tmc(4);
vx_printf("test_divergence\n");
test_divergence();
vx_tmc(1);
// Test wspawn
vx_print_str("test_wspawn\n");
vx_printf("test_wspawn\n");
test_wsapwn();
vx_print_str("Shared Memory test\n");
vx_printf("Shared Memory test\n");
unsigned * ptr = (unsigned *) SHARED_MEM_BASE_ADDR;
unsigned value = 0;
for (int i = 0; i < 5; i++)
{
for (int i = 0; i < 5; i++) {
*ptr = value;
unsigned read_valud = *ptr;
vx_printf("ptr: ", (unsigned) ptr);
vx_printf("Original Value: ", value);
vx_printf("Read Value: ", read_valud);
vx_print_str("-------------------\n");
vx_printf("ptr: %p\n", ptr);
vx_printf("Original Value: %x\n", value);
vx_printf("Read Value: %x\n", read_valud);
vx_printf("-------------------\n");
value++;
ptr++;
}
vx_print_str("vx_spawn_warps mat_add_kernel\n");
vx_printf("vx_spawn_warps mat_add_kernel\n");
mat_add_args_t arguments;
arguments.x = x;
@@ -124,24 +107,20 @@ int main()
arguments.numColums = 4;
arguments.numRows = 4;
int numWarps = 4;
int numThreads = 4;
vx_spawn_warps(numWarps, numThreads, mat_add_kernel, &arguments);
vx_print_str("Waiting to ensure other warps are done... (Takes a while)\n");
vx_printf("Waiting to ensure other warps are done... (Takes a while)\n");
for (int i = 0; i < 5000; i++) {}
for (int i = 0; i < numWarps; i++)
{
for (int j = 0; j < numThreads; j++)
{
for (int i = 0; i < numWarps; i++) {
for (int j = 0; j < numThreads; j++) {
unsigned index = (i * arguments.numColums) + j;
vx_print_hex(z[index]);
vx_print_str(" ");
vx_printf("0x%x ", z[index]);
}
vx_print_str("\n");
vx_printf("\n");
}
return 0;

View File

@@ -1,128 +1,83 @@
#include "tests.h"
#include <stdbool.h>
#include <vx_intrinsics.h>
#include <vx_print.h>
int tmc_array[4] = {5,5,5,5};
int tmc_array[4] = {5, 5, 5, 5};
void test_tmc_impl()
{
void test_tmc_impl() {
unsigned tid = vx_thread_id(); // Get TID
tmc_array[tid] = tid;
}
void test_tmc()
{
vx_print_str("testing_tmc\n");
void test_tmc() {
vx_printf("testing_tmc\n");
vx_tmc(4);
test_tmc_impl();
vx_tmc(1);
vx_print_hex(tmc_array[0]);
vx_print_str("\n");
vx_print_hex(tmc_array[1]);
vx_print_str("\n");
vx_print_hex(tmc_array[2]);
vx_print_str("\n");
vx_print_hex(tmc_array[3]);
vx_print_str("\n");
vx_printx(tmc_array[0]);
vx_printx(tmc_array[1]);
vx_printx(tmc_array[2]);
vx_printx(tmc_array[3]);
return;
}
int div_arr[4];
void test_divergence()
{
void test_divergence() {
vx_tmc(4);
unsigned tid = vx_thread_id(); // Get TID
bool b = tid < 2;
__if (b)
{
__if (b) {
bool c = tid < 1;
__if (c)
{
__if (c) {
div_arr[tid] = 10;
}
__else
{
__else {
div_arr[tid] = 11;
}
__endif
}
__else
{
__else {
bool c = tid < 3;
__if (c)
{
__if (c) {
div_arr[tid] = 12;
}
__else
{
__else {
div_arr[tid] = 13;
}
__endif
}
__endif
vx_print_hex(div_arr[0]);
vx_print_str("\n");
vx_print_hex(div_arr[1]);
vx_print_str("\n");
vx_print_hex(div_arr[2]);
vx_print_str("\n");
vx_print_hex(div_arr[3]);
vx_print_str("\n");
vx_tmc(1);
vx_printx(div_arr[0]);
vx_printx(div_arr[1]);
vx_printx(div_arr[2]);
vx_printx(div_arr[3]);
}
unsigned wsapwn_arr[4];
void simple_kernel()
{
void simple_kernel() {
unsigned wid = vx_warp_id();
wsapwn_arr[wid] = wid;
if (wid != 0)
{
vx_tmc(0);
}
vx_tmc(0 == wid);
}
void test_wsapwn()
{
unsigned func_ptr = (unsigned) simple_kernel;
vx_wspawn(4, func_ptr);
void test_wsapwn() {
vx_wspawn(4, (unsigned)simple_kernel);
simple_kernel();
for (int i = 0; i < 100; i++) {}
vx_print_hex(wsapwn_arr[0]);
vx_print_str("\n");
vx_print_hex(wsapwn_arr[1]);
vx_print_str("\n");
vx_print_hex(wsapwn_arr[2]);
vx_print_str("\n");
vx_print_hex(wsapwn_arr[3]);
vx_print_str("\n");
}
void intrinsics_tests()
{
// TMC test
test_tmc();
// Control Divergence Test
vx_print_str("test_divergence\n");
vx_tmc(4);
test_divergence();
vx_tmc(1);
// Test wspawn
vx_print_str("test_spawn\n");
test_wsapwn();
vx_printx(wsapwn_arr[0]);
vx_printx(wsapwn_arr[1]);
vx_printx(wsapwn_arr[2]);
vx_printx(wsapwn_arr[3]);
}

View File

@@ -7,6 +7,4 @@ void test_divergence();
void test_wsapwn();
void intrinsics_tests();
#endif

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,4 +1,4 @@
RISCV_TOOLCHAIN_PATH ?= ~/dev/riscv-gnu-toolchain/drops
RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain
VORTEX_RT_PATH ?= $(wildcard ../..)
CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc
@@ -6,7 +6,7 @@ AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar
DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump
CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy
CFLAGS += -march=rv32im -mabi=ilp32 -O3 -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld
CFLAGS += -march=rv32imf -mabi=ilp32f -O3 -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld
CFLAGS += -nostartfiles -ffreestanding -fno-exceptions -Wl,--gc-sections
CFLAGS += -I$(VORTEX_RT_PATH)/include -I./include