Compare commits

...

8 Commits

Author SHA1 Message Date
frtabu
564eee7b7c --amend 2020-09-15 20:53:32 +02:00
frtabu
bd33606b86 add gcc options to track simd usage 2020-09-15 10:26:56 +02:00
frtabu
00ecef7761 add code to debug pucch dft 2020-09-15 10:10:09 +02:00
frtabu
4d19f6ae1d dft tests 2020-09-15 10:10:09 +02:00
frtabu
d126ba9bcc add tools to compare oai/kiss dfts 2020-09-15 10:10:09 +02:00
frtabu
1713787750 add tools to compare oai/kiss dfts 2020-09-15 10:10:09 +02:00
frtabu
7c628ca625 add oai_kissfft.c 2020-09-15 10:10:09 +02:00
frtabu
40f55fa9c5 add kissfft as a possible fft implementation 2020-09-15 10:10:09 +02:00
6 changed files with 10918 additions and 10 deletions

View File

@@ -1415,7 +1415,13 @@ add_library(ldpc MODULE ${PHY_LDPC_OPTIM8SEGMULTI_SRC} )
add_library(coding MODULE ${PHY_TURBOSRC} )
add_library(dfts MODULE ${OPENAIR1_DIR}/PHY/TOOLS/oai_dfts.c )
set(KISSFFT_DIR ${OPENAIR_DIR}/kiss_fft130)
add_library(dfts_fpkiss MODULE ${OPENAIR1_DIR}/PHY/TOOLS/oai_kissdfts.c ${OPENAIR1_DIR}/PHY/TOOLS/oai_dfts_tmp.c ${KISSFFT_DIR}/kiss_fft.c)
target_compile_definitions(dfts_fpkiss PUBLIC -DFIXED_POINT=16 )
target_compile_options(dfts_fpkiss PUBLIC -O3 -march=native -ffast-math -fomit-frame-pointer -fopt-info-loop-optimized )
add_library(dfts_flkiss MODULE ${OPENAIR1_DIR}/PHY/TOOLS/oai_kissdfts.c ${OPENAIR1_DIR}/PHY/TOOLS/oai_dfts_tmp.c ${KISSFFT_DIR}/kiss_fft.c)
target_compile_options(dfts_flkiss PUBLIC -O3 -march=native -ffast-math -fomit-frame-pointer -ftree-vectorizer-verbose=2 -fopt-info-vec-missed)
set(PHY_SRC_COMMON
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools_common.c

View File

@@ -67,7 +67,7 @@ UE_TIMING_TRACE="False"
USRP_REC_PLAY="False"
BUILD_ECLIPSE=0
NR="False"
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope msc"
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope msc dfts_fpkiss dfts_flkiss"
trap handle_ctrl_c INT
function print_help() {

View File

@@ -32,6 +32,7 @@
#define M_PI 3.14159265358979323846
#endif
#define OAIDFTS_MAIN
#define OAIDFTS_LIB
#ifndef MR_MAIN
#include "PHY/defs_common.h"
#include "PHY/impl_defs_top.h"
@@ -9649,7 +9650,6 @@ int dfts_autoinit(void)
}
#ifndef MR_MAIN
void dft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag){

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,220 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file openair1/PHY/TPOOLS/oai_kissdfts.c
* \brief: interface to kissfft, used to build libdfts_kiss.so
* alternative to oai implementation of dft and idft
* \author Francois TABURET
* \date 2020
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <execinfo.h>
#include <limits.h>
#define OAIDFTS_LIB
#include "PHY/defs_common.h"
#include "PHY/impl_defs_top.h"
#include "time_meas.h"
#include "LOG/log.h"
#include "kiss_fft130/kiss_fft.h"
static kiss_fft_cfg fftcfg[DFT_SIZE_IDXTABLESIZE];
static kiss_fft_cfg ifftcfg[IDFT_SIZE_IDXTABLESIZE];
static int fftsizes[] = DFT_SIZES;
static int ifftsizes[] = IDFT_SIZES;
/*----------------------------------------------------------------*/
/* dft library entry points: */
static int16_t *tmpbuff;
int dfts_autoinit(void)
{
for (int i=0; i<DFT_SIZE_IDXTABLESIZE ; i++) {
fftcfg[i]=kiss_fft_alloc(fftsizes[i],0,NULL,NULL);
}
for (int i=0; i<IDFT_SIZE_IDXTABLESIZE ; i++) {
ifftcfg[i]=kiss_fft_alloc(ifftsizes[i],1,NULL,NULL);
}
tmpbuff=malloc(98304*2*sizeof(int16_t));
olddfts_autoinit();
return 0;
}
void convert_shorttofloat(int size,short *input,float *output,int factor){
for (int i=0;i<(size-2);i++){
output[2*i]=(float)(input[2*i]*factor);
output[(2*i)+1]=(float)((input[(2*i)+1])*factor);
}
}
void convert_floattoshort(int size,float *input,short *output,int factor){
for (int i=0;i<(size-2);i++){
output[2*i]=(int16_t)(((int)(roundf(input[2*i])))/factor);
output[(2*i)+1]=(int16_t)(((int)(roundf(input[(2*i)+1])))/factor);
}
}
void rescale_up_int16buff(int size,int16_t *input, int factor){
for (int i=0;i<(size*2);i=i+1){
input[i]=(input[i]*factor);
}
}
void rescale_up_newint16buff(int size,int16_t *input, int16_t *output,int factor){
switch (size) {
case 128:
for(int j=0; j<256; j++) {
output[j]=input[j]*factor;
}
break;
default:
for (int i=0;i<size;i=i+1){
output[2*i]=(input[2*i]*factor);
output[2*i+1]=(input[2*i+1]*factor);
}
break;
}
}
void rescale_down_int16buff(int size,int16_t *input, int factor){
for (int i=0;i<(size*2);i=i+1){
input[i]=(input[i]/factor);
}
}
void rescale_dft_int16buff(int size,int16_t *input, int factor){
for (int i=0;i<(size*2);i=i+1){
int32_t tmpi=input[i]*factor;
input[i]=tmpi/4096;
}
}
void print_minmax(int size,int16_t *buf,int scale_flag) {
int16_t vmin=0, vmax=0;
for (int i=0;i<(size*2);i=i+1){
if (buf[i]>vmax) vmax=buf[i];
if (buf[i]<vmin) vmin=buf[i];
}
if (scale_flag == 0 || (vmax - vmin)>10)
printf("%i: %i - %i\n",scale_flag,vmin,vmax);
}
void dft(uint8_t sizeidx,int16_t *input,int16_t *output,unsigned char scale_flag){
#ifndef FIXED_POINT
float input_float[98304*2];
float output_float[98304*2];
switch(sizeidx) {
case DFT_128:
case DFT_256:
case DFT_512:
case DFT_1024:
case DFT_1536:
case DFT_2048:
case DFT_3072:
case DFT_4096:
case DFT_6144:
case DFT_8192:
case DFT_9216:
case DFT_12288:
case DFT_18432:
case DFT_24576:
case DFT_36864:
case DFT_49152:
case DFT_73728:
case DFT_98304:
convert_shorttofloat(fftsizes[sizeidx],input,input_float,8192);
kiss_fft(fftcfg[sizeidx],(kiss_fft_cpx *)input_float,(kiss_fft_cpx *)output_float);
if (scale_flag)
convert_floattoshort(fftsizes[sizeidx],output_float,output,8192);
else
convert_floattoshort(fftsizes[sizeidx],output_float,output,98304);
break;
default:
olddft(sizeidx,input,output,scale_flag);
break;
}
#else
switch(sizeidx) {
case DFT_128:
case DFT_256:
case DFT_512:
case DFT_1024:
case DFT_1536:
case DFT_2048:
case DFT_3072:
case DFT_4096:
case DFT_6144:
case DFT_8192:
case DFT_9216:
case DFT_12288:
case DFT_18432:
case DFT_24576:
case DFT_36864:
case DFT_49152:
case DFT_73728:
case DFT_98304:
if (scale_flag)
rescale_up_int16buff(fftsizes[sizeidx],input,16);
//
kiss_fft(fftcfg[sizeidx],(kiss_fft_cpx *)input,(kiss_fft_cpx *)output);
// if (scale_flag)
// rescale_down_int16buff(fftsizes[sizeidx],output,16);
break;
default:
olddft(sizeidx,input,output,scale_flag);
break;
}
// print_minmax(fftsizes[sizeidx],output,scale_flag);
#endif
};
void idft(uint8_t sizeidx, int16_t *input,int16_t *output,unsigned char scale_flag){
#ifndef FIXED_POINT
float input_float2[98304*2];
float output_float2[98304*2];
convert_shorttofloat(ifftsizes[sizeidx],input,input_float2, 4096);
kiss_fft(ifftcfg[sizeidx],(kiss_fft_cpx *)input_float2,(kiss_fft_cpx *)output_float2);
convert_floattoshort(ifftsizes[sizeidx],output_float2,output,98304);
#else
if (scale_flag)
rescale_up_int16buff(ifftsizes[sizeidx],input,16);
kiss_fft(ifftcfg[sizeidx],(kiss_fft_cpx *)input,(kiss_fft_cpx *)output);
// oldidft(sizeidx,input,output,scale_flag);
// print_minmax(ifftsizes[sizeidx],output,scale_flag);
#endif
};

View File

@@ -261,23 +261,26 @@ void idft36864(int16_t *sigF,int16_t *sig,uint8_t scale_flag);
void idft49152(int16_t *sigF,int16_t *sig,uint8_t scale_flag);
void idft73728(int16_t *sigF,int16_t *sig,uint8_t scale_flag);
void idft98304(int16_t *sigF,int16_t *sig,uint8_t scale_flag);
#endif
#else
typedef void(*dftfunc_t)(uint8_t sizeidx,int16_t *sigF,int16_t *sig,unsigned char scale_flag);
typedef void(*idftfunc_t)(uint8_t sizeidx,int16_t *sigF,int16_t *sig,unsigned char scale_flag);
# ifdef OAIDFTS_LOADER
typedef void(*dftfunc_t)(uint8_t sizeidx,int16_t *sigF,int16_t *sig,unsigned char scale_flag);
typedef void(*idftfunc_t)(uint8_t sizeidx,int16_t *sigF,int16_t *sig,unsigned char scale_flag);
#ifdef OAIDFTS_LOADER
dftfunc_t dft;
idftfunc_t idft;
# else
extern dftfunc_t dft;
extern idftfunc_t idft;
extern int load_dftslib(void);
#else
# ifndef OAIDFTS_LIB
extern dftfunc_t dft;
extern idftfunc_t idft;
extern int load_dftslib(void);
# endif
#endif
typedef enum DFT_size_idx {
DFT_12, DFT_24, DFT_36, DFT_48, DFT_60, DFT_72, DFT_96,
DFT_108, DFT_120, DFT_128, DFT_144, DFT_180, DFT_192, DFT_216, DFT_240,
@@ -289,6 +292,16 @@ typedef enum DFT_size_idx {
DFT_SIZE_IDXTABLESIZE
} dft_size_idx_t;
#define DFT_SIZES {\
12*4, 24*4, 36*4, 48*4, 60*4, 72*4, 96*4,\
108*4, 120*4, 128, 144*4, 180*4, 192*4, 216*4, 240*4,\
256, 288*4, 300*4, 324*4, 360*4, 384*4, 432*4, 480*4,\
512, 540*4, 576*4, 600*4, 648*4, 720*4, 768*4, 864*4,\
900*4, 960*4, 972*4, 1024, 1080*4, 1152*4, 1200*4, 1536,\
2048, 3072, 4096, 6144, 8192 ,9216, 12288, 18432,\
24576, 36864, 49152,73728, 98304}
#ifdef OAIDFTS_MAIN
adftfunc_t dft_ftab[]={
dft12, dft24, dft36, dft48, dft60, dft72, dft96,
@@ -307,6 +320,12 @@ typedef enum idft_size_idx {
IDFT_73728, IDFT_98304,
IDFT_SIZE_IDXTABLESIZE
} idft_size_idx_t;
#define IDFT_SIZES {\
128, 256, 512, 1024, 1536, 2048, 3072, 4096,\
6144, 8192, 9216, 12288, 18432, 24576, 36864, 49152,\
73728, 98304}
#ifdef OAIDFTS_MAIN
aidftfunc_t idft_ftab[]={
idft128, idft256, idft512, idft1024, idft1536, idft2048, idft3072, idft4096,