1

Does anyone how to do control flow with the Mono.Simd namespace. For example, break if all elements in a vector match some condition relative to another vector. e.g.

var y= Vector2d(1,2);
var x=Vector2d(3,4):
if(y<x)//compare less than, true for both???
//Do something…

I gather SSE has a movmskps instruction that is useful, and there are comparison functions, but they create bit masks which I am not sure how/how-best to utilize with C#.

4

1 回答 1

2

Mono 提供了一个名为的包装器ExtractByteMask,您可以将其用于此目的。请注意,您应该尽可能避免流量控制。

var y = new Vector2d(1,2);
var x = new Vector2d(3,4);
if (VectorOperations.ExtractByteMask((Vector16sb)VectorOperations.CompareLessThan(y, x)) == 0xffff)
{
    Console.WriteLine("All components passed the comparison");
}

如果您有兴趣,这里是一段生成的代码:

1062:       66 0f c2 c1 01          cmpltpd %xmm1,%xmm0
1067:       66 0f d7 c0             pmovmskb %xmm0,%eax
106b:       3d ff ff 00 00          cmp    $0xffff,%eax
1070:       75 0c                   jne    107e <Sample_Main+0x5e>
于 2013-09-12T12:30:37.180 回答