Boost logo

Boost :

Subject: Re: [boost] [endian] swap_in_place use case
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-06-05 04:08:20


----- Original Message -----
From: "Michael Caisse" <boost_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, June 04, 2010 8:37 PM
Subject: Re: [boost] [endian] swap_in_place use case

vicente.botet wrote:
> Hi,
>
> I'm looking for a use case where the use of swap_in_place (or whatever is renamed) is not followed/preceded by a copy.

<snip>

> Can somene help me to identify a real use case on which the swap_in_place can be used to reveive a message, without needing to do any additional copy from the swapped buffer to native data?
>

Hello Vicente -

I hope you are doing well. It was a pleasure to meet you at boostcon.

I think one problem might be the focus on "messaging" as the reason for
endian swapping. Granted, that is a large use case and one that I
suspect most of us use. I also do a fair amount of swapping of
bytes/bits in signal processing work. Typically I have received some
signal via a DMA transfer and now need to operate on it. As much as
possible this is done in-place.

Typical operations include changing the endian to match the processor.
For example, many PCM codecs will result in a little endian audio
signal; however, most of my favorite processors are big endian. The swap
will be in-place.

Another typical operation is time decimation for a Fourier transform
which is basically bit-reversal of the indexes. This is also in-place.

Even my messaging for these small embedded processors is in-place. I
just don't have the memory nor cycles to make copies. A message is
formed in memory. It is "transformed" to the right endian and then the
buffer is sent to a DMA engine.

I could provide dozens of use-cases of in-place endian transforms. Just
start thinking little to no memory and not a lot of processor cycles and
you can come up with a bunch.

Hope this helps a little. The endian library is of great interest to me.
I'm reading all of the email traffic but don't have the time right yet
to jump into the discussion.

michael
______________________________________________

Hi Michael,

thanks for all your use cases. Your use cases and the ones of Dave Handley help a lot.
I see swap_in_place could be inevitable in some cases in particular when receiving some information. It is less the case for sending information. As you say "A message is formed in memory. It is 'transformed' to the right endian and then the buffer is sent to a DMA engine". The key here is the message is "formed in memory". I guess we can "form in memory" with the correct endianess, and avoid the swap.

Anyway. swap_in_place is needed. This was just what I was looking to answer.

Thanks,
Vicente

(Ah it was a pleasure to me too).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk