fixed vreg clearning

This commit is contained in:
fares
2019-11-22 20:36:11 -05:00
parent 10505feaf5
commit bff1b207c2
8 changed files with 63 additions and 92592 deletions

View File

@@ -35,3 +35,8 @@ HEX: ELF
ELF:
$(COMP) $(CC_FLAGS) $(VX_STR) $(VX_VEC) $(VX_FIO) $(NEWLIB) $(VX_INT) $(VX_IO) $(VX_API) $(VX_TEST) $(VX_MAIN).c $(LIBS) -Iinclude -o $(VX_MAIN).elf
run:
../../simX/obj_dir/Vcache_simX -E -a rv32i --core vx_vector_main.hex -s -b 1> emulator.debug

View File

@@ -7,7 +7,7 @@
extern "C" {
#endif
void vx_vec_test(int *);
void vx_vec_test(int n, int* a, int* b, int* c); //vvaddint32
#ifdef __cplusplus

View File

@@ -1,30 +1,23 @@
.type vx_vec_test, @function
.global vx_vec_test
vx_vec_test:
li a1, 7
sw a1, 0(a0)
ret
# slli a0, a0, 2
# add a0, a0, a3
# vmv.v.x vv0, a2
# # vsplat4 vv0, a2
# stripmine_loop:
# vlb4 vv1, (a1)
# vcmpez4 vp0, vv1
# !vp0 vlw4 vv1, (a3)
# !vp0 vlw4 vv2, (a4)
# !vp0 vfma4 vv1, vv0, vv1, vv2
# !vp0 vsw4 vv1, (a4)
# addi a1, a1, 4
# addi a3, a3, 16
# addi a4, a4, 16
# bleu a3, a0, stripmine_loop
# handle edge cases
# when (n % 4) != 0 ...
# vector-vector add routine of 32-bit integers
# void vvaddint32(size_t n, const int*x, const int*y, int*z)
# { for (size_t i=0; i<n; i++) { z[i]=x[i]+y[i]; } }
#
# a0 = n, a1 = x, a2 = y, a3 = z
# Non-vector instructions are indented
vsetvli t0, a0, e32 # Set vector length based on 32-bit vectors
vlw.v v0, (a1) # Get first vector
sub a0, a0, t0 # Decrement number done
slli t0, t0, 2 # Multiply number done by 4 bytes
add a1, a1, t0 # Bump pointer
vlw.v v1, (a2) # Get second vector
add a2, a2, t0 # Bump pointer
vadd.vv v2, v0, v1 # Sum vectors
vsw.v v2, (a3) # Store result
add a3, a3, t0 # Bump pointer
bnez a0, vx_vec_test # Loop back
ret # Finished

View File

@@ -1,32 +1,29 @@
#include "../../runtime/intrinsics/vx_intrinsics.h"
#include "vx_vec.h"
int main()
{
vx_tmc(1);
// int * a = malloc(4);
// int * b = malloc(4);
// int * c = malloc(4);
vx_tmc(1);
printf("Hello\n");
int n = 64;
int *a = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
int *b = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
int *c = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
for(int i = 0; i < n; ++i)
{
a[i] = b[i] = c[i] = 1;
}
vx_vec_test(n, a, b, c);
for (int i = 0; i < n; ++i)
{
printf("a[%d]=%d, b[%d]=%d, c[%d]=%d\n", i, a[i], i, b[i], i, c[i]);
}
int * a = malloc(4);
*a = 5;
printf("Value of a: %d\n", *a);
vx_vec_test(a);
printf("Value of a: %d\n", *a);
// for (int i = 0; i < 4; i++)
// {
// if (c[i] != (a[i] + b[i]))
// {
// printf("Fail\n");
// break;
// }
// }
vx_tmc(0);
vx_tmc(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

@@ -2040,6 +2040,7 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) {
Word regNum(0);
c.vreg.clear();
for (int j = 0; j < 32; j++)
{
c.vreg.push_back(vector<Reg<char*>>());
@@ -2083,9 +2084,11 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) {
}*/
D(3, "Vector Register state after addition:");
for(int i=0; i < c.vreg.size(); i++)
for(int j=0; j< c.vreg[0].size(); j++)
for(int i=0; i < 32; i++)
{
for(int j=0; j< c.vl; j++)
{
cout << "starting iter" << endl;
if (c.vtype.vsew == 8)
{
uint8_t * ptr_val = (uint8_t *) c.vreg[i][j].val;
@@ -2099,9 +2102,16 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) {
uint32_t * ptr_val = (uint32_t *) c.vreg[i][j].val;
std::cout << "reg[" << i << "][" << j << "] = " << *ptr_val << std::endl;
}
cout << "Finished iter" << endl;
}
break;
}
cout << "Finished loop" << endl;
break;
}
cout << "hhhhhhhhhhhhhhh" << endl;
break;
}
break;
case VS:
@@ -2137,8 +2147,13 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) {
cout << "aERROR: Unsupported instruction: " << *this << "\n" << flush;
exit(1);
}
cout << "outside case" << endl;
}
std::cout << "finished instruction" << endl;
D(3, "End instruction execute.");
c.activeThreads = nextActiveThreads;