saxpy test: rs1 error
This commit is contained in:
@@ -34,8 +34,8 @@ HEX: ELF
|
|||||||
$(CPY) -O ihex $(VX_MAIN).elf $(VX_MAIN).hex
|
$(CPY) -O ihex $(VX_MAIN).elf $(VX_MAIN).hex
|
||||||
|
|
||||||
ELF:
|
ELF:
|
||||||
$(COMP) $(CC_FLAGS) $(VX_STR) $(VX_VEC1) $(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_VEC1) $(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_VEC2) $(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_VEC2) $(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_VEC3) $(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_VEC3) $(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_VEC4) $(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_VEC4) $(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_VEC5) $(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_VEC5) $(VX_FIO) $(NEWLIB) $(VX_INT) $(VX_IO) $(VX_API) $(VX_TEST) $(VX_MAIN).c $(LIBS) -Iinclude -o $(VX_MAIN).elf~
|
||||||
|
|||||||
@@ -6,14 +6,17 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
vx_tmc(1);
|
vx_tmc(1);
|
||||||
|
|
||||||
int n = 5;
|
int n = 5;
|
||||||
|
int scalar = 10;
|
||||||
|
|
||||||
int *a = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
|
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 *b = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
|
||||||
int *c = (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] = 1; b[i] = 2; c[i] = 5; }
|
for (int i = 0; i < n; ++i) { a[i] = 1; b[i] = 2; c[i] = 5; }
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
/* vvaddint32
|
/* vvaddint32
|
||||||
* # vector-vector add routine of 32-bit integers
|
* # vector-vector add routine of 32-bit integers
|
||||||
@@ -43,7 +46,6 @@ int main()
|
|||||||
/* # vector-scalar add
|
/* # vector-scalar add
|
||||||
# for (i=0; i<N; i++) { C[i] = A[i] + B; } // 32-bit ints */
|
# for (i=0; i<N; i++) { C[i] = A[i] + B; } // 32-bit ints */
|
||||||
for (int i = 0; i < n; ++i) { a[i] = 1; b[i] = 1;}
|
for (int i = 0; i < n; ++i) { a[i] = 1; b[i] = 1;}
|
||||||
int scalar = 10;
|
|
||||||
printf("vsadd...scalar:%d\na[%d]: ", scalar, n);
|
printf("vsadd...scalar:%d\na[%d]: ", scalar, n);
|
||||||
for(int i = 0; i < n; ++i) printf("%d \n", a[i]);
|
for(int i = 0; i < n; ++i) printf("%d \n", a[i]);
|
||||||
printf("\nb: %d", scalar);
|
printf("\nb: %d", scalar);
|
||||||
@@ -78,10 +80,12 @@ int main()
|
|||||||
if(a[i] != b[i])
|
if(a[i] != b[i])
|
||||||
{
|
{
|
||||||
printf("\n<memcpy> failed at <index: %d>! \n", i);
|
printf("\n<memcpy> failed at <index: %d>! \n", i);
|
||||||
return;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\nPASSED.......................... <memcpy> \n");
|
printf("\nPASSED.......................... <memcpy> \n");
|
||||||
|
#endif
|
||||||
|
#if 1
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
/* # void saxpy(size_t n, const float a, const float *x, float *y)
|
/* # void saxpy(size_t n, const float a, const float *x, float *y)
|
||||||
# ==> convert to int!!
|
# ==> convert to int!!
|
||||||
@@ -99,16 +103,22 @@ int main()
|
|||||||
|
|
||||||
vx_vec_saxpy(n, scalar, a, b);
|
vx_vec_saxpy(n, scalar, a, b);
|
||||||
|
|
||||||
|
printf("saxpy\na[%d]: ", n);
|
||||||
|
for(int i = 0; i < n; ++i) printf("%d \n", a[i]);
|
||||||
|
printf("\nb[%d]: ", n);
|
||||||
|
for(int i = 0; i < n; ++i) printf("%d \n", b[i]);
|
||||||
|
|
||||||
for(int i = 0; i < n; ++i)
|
for(int i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
if(b[i] != ((a[i] * scalar) + c[i]))
|
if(b[i] != ((a[i] * scalar) + c[i]))
|
||||||
{
|
{
|
||||||
printf("\n<saxpy> failed at <index: %d>! \n", i);
|
printf("\n<saxpy> failed at <index: %d>! \n", i);
|
||||||
return;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\nPASSED.......................... <saxpy> \n");
|
printf("\nPASSED.......................... <saxpy> \n");
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
/* # void sgemm_nn(size_t n, size_t m, size_t k, const float*a, // m * k matrix
|
/* # void sgemm_nn(size_t n, size_t m, size_t k, const float*a, // m * k matrix
|
||||||
# size_t lda, const float*b, // k * n matrix
|
# size_t lda, const float*b, // k * n matrix
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void vx_vec_vvaddint32(int n, int* a, int* b, int *c);
|
//void vx_vec_vvaddint32(int n, int* a, int* b, int *c);
|
||||||
//void vx_vec_vsadd(int n, int* a, int scalar);
|
//void vx_vec_vsadd(int n, int* a, int scalar);
|
||||||
//void vx_vec_memcpy(int* a, int* b, int n);
|
//void vx_vec_memcpy(int* a, int* b, int n);
|
||||||
//void vx_vec_saxpy(int n, int scalar, int* a, int* b);
|
void vx_vec_saxpy(int n, int scalar, int* a, int* b);
|
||||||
//void vx_vec_sgemm_nn(int n, int m, int k, int* a1, int lda, int* b1, int ldb, int* c1, int ldc);
|
//void vx_vec_sgemm_nn(int n, int m, int k, int* a1, int lda, int* b1, int ldb, int* c1, int ldc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -13,16 +13,31 @@
|
|||||||
# fa0 a
|
# fa0 a
|
||||||
# a1 x
|
# a1 x
|
||||||
# a2 y
|
# a2 y
|
||||||
|
#vx_vec_saxpy:
|
||||||
|
# vsetvli a4, a0, e32, m8
|
||||||
|
#saxpy:
|
||||||
|
# vlw.v v0, (a1)
|
||||||
|
# sub a0, a0, a4
|
||||||
|
# slli a4, a4, 2
|
||||||
|
# add a1, a1, a4
|
||||||
|
# vlw.v v8, (a2)
|
||||||
|
# vfmacc.vf v8, fa0, v0
|
||||||
|
# vsw.v v8, (a2)
|
||||||
|
# add a2, a2, a4
|
||||||
|
# bnez a0, saxpy
|
||||||
|
# ret
|
||||||
|
|
||||||
|
# a0 n, rs1 a, a2 x, a3 y
|
||||||
vx_vec_saxpy:
|
vx_vec_saxpy:
|
||||||
vsetvli a4, a0, e32, m8
|
vsetvli a4, a0, e32, m8
|
||||||
saxpy:
|
saxpy:
|
||||||
vlw.v v0, (a1)
|
vlw.v v0, (a2)
|
||||||
sub a0, a0, a4
|
sub a0, a0, a4
|
||||||
slli a4, a4, 2
|
slli a4, a4, 2
|
||||||
add a1, a1, a4
|
|
||||||
vlw.v v8, (a2)
|
|
||||||
vfmacc.vf v8, fa0, v0
|
|
||||||
vsw.v v8, (a2)
|
|
||||||
add a2, a2, a4
|
add a2, a2, a4
|
||||||
|
vlw.v v1, (a3)
|
||||||
|
vmacc.vx v1, rs1, v0
|
||||||
|
vsw.v v1, (a3)
|
||||||
|
add a3, a3, a4
|
||||||
bnez a0, saxpy
|
bnez a0, saxpy
|
||||||
ret
|
ret
|
||||||
Reference in New Issue
Block a user