diff --git a/lib/src/phy/fec/ldpc/test/CMakeLists.txt b/lib/src/phy/fec/ldpc/test/CMakeLists.txt index 18f6f709c..630ff51e4 100644 --- a/lib/src/phy/fec/ldpc/test/CMakeLists.txt +++ b/lib/src/phy/fec/ldpc/test/CMakeLists.txt @@ -44,7 +44,7 @@ set_target_properties(ldpc_enc_test ldpc_dec_test ldpc_dec_s_test ldpc_dec_c_tes RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/tests/ldpc" ) -if(NOT DISABLE_SIMD) +if(HAVE_AVX2) add_executable(ldpc_enc_avx2_test ldpc_enc_avx2_test.c) target_link_libraries(ldpc_enc_avx2_test srslte_phy) @@ -55,7 +55,7 @@ if(NOT DISABLE_SIMD) PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/tests/ldpc" ) -endif(NOT DISABLE_SIMD) +endif(HAVE_AVX2) add_custom_command( OUTPUT ${PROJECT_SOURCE_DIR}/tests/ldpc/examplesBG1.dat diff --git a/lib/src/phy/fec/ldpc/test/ldpc_chain_test.c b/lib/src/phy/fec/ldpc/test/ldpc_chain_test.c index c746a2607..3d1746dbf 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_chain_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_chain_test.c @@ -246,19 +246,22 @@ int main(int argc, char** argv) int i_bit = 0; int i_batch = 0; struct timeval t[3]; - double elapsed_time_enc = 0; - double elapsed_time_dec_f = 0; - double elapsed_time_dec_s = 0; - double elapsed_time_dec_c = 0; - double elapsed_time_dec_c_flood = 0; - double elapsed_time_dec_avx = 0; - double elapsed_time_dec_avx_flood = 0; - int n_error_words_f = 0; - int n_error_words_s = 0; - int n_error_words_c = 0; - int n_error_words_c_flood = 0; - int n_error_words_avx = 0; - int n_error_words_avx_flood = 0; + double elapsed_time_enc = 0; + double elapsed_time_dec_f = 0; + double elapsed_time_dec_s = 0; + double elapsed_time_dec_c = 0; + double elapsed_time_dec_c_flood = 0; + int n_error_words_f = 0; + int n_error_words_s = 0; + int n_error_words_c = 0; + int n_error_words_c_flood = 0; + +#ifdef LV_HAVE_AVX + double elapsed_time_dec_avx = 0; + double elapsed_time_dec_avx_flood = 0; + int n_error_words_avx = 0; + int n_error_words_avx_flood = 0; +#endif // LV_HAVE_AVX2 float noise_std_dev = srslte_convert_dB_to_amplitude(-snr); diff --git a/lib/src/phy/fec/ldpc/test/ldpc_rm_chain_test.c b/lib/src/phy/fec/ldpc/test/ldpc_rm_chain_test.c index c79c9b88d..7aa65ec04 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_rm_chain_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_rm_chain_test.c @@ -309,19 +309,22 @@ int main(int argc, char** argv) int i_bit = 0; int i_batch = 0; struct timeval t[3]; - double elapsed_time_enc = 0; - double elapsed_time_dec_f = 0; - double elapsed_time_dec_s = 0; - double elapsed_time_dec_c = 0; - double elapsed_time_dec_c_flood = 0; - double elapsed_time_dec_avx = 0; - double elapsed_time_dec_avx_flood = 0; - int n_error_words_f = 0; - int n_error_words_s = 0; - int n_error_words_c = 0; - int n_error_words_c_flood = 0; - int n_error_words_avx = 0; - int n_error_words_avx_flood = 0; + double elapsed_time_enc = 0; + double elapsed_time_dec_f = 0; + double elapsed_time_dec_s = 0; + double elapsed_time_dec_c = 0; + double elapsed_time_dec_c_flood = 0; + int n_error_words_f = 0; + int n_error_words_s = 0; + int n_error_words_c = 0; + int n_error_words_c_flood = 0; + +#ifdef LV_HAVE_AVX + double elapsed_time_dec_avx = 0; + double elapsed_time_dec_avx_flood = 0; + int n_error_words_avx = 0; + int n_error_words_avx_flood = 0; +#endif // LV_HAVE_AVX2 float noise_std_dev = srslte_convert_dB_to_amplitude(-snr); diff --git a/lib/src/phy/fec/polar/test/polar_chain_test.c b/lib/src/phy/fec/polar/test/polar_chain_test.c index 55b028a4a..5b5a2f990 100644 --- a/lib/src/phy/fec/polar/test/polar_chain_test.c +++ b/lib/src/phy/fec/polar/test/polar_chain_test.c @@ -181,15 +181,17 @@ int main(int argc, char** argv) double var[SNR_POINTS + 1]; double snr_db_vec[SNR_POINTS + 1]; - int i = 0; int j = 0; int snr_points = 0; - int errors_symb = 0; - int errors_symb_s = 0; - int errors_symb_c = 0; + int errors_symb = 0; + int errors_symb_s = 0; + int errors_symb_c = 0; + +#ifdef LV_HAVE_AVX int errors_symb_c_avx2 = 0; +#endif // LV_HAVE_AVX int n_error_words[SNR_POINTS + 1]; int n_error_words_s[SNR_POINTS + 1]; @@ -208,11 +210,13 @@ int main(int argc, char** argv) double elapsed_time_enc_avx2[SNR_POINTS + 1]; // 16-bit quantizer - int16_t inf16 = (1U << 15U) - 1; - int8_t inf8 = (1U << 7U) - 1; - float gain_s = NAN; - float gain_c = NAN; - float gain_c_avx2 = NAN; + int16_t inf16 = (1U << 15U) - 1; + int8_t inf8 = (1U << 7U) - 1; + float gain_s = NAN; + float gain_c = NAN; +#ifdef LV_HAVE_AVX + float gain_c_avx2 = NAN; +#endif // LV_HAVE_AVX2 srslte_polar_sets_t sets; srslte_subchn_alloc_t subch; @@ -380,7 +384,7 @@ int main(int argc, char** argv) } #else - for (i = 0; i < BATCH_SIZE; i++) { + for (uint32_t i = 0; i < BATCH_SIZE; i++) { for (j = 0; j < message_size; j++) { data_tx[i * message_size + j] = srslte_random_uniform_int_dist(random_gen, 0, 1); } @@ -388,7 +392,7 @@ int main(int argc, char** argv) #endif // subchannel_allocation block - for (i = 0; i < BATCH_SIZE; i++) { + for (uint32_t i = 0; i < BATCH_SIZE; i++) { srslte_subchannel_allocation(&subch, data_tx + i * message_size, input_enc + i * code_size); } @@ -417,7 +421,7 @@ int main(int argc, char** argv) // check encoders have the same output. // check errors with respect the output of the pipeline encoder - for (i = 0; i < BATCH_SIZE; i++) { + for (uint32_t i = 0; i < BATCH_SIZE; i++) { if (srslte_bit_diff(output_enc + i * code_size, output_enc_avx2 + i * code_size, code_size) != 0) { printf("ERROR: Wrong avx2 encoder output. SNR= %f, Batch: %d\n", snr_db_vec[i_snr], i); exit(-1); @@ -455,7 +459,7 @@ int main(int argc, char** argv) } // check errors - float decpder - for (i = 0; i < BATCH_SIZE; i++) { + for (uint32_t i = 0; i < BATCH_SIZE; i++) { errors_symb = srslte_bit_diff(data_tx + i * message_size, data_rx + i * message_size, message_size); if (errors_symb != 0) { @@ -488,7 +492,7 @@ int main(int argc, char** argv) } // check errors 16-bit decoder - for (i = 0; i < BATCH_SIZE; i++) { + for (uint32_t i = 0; i < BATCH_SIZE; i++) { errors_symb_s = srslte_bit_diff(data_tx + i * message_size, data_rx_s + i * message_size, message_size); if (errors_symb_s != 0) { @@ -519,7 +523,7 @@ int main(int argc, char** argv) } // check errors 8-bits decoder - for (i = 0; i < BATCH_SIZE; i++) { + for (uint32_t i = 0; i < BATCH_SIZE; i++) { errors_symb_c = srslte_bit_diff(data_tx + i * message_size, data_rx_c + i * message_size, message_size); @@ -552,7 +556,7 @@ int main(int argc, char** argv) } // check errors 8-bits decoder - for (i = 0; i < BATCH_SIZE; i++) { + for (uint32_t i = 0; i < BATCH_SIZE; i++) { errors_symb_c_avx2 = srslte_bit_diff(data_tx + i * message_size, data_rx_c_avx2 + i * message_size, message_size); @@ -780,7 +784,7 @@ int main(int argc, char** argv) ); } else { - for (int i_snr = 0; i_snr < snr_points; i_snr++) { + for (i_snr = 0; i_snr < snr_points; i_snr++) { if (n_error_words_s[i_snr] > 10 * n_error_words[i_snr]) { perror("16-bit performance at SNR = %d too low!"); exit(-1);