Removed test macros from mat.h

This commit is contained in:
Xavier Arteaga 2017-09-25 13:08:38 +02:00
parent 2b775462f7
commit 8078238cb5
3 changed files with 31 additions and 10 deletions

View File

@ -27,14 +27,8 @@
#ifndef SRSLTE_MAT_H
#define SRSLTE_MAT_H
#include "srslte/phy/utils/simd.h"
#include "srslte/config.h"
/*
* Generic Macros
*/
#define RANDOM_CF() (((float)rand())/((float)RAND_MAX) + _Complex_I*((float)rand())/((float)RAND_MAX))
#include "srslte/phy/utils/simd.h"
/* Generic implementation for complex reciprocal */
SRSLTE_API cf_t srslte_mat_cf_recip_gen(cf_t a);

View File

@ -27,6 +27,7 @@
#include <complex.h>
#include <math.h>
#include <srslte/config.h>
#include "srslte/phy/utils/mat.h"

View File

@ -33,12 +33,18 @@
#include <sys/time.h>
#include "srslte/phy/utils/mat.h"
#include "srslte/phy/utils/simd.h"
#include "srslte/phy/utils/vector.h"
bool zf_solver = false;
bool mmse_solver = false;
bool verbose = false;
#define RANDOM_F() ((float)rand())/((float)RAND_MAX)
#define RANDOM_S() ((int16_t)(rand() && 0x800F))
#define RANDOM_CF() (RANDOM_F() + _Complex_I*RANDOM_F())
double elapsed_us(struct timeval *ts_start, struct timeval *ts_end) {
if (ts_end->tv_usec > ts_start->tv_usec) {
return ((double) ts_end->tv_sec - (double) ts_start->tv_sec) * 1000000 +
@ -49,16 +55,16 @@ double elapsed_us(struct timeval *ts_start, struct timeval *ts_end) {
}
}
#define NOF_REPETITIONS 1000
#define BLOCK_SIZE 1000
#define RUN_TEST(FUNCTION) /*TYPE NAME (void)*/ { \
int i;\
struct timeval start, end;\
gettimeofday(&start, NULL); \
bool ret = true; \
for (i = 0; i < NOF_REPETITIONS; i++) {ret &= FUNCTION ();}\
for (i = 0; i < BLOCK_SIZE; i++) {ret &= FUNCTION ();}\
gettimeofday(&end, NULL);\
if (verbose) printf("%32s: %s ... %6.2f us/call\n", #FUNCTION, (ret)?"Pass":"Fail", \
elapsed_us(&start, &end)/NOF_REPETITIONS);\
elapsed_us(&start, &end)/BLOCK_SIZE);\
passed &= ret;\
}
@ -373,6 +379,24 @@ bool test_mmse_solver_avx(void) {
#endif /* LV_HAVE_AVX */
bool test_vec_dot_prod_ccc(void) {
__attribute__((aligned(256))) cf_t a[14];
__attribute__((aligned(256))) cf_t b[14];
cf_t res = 0, gold = 0;
for (int i = 0; i < 14; i++) {
a[i] = RANDOM_CF();
b[i] = RANDOM_CF();
}
res = srslte_vec_dot_prod_ccc(a, b, 14);
for (int i=0;i<14;i++) {
gold += a[i]*b[i];
}
return (cabsf(res - gold) < 1e-3);
}
int main(int argc, char **argv) {
bool passed = true;
@ -405,6 +429,8 @@ int main(int argc, char **argv) {
#endif /* LV_HAVE_AVX */
}
RUN_TEST(test_vec_dot_prod_ccc);
printf("%s!\n", (passed) ? "Ok" : "Failed");
if (!passed) {