Question about Vectors
Marco Leise via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Nov 21 08:01:22 PST 2014
Am Thu, 20 Nov 2014 20:17:31 +0000
schrieb "Charles" <csmith.ku2013 at gmail.com>:
> So I was reading the documentation page:
> http://dlang.org/simd.html and noticed what appears to be a typo:
>
> int4 v;
> (cast(int*)&v)[3] = 2; // set 3rd element of the 4 int vector
> (cast(int[4])v)[3] = 2; // set 3rd element of the 4 int vector
> v.array[3] = 2; // set 3rd element of the 4 int vector
> v.ptr[3] = 2; // set 3rd element of the 4 int vector
>
> v.array[3] = 2; and v.ptr[3] = 2; set the fourth element, and not
> the third.
>
> As I was verifying this, I realized I had to compile it in 64 bit
> code. The 32 bit code produced the error "SIMD vector types not
> supported on this platform".
>
> My test code is:
>
> void main() {
> import std.stdio;
> import core.simd;
>
> int4 v = 7;
> v.ptr[3] = 2;
> writeln(v.array[]);
> }
>
>
> Is that related to me compiling while using a 64 bit OS, or is
> that true of any 32 bit OS, and thus, vectors can't be used in
> programs intended to be run on 32 bit OSs?
>
> Thanks,
> Charles
DMD supports SIMD only on amd64, but you can use the GDC or
LDC2 compilers if you need 32-bit support for vector types.
--
Marco
More information about the Digitalmars-d-learn
mailing list