[MERGED] osmo-pcu[master]: tbf.cpp: use new tlli instead of old tlli

2017-05-01 Thread lynxis lazus
lynxis lazus has submitted this change and it was merged.

Change subject: tbf.cpp: use new tlli instead of old tlli
..


tbf.cpp: use new tlli instead of old tlli

The old tlli might be 0x.

Change-Id: I2fd6fec022506e203d05e91c36ccd9e020ff816c
---
M src/tbf.cpp
M tests/tbf/TbfTest.err
2 files changed, 3 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Holger Freyther: Looks good to me, approved



diff --git a/src/tbf.cpp b/src/tbf.cpp
index 820131c..99ad30a 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -1311,7 +1311,7 @@
if (dl_tbf && dl_tbf->ms() != ms()) {
LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from "
"TLLI=0x%08x while %s still exists. "
-   "Killing pending DL TBF\n", tlli(),
+   "Killing pending DL TBF\n", new_tlli,
tbf_name(dl_tbf));
tbf_free(dl_tbf);
dl_tbf = NULL;
@@ -1319,7 +1319,7 @@
if (ul_tbf && ul_tbf->ms() != ms()) {
LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from "
"TLLI=0x%08x while %s still exists. "
-   "Killing pending UL TBF\n", tlli(),
+   "Killing pending UL TBF\n", new_tlli,
tbf_name(ul_tbf));
tbf_free(ul_tbf);
ul_tbf = NULL;
diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err
index 3412bde..2002379 100644
--- a/tests/tbf/TbfTest.err
+++ b/tests/tbf/TbfTest.err
@@ -2184,7 +2184,7 @@
 - BSN 0 storing in window (0..63)
 TBF(TFI=0 TLLI=0x DIR=UL STATE=FLOW): data_length=20, data=f1 22 33 44 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 Decoded premier TLLI=0x of UL DATA TFI=0.
-Got RACH from TLLI=0x while TBF(TFI=0 TLLI=0xf1223344 DIR=DL 
STATE=ASSIGN) still exists. Killing pending DL TBF
+Got RACH from TLLI=0xf1223344 while TBF(TFI=0 TLLI=0xf1223344 DIR=DL 
STATE=ASSIGN) still exists. Killing pending DL TBF
 TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN) changes state from ASSIGN to 
RELEASING
 TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=RELEASING) free
 TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=RELEASING) stopping timer 0.

-- 
To view, visit https://gerrit.osmocom.org/1663
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2fd6fec022506e203d05e91c36ccd9e020ff816c
Gerrit-PatchSet: 3
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: lynxis lazus 


libosmocore[master]: core/conv: add x86 SSE support for Viterbi decoder

2017-05-01 Thread Vadim Yanitskiy

Patch Set 4: Code-Review-1

> Build Failed
 > 
 > http://jenkins.osmocom.org/jenkins/job/libosmocore-gerrit/1009/ :
 > FAILURE

Here we have the same problem with FreeBSD, as described in
previous change, but there is also another issue. Have a look
at Debian build log, and you will see, that SCH test fails.

This failure caused by SSE decoder implementation, which
provides one-byte different decoding result from original
implementation. I'll describe more details in the ML.

-- 
To view, visit https://gerrit.osmocom.org/2454
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I1da6d71ed0564f1d684f3a836e998d09de5f0351
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


libosmocore[master]: configure.ac: add SIMD detection capabilities

2017-05-01 Thread Vadim Yanitskiy

Patch Set 3:

> Build Failed
 > 
 > http://jenkins.osmocom.org/jenkins/job/libosmocore-gerrit/1008/ :
 > FAILURE

Well, Debian build is ok, but FreeBSD fails...
I cannot reproduce the problem at my end.

All I can see is multiple "Illegal instruction"
messages.

Which compiler is used on FreeBSD?

-- 
To view, visit https://gerrit.osmocom.org/2453
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Idf8fff984bd936a75c7c307338df88ba4b005817
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[MERGED] libosmocore[master]: tests/conv: add GSM 05.03 specific test

2017-05-01 Thread Vadim Yanitskiy
Vadim Yanitskiy has submitted this change and it was merged.

Change subject: tests/conv: add GSM 05.03 specific test
..


tests/conv: add GSM 05.03 specific test

This change extends the convolutional code test coverage, adding
the GSM 05.03 specific test vectors, generated by the conv_gen.py.

Inspired by Tom's patch:
http://lists.osmocom.org/pipermail/openbsc/2014-April/007364.html

Change-Id: I76d1cd4032d2f74c5bb93bde4fab99aa655b7f1a
---
M .gitignore
M tests/Makefile.am
M tests/conv/conv.h
A tests/conv/conv_gsm0503_test.c
A tests/conv/conv_gsm0503_test.ok
M tests/testsuite.at
6 files changed, 355 insertions(+), 5 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/.gitignore b/.gitignore
index 4c6a78f..5111b25 100644
--- a/.gitignore
+++ b/.gitignore
@@ -122,6 +122,7 @@
 include/osmocom/core/crc*gen.h
 include/osmocom/core/bit*gen.h
 include/osmocom/gsm/gsm0503.h
+tests/conv/gsm0503_test_vectors.c
 
 # vi files
 *.sw?
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3ce7620..d9816ef 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -15,7 +15,8 @@
 bitvec/bitvec_test msgb/msgb_test bits/bitcomp_test\
 tlv/tlv_test gsup/gsup_test oap/oap_test fsm/fsm_test  \
 write_queue/wqueue_test socket/socket_test \
-coding/coding_test abis/abis_test
+coding/coding_test conv/conv_gsm0503_test  \
+abis/abis_test
 
 if ENABLE_MSGFILE
 check_PROGRAMS += msgfile/msgfile_test
@@ -63,6 +64,10 @@
 
 conv_conv_test_SOURCES = conv/conv_test.c conv/conv.c
 conv_conv_test_LDADD = $(top_builddir)/src/libosmocore.la 
$(top_builddir)/src/gsm/libgsmint.la
+
+conv_conv_gsm0503_test_SOURCES = conv/conv_gsm0503_test.c conv/conv.c 
conv/gsm0503_test_vectors.c
+conv_conv_gsm0503_test_LDADD = $(top_builddir)/src/libosmocore.la 
$(top_builddir)/src/gsm/libgsmint.la
+conv_conv_gsm0503_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/conv
 
 gsm0808_gsm0808_test_SOURCES = gsm0808/gsm0808_test.c
 gsm0808_gsm0808_test_LDADD = $(top_builddir)/src/libosmocore.la 
$(top_builddir)/src/gsm/libosmogsm.la
@@ -198,9 +203,11 @@
 socket/socket_test.err coding/coding_test.ok   \
 osmo-auc-gen/osmo-auc-gen_test.sh  \
 osmo-auc-gen/osmo-auc-gen_test.ok  \
-osmo-auc-gen/osmo-auc-gen_test.err
+osmo-auc-gen/osmo-auc-gen_test.err \
+conv/conv_gsm0503_test.ok
 
-DISTCLEANFILES = atconfig atlocal
+DISTCLEANFILES = atconfig atlocal conv/gsm0503_test_vectors.c
+BUILT_SOURCES = conv/gsm0503_test_vectors.c
 noinst_HEADERS = conv/conv.h
 
 TESTSUITE = $(srcdir)/testsuite
@@ -221,3 +228,7 @@
 $(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4
$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
mv $@.tmp $@
+
+conv/gsm0503_test_vectors.c: $(top_srcdir)/utils/conv_gen.py 
$(top_srcdir)/utils/conv_codes_gsm.py
+   $(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py gen_vectors gsm \
+   --target-path $(builddir)/conv
diff --git a/tests/conv/conv.h b/tests/conv/conv.h
index 676c5af..0604859 100644
--- a/tests/conv/conv.h
+++ b/tests/conv/conv.h
@@ -1,7 +1,7 @@
 #pragma once
 
-#define MAX_LEN_BITS   512
-#define MAX_LEN_BYTES  (512/8)
+#define MAX_LEN_BITS   2048
+#define MAX_LEN_BYTES  (2048 / 8)
 
 struct conv_test_vector {
const char *name;
diff --git a/tests/conv/conv_gsm0503_test.c b/tests/conv/conv_gsm0503_test.c
new file mode 100644
index 000..6704129
--- /dev/null
+++ b/tests/conv/conv_gsm0503_test.c
@@ -0,0 +1,28 @@
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "conv.h"
+
+/* Forward declaration of GSM 05.03 specific test vectors */
+extern const struct conv_test_vector gsm0503_vectors[];
+extern const int gsm0503_vectors_len;
+
+int main(int argc, char *argv[])
+{
+   int rc, i;
+
+   for (i = 0; i < gsm0503_vectors_len; i++) {
+   rc = do_check(_vectors[i]);
+   if (rc)
+   return rc;
+   }
+
+   return 0;
+}
diff --git a/tests/conv/conv_gsm0503_test.ok b/tests/conv/conv_gsm0503_test.ok
new file mode 100644
index 000..e6e2572
--- /dev/null
+++ b/tests/conv/conv_gsm0503_test.ok
@@ -0,0 +1,304 @@
+[+] Testing: gsm0503_xcch
+[.] Input length  : ret = 224  exp = 224 -> OK
+[.] Output length : ret = 456  exp = 456 -> OK
+[.] Random vector checks:
+[..] Encoding / Decoding cycle : OK
+[..] Encoding / Decoding cycle : OK
+[..] Encoding / Decoding cycle : OK
+
+[+] Testing: gsm0503_rach
+[.] Input length  : ret =  14  exp =  14 -> OK
+[.] Output length : ret =  36  exp =  36 -> OK
+[.] Random vector checks:
+[..] Encoding / Decoding cycle : OK
+[..] Encoding / Decoding cycle : OK
+[..] 

[PATCH] libosmocore[master]: core/conv: add x86 SSE support for Viterbi decoder

2017-05-01 Thread Vadim Yanitskiy
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2454

to look at the new patch set (#4).

core/conv: add x86 SSE support for Viterbi decoder

Fast convolutional decoding is provided through x86 intrinsic based
SSE operations. SSE3, found on virtually all modern x86 processors,
is the minimal requirement. SSE4.1 and AVX2 are used if available.

Also, the original code was extended with runtime SIMD detection,
so only supported extensions will be used by target CPU. It makes
the library more partable, what is very important for binary
packages distribution. The SIMD detection is currently implemented
through the __builtin_cpu_supports(EXT), which is only supported
by GCC.

Change-Id: I1da6d71ed0564f1d684f3a836e998d09de5f0351
---
M src/Makefile.am
M src/viterbi.c
M src/viterbi_gen.c
A src/viterbi_sse.c
4 files changed, 746 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/2454/4

diff --git a/src/Makefile.am b/src/Makefile.am
index 999436d..2f19838 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,6 +19,10 @@
 macaddr.c stat_item.c stats.c stats_statsd.c prim.c \
 viterbi.c viterbi_gen.c
 
+if HAVE_SSE3
+libosmocore_la_SOURCES += viterbi_sse.c
+endif
+
 BUILT_SOURCES = crc8gen.c crc16gen.c crc32gen.c crc64gen.c
 
 if ENABLE_PLUGIN
diff --git a/src/viterbi.c b/src/viterbi.c
index 21c6a57..d68db23 100644
--- a/src/viterbi.c
+++ b/src/viterbi.c
@@ -24,11 +24,34 @@
 #include 
 #include 
 
-#include 
 #include "config.h"
+
+#include 
 
 #define BIT2NRZ(REG,N) (((REG >> N) & 0x01) * 2 - 1) * -1
 #define NUM_STATES(K)  (K == 7 ? 64 : 16)
+
+static int init_complete = 0;
+
+__attribute__ ((visibility("hidden"))) int avx2_supported = 0;
+__attribute__ ((visibility("hidden"))) int sse3_supported = 0;
+__attribute__ ((visibility("hidden"))) int sse41_supported = 0;
+
+/**
+ * This pointers will be initialized by the osmo_conv_init()
+ * depending on supported SIMD extensions.
+ */
+static int16_t *(*vdec_malloc)(size_t n);
+static void (*vdec_free)(int16_t *ptr);
+
+/* Forward malloc wrappers */
+int16_t *osmo_conv_vdec_malloc(size_t n);
+void osmo_conv_vdec_free(int16_t *ptr);
+
+#ifdef HAVE_SSE3
+int16_t *osmo_conv_vdec_malloc_sse3(size_t n);
+void osmo_conv_vdec_free_sse3(int16_t *ptr);
+#endif
 
 /* Forward Metric Units */
 void osmo_conv_gen_metrics_k5_n2(const int8_t *seq, const int16_t *out,
@@ -43,6 +66,21 @@
int16_t *sums, int16_t *paths, int norm);
 void osmo_conv_gen_metrics_k7_n4(const int8_t *seq, const int16_t *out,
int16_t *sums, int16_t *paths, int norm);
+
+#ifdef HAVE_SSE3
+void osmo_conv_gen_metrics_k5_n2_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k5_n3_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k5_n4_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n2_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n3_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n4_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+#endif
 
 /* Trellis State
  * state - Internal lshift register value
@@ -89,12 +127,6 @@
void (*metric_func)(const int8_t *, const int16_t *,
int16_t *, int16_t *, int);
 };
-
-/* Non-aligned Memory Allocator */
-static int16_t *vdec_malloc(size_t n)
-{
-   return (int16_t *) malloc(sizeof(int16_t) * n);
-}
 
 /* Accessor calls */
 static inline int conv_code_recursive(const struct osmo_conv_code *code)
@@ -294,9 +326,9 @@
if (!trellis)
return;
 
+   vdec_free(trellis->outputs);
+   vdec_free(trellis->sums);
free(trellis->vals);
-   free(trellis->outputs);
-   free(trellis->sums);
free(trellis);
 }
 
@@ -430,7 +462,7 @@
if (!dec)
return;
 
-   free(dec->paths[0]);
+   vdec_free(dec->paths[0]);
free(dec->paths);
free_trellis(dec->trellis);
free(dec);
@@ -456,13 +488,31 @@
if (dec->k == 5) {
switch (dec->n) {
case 2:
+   #ifdef HAVE_SSE3
+   dec->metric_func = !sse3_supported ?
+   osmo_conv_gen_metrics_k5_n2 :
+   osmo_conv_gen_metrics_k5_n2_sse;
+   #else
dec->metric_func = osmo_conv_gen_metrics_k5_n2;
+   #endif
break;
case 3:
+   #ifdef HAVE_SSE3
+   dec->metric_func = !sse3_supported ?
+ 

[PATCH] libosmocore[master]: core/conv: strip unused memalign() call

2017-05-01 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/2455

core/conv: strip unused memalign() call

The alligned memory allocation is only required for SSE, which
is currently unsupported. Moreover, it's better to use dedicated
_mm_malloc() and _mm_free() from xmmintrin.h instead, which are
introduced by Intel specifically for SIMD computations.

Change-Id: Ide764d1c643527323334ef14335be7f8915f7622
---
M src/viterbi.c
1 file changed, 1 insertion(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/55/2455/1

diff --git a/src/viterbi.c b/src/viterbi.c
index ea4fb21..21c6a57 100644
--- a/src/viterbi.c
+++ b/src/viterbi.c
@@ -29,7 +29,6 @@
 
 #define BIT2NRZ(REG,N) (((REG >> N) & 0x01) * 2 - 1) * -1
 #define NUM_STATES(K)  (K == 7 ? 64 : 16)
-#define SSE_ALIGN  16
 
 /* Forward Metric Units */
 void osmo_conv_gen_metrics_k5_n2(const int8_t *seq, const int16_t *out,
@@ -91,18 +90,10 @@
int16_t *, int16_t *, int);
 };
 
-/* Aligned Memory Allocator
- * SSE requires 16-byte memory alignment. We store relevant trellis values
- * (accumulated sums, outputs, and path decisions) as 16 bit signed integers
- * so the allocated memory is casted as such.
- */
+/* Non-aligned Memory Allocator */
 static int16_t *vdec_malloc(size_t n)
 {
-#ifdef HAVE_SSE3
-   return (int16_t *) memalign(SSE_ALIGN, sizeof(int16_t) * n);
-#else
return (int16_t *) malloc(sizeof(int16_t) * n);
-#endif
 }
 
 /* Accessor calls */

-- 
To view, visit https://gerrit.osmocom.org/2455
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide764d1c643527323334ef14335be7f8915f7622
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


libosmocore[master]: configure.ac: add SIMD detection capabilities

2017-05-01 Thread Vadim Yanitskiy

Patch Set 2:

After a little discussion with Alexander Chemeris,
the "--enable-simd" was replaced by "--disable-simd",
so now compile-time SIMD detection is enabled by default.

-- 
To view, visit https://gerrit.osmocom.org/2453
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Idf8fff984bd936a75c7c307338df88ba4b005817
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[PATCH] libosmocore[master]: core/conv: add x86 SSE support for Viterbi decoder

2017-05-01 Thread Vadim Yanitskiy
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2454

to look at the new patch set (#3).

core/conv: add x86 SSE support for Viterbi decoder

Fast convolutional decoding is provided through x86 intrinsic based
SSE operations. SSE3, found on virtually all modern x86 processors,
is the minimal requirement. SSE4.1 and AVX2 are used if available.

Also, the original code was extended with runtime SIMD detection,
so only supported extensions will be used by target CPU. It makes
the library more partable, what is very important for binary
packages distribution. The SIMD detection is currently implemented
through the __builtin_cpu_supports(EXT), which is only supported
by GCC.

Change-Id: I1da6d71ed0564f1d684f3a836e998d09de5f0351
---
M src/Makefile.am
M src/viterbi.c
M src/viterbi_gen.c
A src/viterbi_sse.c
4 files changed, 746 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/2454/3

diff --git a/src/Makefile.am b/src/Makefile.am
index 999436d..2f19838 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,6 +19,10 @@
 macaddr.c stat_item.c stats.c stats_statsd.c prim.c \
 viterbi.c viterbi_gen.c
 
+if HAVE_SSE3
+libosmocore_la_SOURCES += viterbi_sse.c
+endif
+
 BUILT_SOURCES = crc8gen.c crc16gen.c crc32gen.c crc64gen.c
 
 if ENABLE_PLUGIN
diff --git a/src/viterbi.c b/src/viterbi.c
index ea4fb21..d68db23 100644
--- a/src/viterbi.c
+++ b/src/viterbi.c
@@ -24,12 +24,34 @@
 #include 
 #include 
 
-#include 
 #include "config.h"
+
+#include 
 
 #define BIT2NRZ(REG,N) (((REG >> N) & 0x01) * 2 - 1) * -1
 #define NUM_STATES(K)  (K == 7 ? 64 : 16)
-#define SSE_ALIGN  16
+
+static int init_complete = 0;
+
+__attribute__ ((visibility("hidden"))) int avx2_supported = 0;
+__attribute__ ((visibility("hidden"))) int sse3_supported = 0;
+__attribute__ ((visibility("hidden"))) int sse41_supported = 0;
+
+/**
+ * This pointers will be initialized by the osmo_conv_init()
+ * depending on supported SIMD extensions.
+ */
+static int16_t *(*vdec_malloc)(size_t n);
+static void (*vdec_free)(int16_t *ptr);
+
+/* Forward malloc wrappers */
+int16_t *osmo_conv_vdec_malloc(size_t n);
+void osmo_conv_vdec_free(int16_t *ptr);
+
+#ifdef HAVE_SSE3
+int16_t *osmo_conv_vdec_malloc_sse3(size_t n);
+void osmo_conv_vdec_free_sse3(int16_t *ptr);
+#endif
 
 /* Forward Metric Units */
 void osmo_conv_gen_metrics_k5_n2(const int8_t *seq, const int16_t *out,
@@ -44,6 +66,21 @@
int16_t *sums, int16_t *paths, int norm);
 void osmo_conv_gen_metrics_k7_n4(const int8_t *seq, const int16_t *out,
int16_t *sums, int16_t *paths, int norm);
+
+#ifdef HAVE_SSE3
+void osmo_conv_gen_metrics_k5_n2_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k5_n3_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k5_n4_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n2_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n3_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n4_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+#endif
 
 /* Trellis State
  * state - Internal lshift register value
@@ -90,20 +127,6 @@
void (*metric_func)(const int8_t *, const int16_t *,
int16_t *, int16_t *, int);
 };
-
-/* Aligned Memory Allocator
- * SSE requires 16-byte memory alignment. We store relevant trellis values
- * (accumulated sums, outputs, and path decisions) as 16 bit signed integers
- * so the allocated memory is casted as such.
- */
-static int16_t *vdec_malloc(size_t n)
-{
-#ifdef HAVE_SSE3
-   return (int16_t *) memalign(SSE_ALIGN, sizeof(int16_t) * n);
-#else
-   return (int16_t *) malloc(sizeof(int16_t) * n);
-#endif
-}
 
 /* Accessor calls */
 static inline int conv_code_recursive(const struct osmo_conv_code *code)
@@ -303,9 +326,9 @@
if (!trellis)
return;
 
+   vdec_free(trellis->outputs);
+   vdec_free(trellis->sums);
free(trellis->vals);
-   free(trellis->outputs);
-   free(trellis->sums);
free(trellis);
 }
 
@@ -439,7 +462,7 @@
if (!dec)
return;
 
-   free(dec->paths[0]);
+   vdec_free(dec->paths[0]);
free(dec->paths);
free_trellis(dec->trellis);
free(dec);
@@ -465,13 +488,31 @@
if (dec->k == 5) {
switch (dec->n) {
case 2:
+   #ifdef HAVE_SSE3
+   dec->metric_func = !sse3_supported ?
+   osmo_conv_gen_metrics_k5_n2 :
+

libosmocore[master]: configure.ac: add SIMD detection capabilities

2017-05-01 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/2453
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Idf8fff984bd936a75c7c307338df88ba4b005817
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


libosmocore[master]: core/conv: add x86 SSE support for Viterbi decoder

2017-05-01 Thread Harald Welte

Patch Set 2: Code-Review+2

good idea to test with qemu!

-- 
To view, visit https://gerrit.osmocom.org/2454
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I1da6d71ed0564f1d684f3a836e998d09de5f0351
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No