[Mono-list] SSE - more specifically fast vector support

d3x0r d3ck0r at gmail.com
Tue Oct 13 11:17:01 UTC 2015


d3x0r wrote
> [Acceleration (AccelMode.SSE1)]
> public void Mult ( float scalar, out Vector4f r )
> {
> /* actually this method was slower under mono; this is also fast under MS
> */
>      r.x = scalar * x; r.y = scalar * y; r.z = scalar * z; r.w = scalar *
> w;
> }

I guess 'out' parameters aren't passed by reference.  Changing out to ref... 

[Acceleration (AccelMode.SSE1)]
public void Mult ( float scalar, ref Vector4f r )
{
     r.x = scalar * x; r.y = scalar * y; r.z = scalar * z; r.w = scalar * w;
}

results in an increasd performance

operator mult = 17357
out mult = 10863
del = 62.5%

-----------
But; that means I can't use a math function to initialize a thing without
always creating a new one and copying that result  (out).

Vector4f v1, v2;

v1.Mult( 3.0f, out v2 ); // is valid because ti makes sure all members of v2
are initialized...
v1.Mult( 3.0f, ref v2 ); // is less-than valid because it may not be that
all members of v2 are initialized...


ref and out are the same performance under MS.




--
View this message in context: http://mono.1490590.n4.nabble.com/SSE-more-specifically-fast-vector-support-tp4666751p4666752.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list