SIMD support...

Manu turkeyman at gmail.com
Fri Jan 6 12:45:15 PST 2012


On 6 January 2012 21:21, Walter Bright <newshound2 at digitalmars.com> wrote:

> 1. the language does typechecking, for example, trying to add a vector of
> 4 floats to 16 bytes would be (and should be) an error.
>

I want to sell you on the 'primitive SIMD regs are truly typeless' point.
(which I thought you had already agreed with) :)

Here are some examples of tight interacting between int/float, and
interacting ON floats with int operations...
Naturally the examples I present will be wrapped as useful functions in
libraries, but the primitive type shouldn't try and make this more annoying
by trying to enforce pointless type safety errors like you seem to be
suggesting.

In computer graphics it's common to work with float16's, a type not
supported by simd units. Pack/Unpack code involved detailed float/int
interaction.
You might take a register of floats, then mask the exponent and then
perform integer arithmetic on the exponent to shift it into the float16
exponent range... then you will mask the bottom of the mantissa and shift
them into place.
Unpacking is same process in reverse.

Other tricks with the float sign bits, making everything negative, by
or-ing in 1's into the top bits. or you can gather the signs using various
techniques.. useful for identifying the cell in a quad-tree for instance.
Integer manipulation of floats is surprisingly common.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120106/44f4c695/attachment.html>


More information about the Digitalmars-d mailing list