Add Intrinsics usage by SIMDE

This commit is contained in:
Bruno Mongazon-Cazavet
2022-09-28 18:21:19 +02:00
committed by Robert Schmidt
parent a1de5e3d11
commit fe1dc24e28
114 changed files with 7900 additions and 11031 deletions
+12 -49
View File
@@ -54,17 +54,7 @@
#include <sys/resource.h>
#ifdef __SSE4_1__
#include <smmintrin.h>
#endif
#ifdef __AVX2__
#include <immintrin.h>
#endif
#ifdef __arm__
#include <arm_neon.h>
#endif
#include "openair1/PHY/sse_intrin.h"
/** @addtogroup _USRP_PHY_RF_INTERFACE_
* @{
@@ -421,14 +411,9 @@ static int trx_usrp_write(openair0_device *device,
if(usrp_tx_thread == 0){
#if defined(__x86_64) || defined(__i386__)
#ifdef __AVX2__
nsamps2 = (nsamps+7)>>3;
__m256i buff_tx[cc<2?2:cc][nsamps2];
#else
nsamps2 = (nsamps+3)>>2;
__m128i buff_tx[cc<2?2:cc][nsamps2];
#endif
#elif defined(__arm__)
#elif defined(__arm__) || defined(__aarch64__)
nsamps2 = (nsamps+3)>>2;
int16x8_t buff_tx[cc<2?2:cc][nsamps2];
#else
@@ -439,12 +424,8 @@ static int trx_usrp_write(openair0_device *device,
for (int i=0; i<cc; i++) {
for (int j=0; j<nsamps2; j++) {
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AVX2__
buff_tx[i][j] = _mm256_slli_epi16(((__m256i *)buff[i])[j],4);
#else
buff_tx[i][j] = _mm_slli_epi16(((__m128i *)buff[i])[j],4);
#endif
#elif defined(__arm__)
buff_tx[i][j] = simde_mm256_slli_epi16(((__m256i *)buff[i])[j],4);
#elif defined(__arm__) || defined(__aarch64__)
buff_tx[i][j] = vshlq_n_s16(((int16x8_t *)buff[i])[j],4);
#endif
}
@@ -561,14 +542,9 @@ void *trx_usrp_write_thread(void * arg){
}*/
#if defined(__x86_64) || defined(__i386__)
#ifdef __AVX2__
nsamps2 = (nsamps+7)>>3;
__m256i buff_tx[cc<2?2:cc][nsamps2];
#else
nsamps2 = (nsamps+3)>>2;
__m128i buff_tx[cc<2?2:cc][nsamps2];
#endif
#elif defined(__arm__)
#elif defined(__arm__) || defined(__aarch64__)
nsamps2 = (nsamps+3)>>2;
int16x8_t buff_tx[cc<2?2:cc][nsamps2];
#else
@@ -579,12 +555,8 @@ void *trx_usrp_write_thread(void * arg){
for (int i=0; i<cc; i++) {
for (int j=0; j<nsamps2; j++) {
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AVX2__
buff_tx[i][j] = _mm256_slli_epi16(((__m256i *)buff[i])[j],4);
#else
buff_tx[i][j] = _mm_slli_epi16(((__m128i *)buff[i])[j],4);
#endif
#elif defined(__arm__)
buff_tx[i][j] = simde_mm256_slli_epi16(((__m256i *)buff[i])[j],4);
#elif defined(__arm__) || defined(__aarch64__)
buff_tx[i][j] = vshlq_n_s16(((int16x8_t *)buff[i])[j],4);
#endif
}
@@ -675,14 +647,9 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
int samples_received=0;
int nsamps2; // aligned to upper 32 or 16 byte boundary
#if defined(__x86_64) || defined(__i386__)
#ifdef __AVX2__
nsamps2 = (nsamps+7)>>3;
__m256i buff_tmp[cc<2 ? 2 : cc][nsamps2];
#else
nsamps2 = (nsamps+3)>>2;
__m128i buff_tmp[cc<2 ? 2 : cc][nsamps2];
#endif
#elif defined(__arm__)
#elif defined(__arm__) || defined(__aarch64__)
nsamps2 = (nsamps+3)>>2;
int16x8_t buff_tmp[cc<2 ? 2 : cc][nsamps2];
#endif
@@ -729,20 +696,14 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
for (int i=0; i<cc; i++) {
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AVX2__
if ((((uintptr_t) buff[i])&0x1F)==0) {
for (int j=0; j<nsamps2; j++)
((__m256i *)buff[i])[j] = _mm256_srai_epi16(buff_tmp[i][j],rxshift);
((__m256i *)buff[i])[j] = simde_mm256_srai_epi16(buff_tmp[i][j],rxshift);
} else {
for (int j=0; j<(nsamps2<<1); j++)
((__m128i *)buff[i])[j] = _mm_srai_epi16(((__m128i *)buff_tmp[i])[j],rxshift);
}
#else
for (int j=0; j<nsamps2; j++)
((__m128i *)buff[i])[j] = _mm_srai_epi16(buff_tmp[i][j],rxshift);
#endif
#elif defined(__arm__)
#elif defined(__arm__) || defined(__aarch64__)
for (int j=0; j<nsamps2; j++)
((int16x8_t *)buff[i])[j] = vshrq_n_s16(buff_tmp[i][j],rxshift);
#endif
@@ -778,7 +739,9 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
memcpy(hdr+1, buff[0], nsamps*4);
recPlay->currentPtr+=sizeof(iqrec_t)+nsamps*4;
recPlay->nbSamplesBlocks++;
#if 0 // BMC: this is too verbose
LOG_D(HW,"recorded %d samples, for TS %lu, shift in buffer %ld\n", nsamps, hdr->ts, recPlay->currentPtr-(uint8_t *)recPlay->ms_sample);
#endif
} else
exit_function(__FILE__, __FUNCTION__, __LINE__,"Recording reaches max iq limit\n");
}