Transceiver52M: Separate architecture specific files
Move x86 specific files into their own directory as this area is about to get crowded with the addition of ARM support. Signed-off-by: Thomas Tsou <tom@tsou.cc>
This commit is contained in:
parent
a1a3ab4bab
commit
17bbb9b755
|
@ -21,10 +21,13 @@
|
||||||
|
|
||||||
include $(top_srcdir)/Makefile.common
|
include $(top_srcdir)/Makefile.common
|
||||||
|
|
||||||
AM_CFLAGS = $(STD_DEFINES_AND_INCLUDES) -std=gnu99 -march=native
|
AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) -I./common
|
||||||
AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
|
|
||||||
AM_CXXFLAGS = -ldl -lpthread
|
AM_CXXFLAGS = -ldl -lpthread
|
||||||
|
|
||||||
|
SUBDIRS = x86
|
||||||
|
|
||||||
|
ARCH_LA = x86/libarch.la
|
||||||
|
|
||||||
#UHD wins if both are defined
|
#UHD wins if both are defined
|
||||||
if UHD
|
if UHD
|
||||||
AM_CPPFLAGS += $(UHD_CFLAGS)
|
AM_CPPFLAGS += $(UHD_CFLAGS)
|
||||||
|
@ -52,9 +55,7 @@ COMMON_SOURCES = \
|
||||||
radioClock.cpp \
|
radioClock.cpp \
|
||||||
sigProcLib.cpp \
|
sigProcLib.cpp \
|
||||||
Transceiver.cpp \
|
Transceiver.cpp \
|
||||||
DummyLoad.cpp \
|
DummyLoad.cpp
|
||||||
convolve.c \
|
|
||||||
convert.c
|
|
||||||
|
|
||||||
libtransceiver_la_SOURCES = \
|
libtransceiver_la_SOURCES = \
|
||||||
$(COMMON_SOURCES) \
|
$(COMMON_SOURCES) \
|
||||||
|
@ -79,8 +80,8 @@ noinst_HEADERS = \
|
||||||
rcvLPF_651.h \
|
rcvLPF_651.h \
|
||||||
sendLPF_961.h \
|
sendLPF_961.h \
|
||||||
Resampler.h \
|
Resampler.h \
|
||||||
convolve.h \
|
common/convolve.h \
|
||||||
convert.h
|
common/convert.h
|
||||||
|
|
||||||
USRPping_SOURCES = USRPping.cpp
|
USRPping_SOURCES = USRPping.cpp
|
||||||
USRPping_LDADD = \
|
USRPping_LDADD = \
|
||||||
|
@ -90,12 +91,14 @@ USRPping_LDADD = \
|
||||||
transceiver_SOURCES = runTransceiver.cpp
|
transceiver_SOURCES = runTransceiver.cpp
|
||||||
transceiver_LDADD = \
|
transceiver_LDADD = \
|
||||||
libtransceiver.la \
|
libtransceiver.la \
|
||||||
|
$(ARCH_LA) \
|
||||||
$(GSM_LA) \
|
$(GSM_LA) \
|
||||||
$(COMMON_LA) $(SQLITE_LA)
|
$(COMMON_LA) $(SQLITE_LA)
|
||||||
|
|
||||||
sigProcLibTest_SOURCES = sigProcLibTest.cpp
|
sigProcLibTest_SOURCES = sigProcLibTest.cpp
|
||||||
sigProcLibTest_LDADD = \
|
sigProcLibTest_LDADD = \
|
||||||
libtransceiver.la \
|
libtransceiver.la \
|
||||||
|
$(ARCH_LA) \
|
||||||
$(GSM_LA) \
|
$(GSM_LA) \
|
||||||
$(COMMON_LA) $(SQLITE_LA)
|
$(COMMON_LA) $(SQLITE_LA)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,156 @@
|
||||||
|
/*
|
||||||
|
* Convolution
|
||||||
|
* Copyright (C) 2012, 2013 Thomas Tsou <tom@tsou.cc>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Base multiply and accumulate complex-real */
|
||||||
|
static void mac_real(float *x, float *h, float *y)
|
||||||
|
{
|
||||||
|
y[0] += x[0] * h[0];
|
||||||
|
y[1] += x[1] * h[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Base multiply and accumulate complex-complex */
|
||||||
|
static void mac_cmplx(float *x, float *h, float *y)
|
||||||
|
{
|
||||||
|
y[0] += x[0] * h[0] - x[1] * h[1];
|
||||||
|
y[1] += x[0] * h[1] + x[1] * h[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Base vector complex-complex multiply and accumulate */
|
||||||
|
static void mac_real_vec_n(float *x, float *h, float *y,
|
||||||
|
int len, int step, int offset)
|
||||||
|
{
|
||||||
|
for (int i = offset; i < len; i += step)
|
||||||
|
mac_real(&x[2 * i], &h[2 * i], y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Base vector complex-complex multiply and accumulate */
|
||||||
|
static void mac_cmplx_vec_n(float *x, float *h, float *y,
|
||||||
|
int len, int step, int offset)
|
||||||
|
{
|
||||||
|
for (int i = offset; i < len; i += step)
|
||||||
|
mac_cmplx(&x[2 * i], &h[2 * i], y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Base complex-real convolution */
|
||||||
|
int _base_convolve_real(float *x, int x_len,
|
||||||
|
float *h, int h_len,
|
||||||
|
float *y, int y_len,
|
||||||
|
int start, int len,
|
||||||
|
int step, int offset)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
mac_real_vec_n(&x[2 * (i - (h_len - 1) + start)],
|
||||||
|
h,
|
||||||
|
&y[2 * i], h_len,
|
||||||
|
step, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Base complex-complex convolution */
|
||||||
|
int _base_convolve_complex(float *x, int x_len,
|
||||||
|
float *h, int h_len,
|
||||||
|
float *y, int y_len,
|
||||||
|
int start, int len,
|
||||||
|
int step, int offset)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
mac_cmplx_vec_n(&x[2 * (i - (h_len - 1) + start)],
|
||||||
|
h,
|
||||||
|
&y[2 * i],
|
||||||
|
h_len, step, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Buffer validity checks */
|
||||||
|
int bounds_check(int x_len, int h_len, int y_len,
|
||||||
|
int start, int len, int step)
|
||||||
|
{
|
||||||
|
if ((x_len < 1) || (h_len < 1) ||
|
||||||
|
(y_len < 1) || (len < 1) || (step < 1)) {
|
||||||
|
fprintf(stderr, "Convolve: Invalid input\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((start + len > x_len) || (len > y_len) || (x_len < h_len)) {
|
||||||
|
fprintf(stderr, "Convolve: Boundary exception\n");
|
||||||
|
fprintf(stderr, "start: %i, len: %i, x: %i, h: %i, y: %i\n",
|
||||||
|
start, len, x_len, h_len, y_len);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* API: Non-aligned (no SSE) complex-real */
|
||||||
|
int base_convolve_real(float *x, int x_len,
|
||||||
|
float *h, int h_len,
|
||||||
|
float *y, int y_len,
|
||||||
|
int start, int len,
|
||||||
|
int step, int offset)
|
||||||
|
{
|
||||||
|
if (bounds_check(x_len, h_len, y_len, start, len, step) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
memset(y, 0, len * 2 * sizeof(float));
|
||||||
|
|
||||||
|
return _base_convolve_real(x, x_len,
|
||||||
|
h, h_len,
|
||||||
|
y, y_len,
|
||||||
|
start, len, step, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* API: Non-aligned (no SSE) complex-complex */
|
||||||
|
int base_convolve_complex(float *x, int x_len,
|
||||||
|
float *h, int h_len,
|
||||||
|
float *y, int y_len,
|
||||||
|
int start, int len,
|
||||||
|
int step, int offset)
|
||||||
|
{
|
||||||
|
if (bounds_check(x_len, h_len, y_len, start, len, step) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
memset(y, 0, len * 2 * sizeof(float));
|
||||||
|
|
||||||
|
return _base_convolve_complex(x, x_len,
|
||||||
|
h, h_len,
|
||||||
|
y, y_len,
|
||||||
|
start, len, step, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Aligned filter tap allocation */
|
||||||
|
void *convolve_h_alloc(int len)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_SSE3
|
||||||
|
return memalign(16, len * 2 * sizeof(float));
|
||||||
|
#else
|
||||||
|
return malloc(len * 2 * sizeof(float));
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
AM_CFLAGS = -Wall -std=gnu99 -march=native -I../common
|
||||||
|
|
||||||
|
noinst_LTLIBRARIES = libarch.la
|
||||||
|
|
||||||
|
libarch_la_SOURCES = \
|
||||||
|
../common/convolve_base.c \
|
||||||
|
convert.c \
|
||||||
|
convolve.c
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "convert.h"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -164,7 +165,7 @@ static void convert_scale_ps_si16(short *out, float *in, float scale, int len)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SSE_4_1
|
#ifndef HAVE_SSE3
|
||||||
static void convert_si16_ps(float *out, short *in, int len)
|
static void convert_si16_ps(float *out, short *in, int len)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
|
@ -20,11 +20,28 @@
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "convolve.h"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Forward declarations from base implementation */
|
||||||
|
int _base_convolve_real(float *x, int x_len,
|
||||||
|
float *h, int h_len,
|
||||||
|
float *y, int y_len,
|
||||||
|
int start, int len,
|
||||||
|
int step, int offset);
|
||||||
|
|
||||||
|
int _base_convolve_complex(float *x, int x_len,
|
||||||
|
float *h, int h_len,
|
||||||
|
float *y, int y_len,
|
||||||
|
int start, int len,
|
||||||
|
int step, int offset);
|
||||||
|
|
||||||
|
int bounds_check(int x_len, int h_len, int y_len,
|
||||||
|
int start, int len, int step);
|
||||||
|
|
||||||
#ifdef HAVE_SSE3
|
#ifdef HAVE_SSE3
|
||||||
#include <xmmintrin.h>
|
#include <xmmintrin.h>
|
||||||
#include <pmmintrin.h>
|
#include <pmmintrin.h>
|
||||||
|
@ -493,90 +510,6 @@ static void sse_conv_cmplx_8n(float *x, float *h, float *y, int h_len, int len)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Base multiply and accumulate complex-real */
|
|
||||||
static void mac_real(float *x, float *h, float *y)
|
|
||||||
{
|
|
||||||
y[0] += x[0] * h[0];
|
|
||||||
y[1] += x[1] * h[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Base multiply and accumulate complex-complex */
|
|
||||||
static void mac_cmplx(float *x, float *h, float *y)
|
|
||||||
{
|
|
||||||
y[0] += x[0] * h[0] - x[1] * h[1];
|
|
||||||
y[1] += x[0] * h[1] + x[1] * h[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Base vector complex-complex multiply and accumulate */
|
|
||||||
static void mac_real_vec_n(float *x, float *h, float *y,
|
|
||||||
int len, int step, int offset)
|
|
||||||
{
|
|
||||||
for (int i = offset; i < len; i += step)
|
|
||||||
mac_real(&x[2 * i], &h[2 * i], y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Base vector complex-complex multiply and accumulate */
|
|
||||||
static void mac_cmplx_vec_n(float *x, float *h, float *y,
|
|
||||||
int len, int step, int offset)
|
|
||||||
{
|
|
||||||
for (int i = offset; i < len; i += step)
|
|
||||||
mac_cmplx(&x[2 * i], &h[2 * i], y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Base complex-real convolution */
|
|
||||||
static int _base_convolve_real(float *x, int x_len,
|
|
||||||
float *h, int h_len,
|
|
||||||
float *y, int y_len,
|
|
||||||
int start, int len,
|
|
||||||
int step, int offset)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
mac_real_vec_n(&x[2 * (i - (h_len - 1) + start)],
|
|
||||||
h,
|
|
||||||
&y[2 * i], h_len,
|
|
||||||
step, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Base complex-complex convolution */
|
|
||||||
static int _base_convolve_complex(float *x, int x_len,
|
|
||||||
float *h, int h_len,
|
|
||||||
float *y, int y_len,
|
|
||||||
int start, int len,
|
|
||||||
int step, int offset)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
mac_cmplx_vec_n(&x[2 * (i - (h_len - 1) + start)],
|
|
||||||
h,
|
|
||||||
&y[2 * i],
|
|
||||||
h_len, step, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Buffer validity checks */
|
|
||||||
static int bounds_check(int x_len, int h_len, int y_len,
|
|
||||||
int start, int len, int step)
|
|
||||||
{
|
|
||||||
if ((x_len < 1) || (h_len < 1) ||
|
|
||||||
(y_len < 1) || (len < 1) || (step < 1)) {
|
|
||||||
fprintf(stderr, "Convolve: Invalid input\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((start + len > x_len) || (len > y_len) || (x_len < h_len)) {
|
|
||||||
fprintf(stderr, "Convolve: Boundary exception\n");
|
|
||||||
fprintf(stderr, "start: %i, len: %i, x: %i, h: %i, y: %i\n",
|
|
||||||
start, len, x_len, h_len, y_len);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* API: Aligned complex-real */
|
/* API: Aligned complex-real */
|
||||||
int convolve_real(float *x, int x_len,
|
int convolve_real(float *x, int x_len,
|
||||||
float *h, int h_len,
|
float *h, int h_len,
|
||||||
|
@ -666,49 +599,3 @@ int convolve_complex(float *x, int x_len,
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* API: Non-aligned (no SSE) complex-real */
|
|
||||||
int base_convolve_real(float *x, int x_len,
|
|
||||||
float *h, int h_len,
|
|
||||||
float *y, int y_len,
|
|
||||||
int start, int len,
|
|
||||||
int step, int offset)
|
|
||||||
{
|
|
||||||
if (bounds_check(x_len, h_len, y_len, start, len, step) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
memset(y, 0, len * 2 * sizeof(float));
|
|
||||||
|
|
||||||
return _base_convolve_real(x, x_len,
|
|
||||||
h, h_len,
|
|
||||||
y, y_len,
|
|
||||||
start, len, step, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* API: Non-aligned (no SSE) complex-complex */
|
|
||||||
int base_convolve_complex(float *x, int x_len,
|
|
||||||
float *h, int h_len,
|
|
||||||
float *y, int y_len,
|
|
||||||
int start, int len,
|
|
||||||
int step, int offset)
|
|
||||||
{
|
|
||||||
if (bounds_check(x_len, h_len, y_len, start, len, step) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
memset(y, 0, len * 2 * sizeof(float));
|
|
||||||
|
|
||||||
return _base_convolve_complex(x, x_len,
|
|
||||||
h, h_len,
|
|
||||||
y, y_len,
|
|
||||||
start, len, step, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Aligned filter tap allocation */
|
|
||||||
void *convolve_h_alloc(int len)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_SSE3
|
|
||||||
return memalign(16, len * 2 * sizeof(float));
|
|
||||||
#else
|
|
||||||
return malloc(len * 2 * sizeof(float));
|
|
||||||
#endif
|
|
||||||
}
|
|
|
@ -101,6 +101,7 @@ AC_CONFIG_FILES([\
|
||||||
CommonLibs/Makefile \
|
CommonLibs/Makefile \
|
||||||
GSM/Makefile \
|
GSM/Makefile \
|
||||||
Transceiver52M/Makefile \
|
Transceiver52M/Makefile \
|
||||||
|
Transceiver52M/x86/Makefile \
|
||||||
sqlite3/Makefile \
|
sqlite3/Makefile \
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue