suggestion: basic SIMD types modelled after Cg/HLSL

mclysenk at mtu.edu mclysenk at mtu.edu
Fri Jul 14 00:12:22 PDT 2006


In article <e93n8a$27cl$1 at digitaldaemon.com>, cschueler says...
>
>
>Hi list,
>I'll throw in a suggestion for extending D when no other worries are left over.
>
>Why not incorporate the 4-way SIMD (single instruction multiple data) vectors,
>which are available in hardware by now on virtually every platform, by means of
>builtin types in the same syntax as in Cg (Nvidia's C for graphics) resp. HLSL
>(high-level shading language).
>


In my opinion, this feature belongs in a library - not in the language spec.  CG
is totally different in design and scope from D, because shaders are a very
different problem domain than system programs.

The real issue with a vectors is there is no one-size solution.  Most everyone
can agree on simle stuff like vector addition or scalar multiplication, but what
about vector-vector products?  Hardware can easily do a full per-component
multiply or a dot product, and both have equal claim to the * operator.  What
about cross products?  Throwing aside issues like handedness, they only exist in
3 dimensions - which means they will cause headaches with 2d and 4d vectors.  A
nice mathematical solution is geometric algebra, however it is hardly
'efficient.'  Matrix multiplication is also full of traps, since there are so
many different kinds of inner, outer and tensor products.

Ultimately any simple language solution will cause more trouble than its worth.
However, a library would be more than flexible enough to implement any sort of
vector routine, especially with incipient features like implicit template
instantion.

-Mik





More information about the Digitalmars-d mailing list