Vector extension test (vfdiv, vfmax, vfmin, vfmul) 1. Define additional operations (vfdiv, vfmax, vfmin, vfmul) 2. Fix typos in softrvv/include/softrvv_vfsub.h 3. Remove unnecessary header files in softrvv/include/softrvv_vmax.h and softrvv/include/softrvv_vmin.h 4. Add tests for newly added operations in tests/CMakeLists.txt - They are tested with "m springbok && ctest --verbose -R ... --gtest_color=yes" Change-Id: Ia84de66974f0e41b0373e112d19393a7d4ca5b0a
diff --git a/softrvv/include/softrvv.h b/softrvv/include/softrvv.h index bfc0f54..b4b69a2 100644 --- a/softrvv/include/softrvv.h +++ b/softrvv/include/softrvv.h
@@ -9,8 +9,12 @@ #include "softrvv_vadd.h" #include "softrvv_vand.h" #include "softrvv_vdiv.h" -#include "softrvv_vfsub.h" #include "softrvv_vfadd.h" +#include "softrvv_vfdiv.h" +#include "softrvv_vfmax.h" +#include "softrvv_vfmin.h" +#include "softrvv_vfmul.h" +#include "softrvv_vfsub.h" #include "softrvv_vmax.h" #include "softrvv_vmin.h" #include "softrvv_vmseq.h"
diff --git a/softrvv/include/softrvv_vfdiv.h b/softrvv/include/softrvv_vfdiv.h new file mode 100644 index 0000000..6759f66 --- /dev/null +++ b/softrvv/include/softrvv_vfdiv.h
@@ -0,0 +1,22 @@ +#ifndef SOFTRVV_VFDIV_H +#define SOFTRVV_VFDIV_H + +#include <stddef.h> + +namespace softrvv { + +void vfdiv_vf(float *dest, float *src1, const float *src2, int32_t avl) { + for (int32_t idx = 0; idx < avl; idx++) { + dest[idx] = src1[idx] / *src2; + } +} + +void vfdiv_vv(float *dest, float *src1, float *src2, int32_t avl) { + for (int32_t idx = 0; idx < avl; idx++) { + dest[idx] = src1[idx] / src2[idx]; + } +} + +} // namespace softrvv + +#endif // SOFTRVV_VFDIV_H
diff --git a/softrvv/include/softrvv_vfmax.h b/softrvv/include/softrvv_vfmax.h new file mode 100644 index 0000000..3231de1 --- /dev/null +++ b/softrvv/include/softrvv_vfmax.h
@@ -0,0 +1,22 @@ +#ifndef SOFTRVV_VFMAX_H +#define SOFTRVV_VFMAX_H + +#include <stddef.h> + +namespace softrvv { + +void vfmax_vf(float *dest, float *src1, const float *src2, int32_t avl) { + for (int32_t idx = 0; idx < avl; idx++) { + dest[idx] = (src1[idx] > *src2) ? src1[idx] : *src2; + } +} + +void vfmax_vv(float *dest, float *src1, float *src2, int32_t avl) { + for (int32_t idx = 0; idx < avl; idx++) { + dest[idx] = (src1[idx] > src2[idx]) ? src1[idx] : src2[idx]; + } +} + +} // namespace softrvv + +#endif // SOFTRVV_VFMAX_H
diff --git a/softrvv/include/softrvv_vfmin.h b/softrvv/include/softrvv_vfmin.h new file mode 100644 index 0000000..894544f --- /dev/null +++ b/softrvv/include/softrvv_vfmin.h
@@ -0,0 +1,22 @@ +#ifndef SOFTRVV_VFMIN_H +#define SOFTRVV_VFMIN_H + +#include <stddef.h> + +namespace softrvv { + +void vfmin_vf(float *dest, float *src1, const float *src2, int32_t avl) { + for (int32_t idx = 0; idx < avl; idx++) { + dest[idx] = (src1[idx] < *src2) ? src1[idx] : *src2; + } +} + +void vfmin_vv(float *dest, float *src1, float *src2, int32_t avl) { + for (int32_t idx = 0; idx < avl; idx++) { + dest[idx] = (src1[idx] < src2[idx]) ? src1[idx] : src2[idx]; + } +} + +} // namespace softrvv + +#endif // SOFTRVV_VFMIN_H
diff --git a/softrvv/include/softrvv_vfmul.h b/softrvv/include/softrvv_vfmul.h new file mode 100644 index 0000000..7dcb462 --- /dev/null +++ b/softrvv/include/softrvv_vfmul.h
@@ -0,0 +1,22 @@ +#ifndef SOFTRVV_VFMUL_H +#define SOFTRVV_VFMUL_H + +#include <stddef.h> + +namespace softrvv { + +void vfmul_vf(float *dest, float *src1, const float *src2, int32_t avl) { + for (int32_t idx = 0; idx < avl; idx++) { + dest[idx] = src1[idx] * *src2; + } +} + +void vfmul_vv(float *dest, float *src1, float *src2, int32_t avl) { + for (int32_t idx = 0; idx < avl; idx++) { + dest[idx] = src1[idx] * src2[idx]; + } +} + +} // namespace softrvv + +#endif // SOFTRVV_VFMUL_H
diff --git a/softrvv/include/softrvv_vfsub.h b/softrvv/include/softrvv_vfsub.h index aff1f52..d78504d 100644 --- a/softrvv/include/softrvv_vfsub.h +++ b/softrvv/include/softrvv_vfsub.h
@@ -17,7 +17,7 @@ } } -void vfrsub_vx(float *dest, float *src1, const float *src2, int32_t avl) { +void vfrsub_vf(float *dest, float *src1, const float *src2, int32_t avl) { for (int32_t idx = 0; idx < avl; idx++) { dest[idx] = *src2 - src1[idx]; }
diff --git a/softrvv/include/softrvv_vmax.h b/softrvv/include/softrvv_vmax.h index 5ad4352..3b70b9a 100644 --- a/softrvv/include/softrvv_vmax.h +++ b/softrvv/include/softrvv_vmax.h
@@ -2,7 +2,6 @@ #define SOFTRVV_VMAX_H #include <stddef.h> -#include <stdint.h> namespace softrvv {
diff --git a/softrvv/include/softrvv_vmin.h b/softrvv/include/softrvv_vmin.h index d853455..78f55e1 100644 --- a/softrvv/include/softrvv_vmin.h +++ b/softrvv/include/softrvv_vmin.h
@@ -2,7 +2,6 @@ #define SOFTRVV_VMIN_H #include <stddef.h> -#include <stdint.h> namespace softrvv {
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 05814ca..abb58a6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt
@@ -10,6 +10,60 @@ vec_cc_generated_test( NAME + vfsub + TEMPLATE + opivv_opivf_test.tpl.cpp + LINKOPTS + -Xlinker --defsym=__itcm_length__=128K +) + +vec_cc_generated_test( + NAME + vfrsub + TEMPLATE + opivf_test.tpl.cpp + LINKOPTS + -Xlinker --defsym=__itcm_length__=128K +) + +vec_cc_generated_test( + NAME + vfdiv + TEMPLATE + opivv_opivf_test.tpl.cpp + LINKOPTS + -Xlinker --defsym=__itcm_length__=128K +) + +vec_cc_generated_test( + NAME + vfmax + TEMPLATE + opivv_opivf_test.tpl.cpp + LINKOPTS + -Xlinker --defsym=__itcm_length__=128K +) + +vec_cc_generated_test( + NAME + vfmin + TEMPLATE + opivv_opivf_test.tpl.cpp + LINKOPTS + -Xlinker --defsym=__itcm_length__=128K +) + +vec_cc_generated_test( + NAME + vfmul + TEMPLATE + opivv_opivf_test.tpl.cpp + LINKOPTS + -Xlinker --defsym=__itcm_length__=128K +) + +vec_cc_generated_test( + NAME vsub TEMPLATE opivv_opivx_test.tpl.cpp