refactoring fixes

This commit is contained in:
Blaise Tine
2020-04-14 19:39:59 -04:00
parent 22c8da7490
commit 12dc4d6874
624 changed files with 600 additions and 28528 deletions

View File

@@ -0,0 +1,28 @@
COMP = /opt/riscv-new/drops/bin/riscv32-unknown-elf-g++
CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,../../startup/vx_link.ld -ffreestanding -nostdlib
DMP = /opt/riscv-new/drops/bin/riscv32-unknown-elf-objdump
CPY = /opt/riscv-new/drops/bin/riscv32-unknown-elf-objcopy
NEWLIB = ../../newlib/newlib.c
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_FIO = ../../fileio/fileio.s
LIBS = /opt/riscv-new/drops/riscv32-unknown-elf/lib/libc.a /opt/riscv-new/drops/riscv32-unknown-elf/lib/libstdc++.a -static-libgcc -lgcc
VX_SRCS = vx_simple_main.c tests.c
all: HEX DUMP ELF
DUMP: ELF
$(DMP) -D $(VX_MAIN).elf > $(VX_MAIN).dump
HEX: ELF
$(CPY) -O ihex $(VX_MAIN).elf $(VX_MAIN).hex
ELF:
$(COMP) $(CC_FLAGS) $(VX_STR) $(VX_FIO) $(NEWLIB) $(VX_INT) $(VX_IO) $(VX_API) $(VX_SRCS) $(LIBS) -Iinclude -o $(VX_MAIN).elf

View File

@@ -0,0 +1,142 @@
#include "tests.h"
#include "../../intrinsics/vx_intrinsics.h"
#include "../../io/vx_io.h"
int tmc_array[4] = {5,5,5,5};
void test_tmc()
{
vx_print_str("testing_tmc\n");
vx_tmc(4);
unsigned tid = vx_threadID(); // Get TID
tmc_array[tid] = tid;
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");
return;
}
int div_arr[4];
void test_divergence()
{
unsigned tid = vx_threadID(); // Get TID
bool b = tid < 2;
__if (b)
{
bool c = tid < 1;
__if (c)
{
div_arr[tid] = 10;
}
__else
{
div_arr[tid] = 11;
}
__endif
}
__else
{
bool c = tid < 3;
__if (c)
{
div_arr[tid] = 12;
}
__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");
}
unsigned wsapwn_arr[4];
void simple_kernel()
{
unsigned wid = vx_warpID();
wsapwn_arr[wid] = wid;
wid = vx_warpID();
if (wid != 0)
{
vx_tmc(0);
}
}
void test_wsapwn()
{
unsigned func_ptr = (unsigned) simple_kernel;
vx_wspawn(4, func_ptr);
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();
}

View File

@@ -0,0 +1,14 @@
#ifndef TESTS
#define TESTS
void test_tmc();
void test_divergence();
void test_wsapwn();
void intrinsics_tests();
#endif

View File

@@ -0,0 +1,151 @@
#include "../../intrinsics/vx_intrinsics.h"
#include "../../io/vx_io.h"
#include "../common/tests.h"
#include "../../vx_api/vx_api.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_warpID();
unsigned tid = vx_threadID();
bool valid = (wid < arguments->numRows) && (tid < arguments->numColums);
// __if (valid)
// {
unsigned index = (wid * arguments->numColums) + tid;
unsigned val = arguments->x[index] + arguments->y[index];
arguments->z[index] = val;
// }
// __endif
}
int main()
{
// Main is called with all threads active of warp 0
vx_tmc(1);
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++)
{
what[i] = i;
// vx_print_hex(i);
// vx_printf(": ", what[i]);
if (what[i] != i)
{
passed = false;
vx_printf("T1 Fail On ", i);
}
}
for (int i = 0; i < 36; i++)
{
// vx_print_hex(i);
// vx_printf(": ", what[i]);
if (what[i] != i)
{
passed = false;
vx_printf("T2 Fail on ", i);
}
}
if (passed)
{
vx_print_str("Wr->read and repeat(Wr) tests passed!\n");
}
vx_print_str("Simple Main\n");
// // 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_wspawn\n");
test_wsapwn();
vx_print_str("Shared Memory test\n");
unsigned * ptr = (unsigned *) 0xFFFF0000;
unsigned value = 0;
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");
value++;
ptr++;
}
vx_print_str("vx_spawnWarps mat_add_kernel\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;
vx_spawnWarps(numWarps, numThreads, mat_add_kernel, &arguments);
vx_print_str("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++)
{
unsigned index = (i * arguments.numColums) + j;
vx_print_hex(z[index]);
vx_print_str(" ");
}
vx_print_str("\n");
}
return 0;
}

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

@@ -0,0 +1,42 @@
#include "io/io.h" // Printing functions
#include "intrinsics/instrinsics.h" // vx_threadID and vx_WarpID
struct args
{
void * data;
};
void function(void * arg)
{
struct args * real_arg = (struct args *) arg;
unsigned tid = vx_threadID();
unsigned wid = vx_WarpID();
__if(something) // Control divergent if
{
}
__else
{
}
__endif
}
int main()
{
void * data = vx_loadfile("filename.txt"); // The raw char data will be returned by vx_loadfile
struct args arg;
arg.data = data;
vx_spawnWarps(numWarps, numThreads, function, &data);
}