Vector performance

Manu turkeyman at gmail.com
Thu Jan 12 00:29:43 PST 2012


On 12 January 2012 02:46, F i L <witte2008 at gmail.com> wrote:

> Well the idea is you can have both. You could even have a:
>
>   Vector2!(Transition!(Vector4!(**Transition!float))) // headache
>   or something more practical...
>
>   Vector4!(Vector4!float) // Matrix4f
>   Vector4!(Transition!(Vector4!**float)) // Smooth Matrix4f
>
> Or anything like that. I should point out that my example didn't make it
> clear that a Matrix4!(Transition!float) would be pointless compared to
> Transition!(Matrix4!float) unless each Transition held it's own iteration
> value. Example:
>
>   struct Transition(T, bool isTimer = false) {
>
>       T value, start, target;
>       alias value this;
>
>       static if (isTimer) {
>           float time, speed;
>
>           void update() {
>               time += speed;
>               value = start + ((target - start) * time);
>           }
>       }
>   }
>
> That way each channel could update on it's own time frame. There may even
> be a way to have each channel be it's own separate Transition type. Which
> could be interesting. I'm still playing with possibilities.


The vector's aren't quite like that.. you can't make a hardware vector out
of anything, only things the hardware supports: __vector(float[4]) for
instance.
You can make your own vector template that wraps those I guess if you want
to make a matrix that way, but it sounds inefficient. When it comes to
writing the vector/matrix operations, if you're assuming generic code, you
won't be able to make it anywhere near as good as if you write a Matrix4x4
class.


I think that is also possible if that's what you want to do, and I see no
>> reason why any of these constructs wouldn't be efficient (or supported).
>> You can probably even try it out now with what Walter has already done...
>>
>
> Cool, I was unaware Walter had begun implementing SIMD operations. I'll
> have to build DMD and test them out. What's the syntax like right now?
>

The syntax for the types (supporting basic arithmetic) look like
__vector(float[4]) float4vector.. Try it on the latest GDC.


I was under the impression you would be helping him here, or that you would
> be building the SIMD-based math libraries. Or something like that. That's
> why I was posting my examples in question to how the std.simd lib would
> compare.
>

I know nothing of DMD. Then the type semantics and opcode intrinsics are
working, I'll happily write the fiddly library, and I'm using GDC for my
own experiment in the mean time while Walter works on the code gen.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120112/30a69493/attachment.html>


More information about the Digitalmars-d mailing list