core.simd woes

F i L witte2008 at gmail.com
Tue Oct 2 20:11:44 PDT 2012


jerro wrote:
> This code gives me internal compiler errors with GDC and DMD 
> too (with "float4 c = [1, 2, 3, 4]" commented out). I'm using 
> DMD 2.060 and a recent versions of GDC and LDC on 64 bit Linux.

Yes the SIMD situation isn't entirely usable right now with DMD 
and LDC. Only simple vector arithmetic is possible to my 
knowledge. The internal DMD error is actually from processing '(a 
+ b)' and returning it to writeln() without assigning to an 
separate float4 first.. for example, this compiles with DMD and 
outputs correctly:

     import core.simd, std.stdio;

     void main()
     {
         float4 a = 1, b = 2;
         float4 r = a + b;
         writeln(r.array);

         float4 c = [1, 2, 3, 4];
         float4 d = 1;

         c.array[0] = 4;
         c.ptr[1] = 4;
         r = c + d;
         writeln(r.array);
     }

correctly outputs:

     [3, 3, 3, 3]
     [5, 5, 4, 5]


I've never tried to do SIMD with GDC, though I understand it's 
done differently and core.simd XMM operations aren't supported 
(though I can't get them to work in DMD either... *sigh*). Take a 
look at Manu's std.simd library for reference on GDC SIMD 
support: 
https://github.com/TurkeyMan/phobos/blob/master/std/simd.d


More information about the Digitalmars-d mailing list