Add real vector and complex scalar product

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent 6bb1788df1
commit 8de73988b8

@ -139,6 +139,7 @@ SRSLTE_API void srslte_vec_sub_bbb(const int8_t* x, const int8_t* y, int8_t* z,
/* scalar product */ /* scalar product */
SRSLTE_API void srslte_vec_sc_prod_cfc(const cf_t* x, const float h, cf_t* z, const uint32_t len); SRSLTE_API void srslte_vec_sc_prod_cfc(const cf_t* x, const float h, cf_t* z, const uint32_t len);
SRSLTE_API void srslte_vec_sc_prod_fcc(const float* x, const cf_t h, cf_t* z, const uint32_t len);
SRSLTE_API void srslte_vec_sc_prod_ccc(const cf_t* x, const cf_t h, cf_t* z, const uint32_t len); SRSLTE_API void srslte_vec_sc_prod_ccc(const cf_t* x, const cf_t h, cf_t* z, const uint32_t len);
SRSLTE_API void srslte_vec_sc_prod_fff(const float* x, const float h, float* z, const uint32_t len); SRSLTE_API void srslte_vec_sc_prod_fff(const float* x, const float h, float* z, const uint32_t len);

@ -42,6 +42,8 @@ SRSLTE_API void srslte_vec_sub_fff_simd(const float* x, const float* y, float* z
/* SIMD Vector Scalar Product */ /* SIMD Vector Scalar Product */
SRSLTE_API void srslte_vec_sc_prod_cfc_simd(const cf_t* x, const float h, cf_t* y, const int len); SRSLTE_API void srslte_vec_sc_prod_cfc_simd(const cf_t* x, const float h, cf_t* y, const int len);
SRSLTE_API void srslte_vec_sc_prod_fcc_simd(const float* x, const cf_t h, cf_t* y, const int len);
SRSLTE_API void srslte_vec_sc_prod_fff_simd(const float* x, const float h, float* z, const int len); SRSLTE_API void srslte_vec_sc_prod_fff_simd(const float* x, const float h, float* z, const int len);
SRSLTE_API void srslte_vec_sc_prod_ccc_simd(const cf_t* x, const cf_t h, cf_t* z, const int len); SRSLTE_API void srslte_vec_sc_prod_ccc_simd(const cf_t* x, const cf_t h, cf_t* z, const int len);

@ -546,6 +546,20 @@ TEST(srslte_vec_sc_prod_cfc, MALLOC(cf_t, x); MALLOC(cf_t, z); cf_t gold; float
free(x); free(x);
free(z);) free(z);)
TEST(srslte_vec_sc_prod_fcc, MALLOC(float, x); MALLOC(cf_t, z); cf_t gold; float h = RANDOM_CF();
for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); }
TEST_CALL(srslte_vec_sc_prod_fcc(x, h, z, block_size))
for (int i = 0; i < block_size; i++) {
gold = x[i] * h;
mse += cabsf(gold - z[i]);
}
free(x);
free(z);)
TEST( TEST(
srslte_vec_div_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); MALLOC(cf_t, z); srslte_vec_div_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); MALLOC(cf_t, z);
@ -881,6 +895,10 @@ int main(int argc, char** argv)
test_srslte_vec_sc_prod_cfc(func_names[func_count], &timmings[func_count][size_count], block_size); test_srslte_vec_sc_prod_cfc(func_names[func_count], &timmings[func_count][size_count], block_size);
func_count++; func_count++;
passed[func_count][size_count] =
test_srslte_vec_sc_prod_fcc(func_names[func_count], &timmings[func_count][size_count], block_size);
func_count++;
passed[func_count][size_count] = passed[func_count][size_count] =
test_srslte_vec_div_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); test_srslte_vec_div_ccc(func_names[func_count], &timmings[func_count][size_count], block_size);
func_count++; func_count++;

@ -87,6 +87,11 @@ void srslte_vec_sc_prod_cfc(const cf_t* x, const float h, cf_t* z, const uint32_
srslte_vec_sc_prod_cfc_simd(x, h, z, len); srslte_vec_sc_prod_cfc_simd(x, h, z, len);
} }
void srslte_vec_sc_prod_fcc(const float* x, const cf_t h, cf_t* z, const uint32_t len)
{
srslte_vec_sc_prod_fcc_simd(x, h, z, len);
}
// Chest UL // Chest UL
void srslte_vec_sc_prod_ccc(const cf_t* x, const cf_t h, cf_t* z, const uint32_t len) void srslte_vec_sc_prod_ccc(const cf_t* x, const cf_t h, cf_t* z, const uint32_t len)
{ {

@ -1331,6 +1331,29 @@ void srslte_vec_sc_prod_cfc_simd(const cf_t* x, const float h, cf_t* z, const in
} }
} }
void srslte_vec_sc_prod_fcc_simd(const float* x, const cf_t h, cf_t* z, const int len)
{
int i = 0;
#if SRSLTE_SIMD_F_SIZE
const simd_cf_t tap = srslte_simd_cf_set1(h);
if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(z)) {
for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) {
srslte_simd_cfi_store(&z[i], srslte_simd_cf_mul(tap, srslte_simd_f_load(&x[i])));
}
} else {
for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) {
srslte_simd_cfi_storeu(&z[i], srslte_simd_cf_mul(tap, srslte_simd_f_loadu(&x[i])));
}
}
#endif
for (; i < len; i++) {
z[i] = x[i] * h;
}
}
uint32_t srslte_vec_max_fi_simd(const float* x, const int len) uint32_t srslte_vec_max_fi_simd(const float* x, const int len)
{ {
int i = 0; int i = 0;

Loading…
Cancel
Save