Any usable SIMD implementation?
Marco Leise via Digitalmars-d
digitalmars-d at puremagic.com
Sat Apr 16 14:40:44 PDT 2016
Am Tue, 12 Apr 2016 23:22:37 -0700
schrieb Walter Bright <newshound2 at digitalmars.com>:
> > "mulq %[y]"
> > : "=a" tmp.lo, "=d" tmp.hi : "a" x, [y] "rm" y;
>
> I don't see anything elegant about those lines, starting with "mulq" is not in
> any of the AMD or Intel CPU manuals. The assembler should notice that 'y' is a
> ulong and select the 64 bit version of the MUL opcode automatically.
>
> I can see nothing to recommend the:
>
> "=a" tmp.lo
>
> syntax. How about something comprehensible like "tmp.lo = EAX"? I bet people
> could even figure that out without consulting stackoverflow! :-)
>
> I have no idea what:
>
> "a" x
>
> and:
>
> [y] "rm" y
>
> mean, nor why the ":" appears sometimes and the "," other times.
Tell me again, what's more elgant !
uint* pnb = cast(uint*)cf.processorNameBuffer.ptr;
version(GNU)
{
asm { "cpuid" : "=a" pnb[0], "=b" pnb[1], "=c" pnb[ 2], "=d" pnb[ 3] : "a" 0x8000_0002; }
asm { "cpuid" : "=a" pnb[4], "=b" pnb[5], "=c" pnb[ 6], "=d" pnb[ 7] : "a" 0x8000_0003; }
asm { "cpuid" : "=a" pnb[8], "=b" pnb[9], "=c" pnb[10], "=d" pnb[11] : "a" 0x8000_0004; }
}
else version(D_InlineAsm_X86)
{
asm pure nothrow @nogc {
push ESI;
mov ESI, pnb;
mov EAX, 0x8000_0002;
cpuid;
mov [ESI], EAX;
mov [ESI+4], EBX;
mov [ESI+8], ECX;
mov [ESI+12], EDX;
mov EAX, 0x8000_0003;
cpuid;
mov [ESI+16], EAX;
mov [ESI+20], EBX;
mov [ESI+24], ECX;
mov [ESI+28], EDX;
mov EAX, 0x8000_0004;
cpuid;
mov [ESI+32], EAX;
mov [ESI+36], EBX;
mov [ESI+40], ECX;
mov [ESI+44], EDX;
pop ESI;
}
}
else version(D_InlineAsm_X86_64)
{
asm pure nothrow @nogc {
push RSI;
mov RSI, pnb;
mov EAX, 0x8000_0002;
cpuid;
mov [RSI], EAX;
mov [RSI+4], EBX;
mov [RSI+8], ECX;
mov [RSI+12], EDX;
mov EAX, 0x8000_0003;
cpuid;
mov [RSI+16], EAX;
mov [RSI+20], EBX;
mov [RSI+24], ECX;
mov [RSI+28], EDX;
mov EAX, 0x8000_0004;
cpuid;
mov [RSI+32], EAX;
mov [RSI+36], EBX;
mov [RSI+40], ECX;
mov [RSI+44], EDX;
pop RSI;
}
}
--
Marco
More information about the Digitalmars-d
mailing list