Commit Graph

5 Commits

Author SHA1 Message Date
Pau Espin f7331764ac SigProcLib: Improve Vector buffer allocation mess
Original issue: In order to use SSE instructions, 16-byte aligned memory
chunks are needed, and C++ version < C++11 doesn't provide for a native
new/delete store. For that reason, memalign() must be used in the
implementation of convolve_h_alloc() for some buffers.
On the other side, The C++ code relies on C++ "new T[]" operator to
allocate a chunk of memory containing an array of class instances. As
classes are complex types, they cannot be allocated through C structures
(calling malloc). Experimentally can be seen too that it's unreliable
and the process will crash during startup if malloc() is used and then a
Complex<> deferred from it.

Previous implementation allowed for use of convolve_h_alloc or new[]
based on how the (signal)Vector is called, because then the buffer is
not going to be managed internally. But that's unreliable since resize()
calling resize() on it could use "delete" operator on a malloc'ed
buffer, and end up having a new new[] allocated buffer. It was also
found that some of the callers were actually leaking memory through ASan (because the
buffer is not managed by the Vector instance).

IMHO best option would be to rewrite all this code using C structures
and malloc/free exclusively, since it would make all this cod eeasier to
maintain.

But for now, let's extend the Vector class to allow specifying an
external alloc/free function and let the Vector instance take care of
the ownership of the buffer in all scenarios.

Change-Id: Ie484a4762a7f77fe1b105188ea03a6f025730b82
2018-12-05 19:41:34 +00:00
Alexander Chemeris e56bf3a0e5 signalVector: Implement segment().
Change-Id: I6fe3aae53fb2fa5bb7637e976de6059eabe08202
2017-03-24 01:22:40 +00:00
Tom Tsou 28670fb5da iface: Add inner ring-buffer implementation
Two buffers, inner and outer, are used in the transceiver
implementation. The outer buffer interfaces with the device receive
interface to guarantee timestamp aligned and contiguously allocated
sample buffers. The inner buffer absorbs vector size differences between
GSM bursts (156 or 157 samples) and the resampler interface (typically
fixed multiples of 65).

Reimplement the inner buffer with a ring buffer that allows fixed size
segments on the outer (resampler) portion and variable lengths (GSM
side) on the inner side. Compared to the previous stack-like version,
this implementation removes unnecessary copying of buffer contents.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-01 03:03:11 -07:00
Thomas Tsou 3f32ab5afa Transceiver52M: Enable all warnings and resolve
Mainly basic signed vs unsigned comparisons and intializer ordering.

Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-11-15 23:35:07 -05:00
Thomas Tsou 20eb6d64fd Transceiver52M: Separate signalVector into it's own file
Break out the signalVector object and clean up the interface in the
process.

Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-11-15 23:35:07 -05:00