fixed vreg clearning
This commit is contained in:
@@ -35,3 +35,8 @@ HEX: ELF
|
|||||||
|
|
||||||
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
|
$(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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void vx_vec_test(int *);
|
void vx_vec_test(int n, int* a, int* b, int* c); //vvaddint32
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1,30 +1,23 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
.type vx_vec_test, @function
|
.type vx_vec_test, @function
|
||||||
.global vx_vec_test
|
.global vx_vec_test
|
||||||
vx_vec_test:
|
vx_vec_test:
|
||||||
li a1, 7
|
# vector-vector add routine of 32-bit integers
|
||||||
sw a1, 0(a0)
|
# void vvaddint32(size_t n, const int*x, const int*y, int*z)
|
||||||
ret
|
# { 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
|
||||||
# slli a0, a0, 2
|
vlw.v v0, (a1) # Get first vector
|
||||||
# add a0, a0, a3
|
sub a0, a0, t0 # Decrement number done
|
||||||
# vmv.v.x vv0, a2
|
slli t0, t0, 2 # Multiply number done by 4 bytes
|
||||||
# # vsplat4 vv0, a2
|
add a1, a1, t0 # Bump pointer
|
||||||
# stripmine_loop:
|
vlw.v v1, (a2) # Get second vector
|
||||||
# vlb4 vv1, (a1)
|
add a2, a2, t0 # Bump pointer
|
||||||
# vcmpez4 vp0, vv1
|
vadd.vv v2, v0, v1 # Sum vectors
|
||||||
# !vp0 vlw4 vv1, (a3)
|
vsw.v v2, (a3) # Store result
|
||||||
# !vp0 vlw4 vv2, (a4)
|
add a3, a3, t0 # Bump pointer
|
||||||
# !vp0 vfma4 vv1, vv0, vv1, vv2
|
bnez a0, vx_vec_test # Loop back
|
||||||
# !vp0 vsw4 vv1, (a4)
|
ret # Finished
|
||||||
# addi a1, a1, 4
|
|
||||||
# addi a3, a3, 16
|
|
||||||
# addi a4, a4, 16
|
|
||||||
# bleu a3, a0, stripmine_loop
|
|
||||||
# handle edge cases
|
|
||||||
# when (n % 4) != 0 ...
|
|
||||||
@@ -1,32 +1,29 @@
|
|||||||
|
|
||||||
#include "../../runtime/intrinsics/vx_intrinsics.h"
|
#include "../../runtime/intrinsics/vx_intrinsics.h"
|
||||||
#include "vx_vec.h"
|
#include "vx_vec.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
vx_tmc(1);
|
vx_tmc(1);
|
||||||
// int * a = malloc(4);
|
|
||||||
// int * b = malloc(4);
|
|
||||||
// int * c = malloc(4);
|
|
||||||
|
|
||||||
|
printf("Hello\n");
|
||||||
|
|
||||||
int * a = malloc(4);
|
int n = 64;
|
||||||
*a = 5;
|
int *a = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
|
||||||
printf("Value of a: %d\n", *a);
|
int *b = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
|
||||||
|
int *c = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
|
||||||
|
|
||||||
vx_vec_test(a);
|
for(int i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
a[i] = b[i] = c[i] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
printf("Value of a: %d\n", *a);
|
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]);
|
||||||
|
}
|
||||||
|
|
||||||
// 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
@@ -2040,6 +2040,7 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) {
|
|||||||
|
|
||||||
Word regNum(0);
|
Word regNum(0);
|
||||||
|
|
||||||
|
c.vreg.clear();
|
||||||
for (int j = 0; j < 32; j++)
|
for (int j = 0; j < 32; j++)
|
||||||
{
|
{
|
||||||
c.vreg.push_back(vector<Reg<char*>>());
|
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:");
|
D(3, "Vector Register state after addition:");
|
||||||
for(int i=0; i < c.vreg.size(); i++)
|
for(int i=0; i < 32; i++)
|
||||||
for(int j=0; j< c.vreg[0].size(); j++)
|
|
||||||
{
|
{
|
||||||
|
for(int j=0; j< c.vl; j++)
|
||||||
|
{
|
||||||
|
cout << "starting iter" << endl;
|
||||||
if (c.vtype.vsew == 8)
|
if (c.vtype.vsew == 8)
|
||||||
{
|
{
|
||||||
uint8_t * ptr_val = (uint8_t *) c.vreg[i][j].val;
|
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;
|
uint32_t * ptr_val = (uint32_t *) c.vreg[i][j].val;
|
||||||
std::cout << "reg[" << i << "][" << j << "] = " << *ptr_val << std::endl;
|
std::cout << "reg[" << i << "][" << j << "] = " << *ptr_val << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cout << "Finished iter" << endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "Finished loop" << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
cout << "hhhhhhhhhhhhhhh" << endl;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VS:
|
case VS:
|
||||||
@@ -2137,8 +2147,13 @@ void Instruction::executeOn(Warp &c, trace_inst_t * trace_inst) {
|
|||||||
cout << "aERROR: Unsupported instruction: " << *this << "\n" << flush;
|
cout << "aERROR: Unsupported instruction: " << *this << "\n" << flush;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cout << "outside case" << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "finished instruction" << endl;
|
||||||
|
|
||||||
D(3, "End instruction execute.");
|
D(3, "End instruction execute.");
|
||||||
|
|
||||||
c.activeThreads = nextActiveThreads;
|
c.activeThreads = nextActiveThreads;
|
||||||
|
|||||||
Reference in New Issue
Block a user