SIMD support...

Manu turkeyman at gmail.com
Fri Jan 6 11:08:36 PST 2012


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

> On 1/6/2012 6:05 AM, Manu wrote:
>
>> On 6 January 2012 08:22, Walter Bright <newshound2 at digitalmars.com
>> <mailto:newshound2@**digitalmars.com <newshound2 at digitalmars.com>>>
>> wrote:
>>
>>    On 1/5/2012 7:42 PM, Manu wrote:
>>
>>        Perhaps I misunderstand, I can't see the problem?
>>        In the function preamble, you just align it... something like:
>>           mov reg, esp ; take a backup of the stack pointer
>>           and esp, -16 ; align it
>>
>>        ... function
>>
>>           mov esp, reg ; restore the stack pointer
>>           ret 0
>>
>>
>>    And now you cannot access the function's parameters anymore, because
>> the
>>    stack offset for them is now variable rather than fixed.
>>
>>
>> Hehe, true, but not insurmountable. Scheduling of parameter pops before
>> you
>> perform the alignment may solve that straight up, or else don't align esp
>> its
>> self; store the vector to the stack through some other aligned reg copied
>> from
>> esp...
>>
>> I just wrote some test functions using __m128 in VisualC, it seems to do
>> something in between the simplicity of my initial suggestion, and my
>> refined
>> ideas one above :)
>> If you have VisualC, check out what it does, it's very simple, looks
>> pretty
>> good, and I'm sure it's optimal (MS have enough R&D money to assure this)
>>
>> I can paste some disassemblies if you don't have VC...
>>
>
> I don't have VC. I had thought of using an extra level of indirection for
> all the aligned stuff, essentially rewrite:
>
>    v128 v;
>    v = x;
>
> with:
>
>    v128 v; // goes in aligned stack
>    v128 *pv = &v;  // pv is in regular stack
>    *pv = x;
>
> but there are still complexities with it, like spilling aligned temps to
> the stack.
>

I think we should take this conversation to IRC, or a separate thread?
I'll generate some examples from VC for you in various situations. If you
can write me a short list of trouble cases as you see them, I'll make sure
to address them specifically...
Have you tested the code that GCC produces? I'm sure it'll be identical to
VC...

That said, how do you currently support ANY aligned type? I thought
align(n) was a defined keyword in D?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120106/b98aba6f/attachment.html>


More information about the Digitalmars-d mailing list