3D Math Data structures/SIMD

Tomas Lindquist Olsen tomas at famolsen.dk
Sun Dec 23 16:49:36 PST 2007


Lukas Pinkowski wrote:
> I'm wondering why the 2D/3D/4D-vector and -matrix data types don't find
> their way into the mainstream programming languages as builtin types?
> The only that I know of that have builtin-support are the shader languages
> (HLSL, GLSL, Cg, ...) and I suppose the VectorC/C++-compiler. Instead the
> vector- and matrix-class is coded over and over again, with different
> 3D-libraries using their own implementation/interface.
> SIMD instructions are pretty 'old' now, but the compilers support them only
> through non-portable extensions, or handwritten assembly.
> 
> I think the programming language of the future should have those builtin
> instead of in myriads of libraries.
> 
> It would be nice if one of the Open Source D-compilers (GDC, LLVMDC) would
> implement such an extension to D in an experimental branch; don't know if
> it's easy to generate SIMD-code with the GCC backend, but LLVM is supposed
> to make it easy, right?
> Hopefully this extension could propagate after some time into the official D
> spec. Even if Walter won't touch the backend again, DMD could at least
> provide a software implementation (like for 64bit integer operations).
> 
> Seeing that D seems to be quite popular for game programming and numerics,
> this would be a nice addition.
> 
> Well, as for the typenames, I guess something along
> 
> v2f, v3f, v4f, m2f, m3f, m4f: vectors and matrices based on float
> v2d, v3d, v4d, m2d, m3d, m4d: vectors and matrices based on double
> v2r, v3r, v4r, m2r, m3r, m4r: vectors and matrices based on real
> 
> Or vec2f instead of v2f, mat2f instead of m2f, a.s.o. Complex versions would
> be probably needed, too?

I could definitely be interested in experimenting with this in LLVMDC. As LLVM already has 
quite good support for vector types as well as target specific intrinsics, most of the work 
would probably lie in the updating the frontend.

I would need some help with this though. I've only really looked properly at the frontend code 
if I had to figure out something in terms of code generation, there's still lots and lots of 
code in there I still don't know anything about...



More information about the Digitalmars-d mailing list