// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AddDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Add)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Add)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AddSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Add)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Add)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddSubtractDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AddSubtractDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSubtractDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((i % 2 != 0) && (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i]))))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AddSubtract)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AddSubtract)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddSubtractSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AddSubtractSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSubtractSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((i % 2 != 0) && (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i]))))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AddSubtract)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AddSubtract)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AndDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.And)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.And)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AndSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[i]) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.And)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.And)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AndNotDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((~BitConverter.DoubleToInt64Bits(left[i])) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AndNot)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AndNot)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AndNotSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((~BitConverter.SingleToInt32Bits(left[i])) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AndNot)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AndNot)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
<Compile Include="Add.Double.cs" />
<Compile Include="Add.Single.cs" />
<Compile Include="AddSubtract.Double.cs" />
- <Compile Include="AddSubtract.Single.cs" />
+ <Compile Include="AddSubtract.Single.cs" />
<Compile Include="And.Double.cs" />
<Compile Include="And.Single.cs" />
<Compile Include="AndNot.Double.cs" />
<Compile Include="AndNot.Single.cs" />
<Compile Include="BlendVariable.Double.cs" />
- <Compile Include="BlendVariable.Single.cs" />
+ <Compile Include="BlendVariable.Single.cs" />
+ <Compile Include="Divide.Double.cs"/>
+ <Compile Include="Divide.Single.cs"/>
<Compile Include="DuplicateEvenIndexed.Double.cs" />
- <Compile Include="DuplicateEvenIndexed.Single.cs" />
- <Compile Include="DuplicateOddIndexed.Single.cs" />
+ <Compile Include="DuplicateEvenIndexed.Single.cs" />
+ <Compile Include="DuplicateOddIndexed.Single.cs" />
<Compile Include="Max.Double.cs" />
<Compile Include="Max.Single.cs" />
<Compile Include="Min.Double.cs" />
<Compile Include="Min.Single.cs" />
<Compile Include="Multiply.Double.cs" />
<Compile Include="Multiply.Single.cs" />
+ <Compile Include="Or.Double.cs"/>
+ <Compile Include="Or.Single.cs"/>
<Compile Include="Subtract.Double.cs" />
<Compile Include="Subtract.Single.cs" />
<Compile Include="Xor.Double.cs"/>
<Compile Include="Xor.Single.cs"/>
- <Compile Include="Divide.Double.cs"/>
- <Compile Include="Divide.Single.cs"/>
- <Compile Include="Or.Double.cs"/>
- <Compile Include="Or.Single.cs"/>
<Compile Include="Program.Avx.cs" />
<Compile Include="..\Shared\Program.cs" />
<Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" />
<Compile Include="Add.Double.cs" />
<Compile Include="Add.Single.cs" />
<Compile Include="AddSubtract.Double.cs" />
- <Compile Include="AddSubtract.Single.cs" />
+ <Compile Include="AddSubtract.Single.cs" />
<Compile Include="And.Double.cs" />
<Compile Include="And.Single.cs" />
<Compile Include="AndNot.Double.cs" />
<Compile Include="AndNot.Single.cs" />
<Compile Include="BlendVariable.Double.cs" />
- <Compile Include="BlendVariable.Single.cs" />
+ <Compile Include="BlendVariable.Single.cs" />
+ <Compile Include="Divide.Double.cs"/>
+ <Compile Include="Divide.Single.cs"/>
<Compile Include="DuplicateEvenIndexed.Double.cs" />
- <Compile Include="DuplicateEvenIndexed.Single.cs" />
- <Compile Include="DuplicateOddIndexed.Single.cs" />
+ <Compile Include="DuplicateEvenIndexed.Single.cs" />
+ <Compile Include="DuplicateOddIndexed.Single.cs" />
<Compile Include="Max.Double.cs" />
<Compile Include="Max.Single.cs" />
<Compile Include="Min.Double.cs" />
<Compile Include="Min.Single.cs" />
<Compile Include="Multiply.Double.cs" />
<Compile Include="Multiply.Single.cs" />
+ <Compile Include="Or.Double.cs"/>
+ <Compile Include="Or.Single.cs"/>
<Compile Include="Subtract.Double.cs" />
<Compile Include="Subtract.Single.cs" />
<Compile Include="Xor.Double.cs"/>
<Compile Include="Xor.Single.cs"/>
- <Compile Include="Divide.Double.cs"/>
- <Compile Include="Divide.Single.cs"/>
- <Compile Include="Or.Double.cs"/>
- <Compile Include="Or.Single.cs"/>
<Compile Include="Program.Avx.cs" />
<Compile Include="..\Shared\Program.cs" />
<Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" />
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleTernaryOpTest__BlendVariableDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
- private static Double[] _data3 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int Op3ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
+ private static Double[] _data3 = new Double[Op3ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld2;
private Vector256<Double> _fld3;
- private SimpleTernaryOpTest__DataTable<Double> _dataTable;
+ private SimpleTernaryOpTest__DataTable<Double, Double, Double, Double> _dataTable;
static SimpleTernaryOpTest__BlendVariableDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar3), ref Unsafe.As<Double, byte>(ref _data3[0]), VectorSize);
}
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld3), ref Unsafe.As<Double, byte>(ref _data3[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
- _dataTable = new SimpleTernaryOpTest__DataTable<Double>(_data1, _data2, _data3, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
+ _dataTable = new SimpleTernaryOpTest__DataTable<Double, Double, Double, Double>(_data1, _data2, _data3, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> firstOp, Vector256<Double> secondOp, Vector256<Double> thirdOp, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] inArray3 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] inArray3 = new Double[Op3ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), firstOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), secondOp);
private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] inArray3 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] inArray3 = new Double[Op3ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((BitConverter.DoubleToInt64Bits(thirdOp[i]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[i]) != BitConverter.DoubleToInt64Bits(result[i]) : BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.BlendVariable)}<Double>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.BlendVariable)}<Double>(Vector256<Double>, Vector256<Double>, Vector256<Double>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
Console.WriteLine($" thirdOp: ({string.Join(", ", thirdOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleTernaryOpTest__BlendVariableSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
- private static Single[] _data3 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int Op3ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
+ private static Single[] _data3 = new Single[Op3ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld2;
private Vector256<Single> _fld3;
- private SimpleTernaryOpTest__DataTable<Single> _dataTable;
+ private SimpleTernaryOpTest__DataTable<Single, Single, Single, Single> _dataTable;
static SimpleTernaryOpTest__BlendVariableSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar3), ref Unsafe.As<Single, byte>(ref _data3[0]), VectorSize);
}
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld3), ref Unsafe.As<Single, byte>(ref _data3[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
- _dataTable = new SimpleTernaryOpTest__DataTable<Single>(_data1, _data2, _data3, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
+ _dataTable = new SimpleTernaryOpTest__DataTable<Single, Single, Single, Single>(_data1, _data2, _data3, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> firstOp, Vector256<Single> secondOp, Vector256<Single> thirdOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] inArray3 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] inArray3 = new Single[Op3ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), firstOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), secondOp);
private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] inArray3 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] inArray3 = new Single[Op3ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((BitConverter.SingleToInt32Bits(thirdOp[i]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[i]) != BitConverter.SingleToInt32Bits(result[i]) : BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.BlendVariable)}<Single>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.BlendVariable)}<Single>(Vector256<Single>, Vector256<Single>, Vector256<Single>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
Console.WriteLine($" thirdOp: ({string.Join(", ", thirdOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__DivideDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__DivideDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__DivideDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Divide)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Divide)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__DivideSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__DivideSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__DivideSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Divide)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Divide)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleUnaryOpTest__DuplicateEvenIndexedDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data = new Double[Op1ElementCount];
private static Vector256<Double> _clsVar;
private Vector256<Double> _fld;
- private SimpleUnaryOpTest__DataTable<Double> _dataTable;
+ private SimpleUnaryOpTest__DataTable<Double, Double> _dataTable;
static SimpleUnaryOpTest__DuplicateEvenIndexedDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
}
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleUnaryOpTest__DataTable<Double>(_data, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleUnaryOpTest__DataTable<Double, Double>(_data, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> firstOp, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray = new Double[Op1ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray = new Double[Op1ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((i % 2 == 0) ? (BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])) : (BitConverter.DoubleToInt64Bits(firstOp[i - 1]) != BitConverter.DoubleToInt64Bits(result[i])))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateEvenIndexed)}<Double>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateEvenIndexed)}<Double>(Vector256<Double>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleUnaryOpTest__DuplicateEvenIndexedSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data = new Single[Op1ElementCount];
private static Vector256<Single> _clsVar;
private Vector256<Single> _fld;
- private SimpleUnaryOpTest__DataTable<Single> _dataTable;
+ private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
static SimpleUnaryOpTest__DuplicateEvenIndexedSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
}
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleUnaryOpTest__DataTable<Single>(_data, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleUnaryOpTest__DataTable<Single, Single>(_data, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray = new Single[Op1ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray = new Single[Op1ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i - 1]) != BitConverter.SingleToInt32Bits(result[i])))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateEvenIndexed)}<Single>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateEvenIndexed)}<Single>(Vector256<Single>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleUnaryOpTest__DuplicateOddIndexedSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data = new Single[Op1ElementCount];
private static Vector256<Single> _clsVar;
private Vector256<Single> _fld;
- private SimpleUnaryOpTest__DataTable<Single> _dataTable;
+ private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
static SimpleUnaryOpTest__DuplicateOddIndexedSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
}
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleUnaryOpTest__DataTable<Single>(_data, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleUnaryOpTest__DataTable<Single, Single>(_data, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray = new Single[Op1ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray = new Single[Op1ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i + 1]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateOddIndexed)}<Single>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateOddIndexed)}<Single>(Vector256<Single>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MaxDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MaxDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Max)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Max)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MaxSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MaxSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(MathF.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Max)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Max)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MinDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MinDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Min)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Min)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MinSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MinSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(MathF.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Min)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Min)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MultiplyDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MultiplyDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MultiplyDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Multiply)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Multiply)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MultiplySingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MultiplySingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MultiplySingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Multiply)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Multiply)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__OrDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Or)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Or)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__OrSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[i]) | BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Or)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Or)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
["AndNot.Single"] = AndNotSingle,
["BlendVariable.Double"] = BlendVariableDouble,
["BlendVariable.Single"] = BlendVariableSingle,
+ ["Divide.Double"] = DivideDouble,
+ ["Divide.Single"] = DivideSingle,
["DuplicateEvenIndexed.Double"] = DuplicateEvenIndexedDouble,
["DuplicateEvenIndexed.Single"] = DuplicateEvenIndexedSingle,
["DuplicateOddIndexed.Single"] = DuplicateOddIndexedSingle,
- ["Divide.Double"] = DivideDouble,
- ["Divide.Single"] = DivideSingle,
["Max.Double"] = MaxDouble,
["Max.Single"] = MaxSingle,
["Min.Double"] = MinDouble,
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__SubtractDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Subtract)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Subtract)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__SubtractSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Subtract)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Subtract)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__XorDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Xor)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Xor)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__XorSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[i]) ^ BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Xor)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Xor)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector256<Byte> _clsVar1;
private static Vector256<Byte> _clsVar2;
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AddByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector256<Int16> _clsVar1;
private static Vector256<Int16> _clsVar2;
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AddInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector256<Int32> _clsVar1;
private static Vector256<Int32> _clsVar2;
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AddInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector256<Int64> _clsVar1;
private static Vector256<Int64> _clsVar2;
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AddInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector256<SByte> _clsVar1;
private static Vector256<SByte> _clsVar2;
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AddSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector256<UInt16> _clsVar1;
private static Vector256<UInt16> _clsVar2;
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AddUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector256<UInt32> _clsVar1;
private static Vector256<UInt32> _clsVar2;
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AddUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector256<UInt64> _clsVar1;
private static Vector256<UInt64> _clsVar2;
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AddUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<UInt64>(Vector256<UInt64>, Vector256<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector256<Byte> _clsVar1;
private static Vector256<Byte> _clsVar2;
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AndByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector256<Int16> _clsVar1;
private static Vector256<Int16> _clsVar2;
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AndInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector256<Int32> _clsVar1;
private static Vector256<Int32> _clsVar2;
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AndInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector256<Int64> _clsVar1;
private static Vector256<Int64> _clsVar2;
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AndInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector256<SByte> _clsVar1;
private static Vector256<SByte> _clsVar2;
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AndSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector256<UInt16> _clsVar1;
private static Vector256<UInt16> _clsVar2;
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AndUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector256<UInt32> _clsVar1;
private static Vector256<UInt32> _clsVar2;
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AndUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector256<UInt64> _clsVar1;
private static Vector256<UInt64> _clsVar2;
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AndUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<UInt64>(Vector256<UInt64>, Vector256<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector256<Byte> _clsVar1;
private static Vector256<Byte> _clsVar2;
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AndNotByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector256<Int16> _clsVar1;
private static Vector256<Int16> _clsVar2;
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AndNotInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector256<Int32> _clsVar1;
private static Vector256<Int32> _clsVar2;
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AndNotInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector256<Int64> _clsVar1;
private static Vector256<Int64> _clsVar2;
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AndNotInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector256<SByte> _clsVar1;
private static Vector256<SByte> _clsVar2;
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AndNotSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector256<UInt16> _clsVar1;
private static Vector256<UInt16> _clsVar2;
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AndNotUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector256<UInt32> _clsVar1;
private static Vector256<UInt32> _clsVar2;
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AndNotUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector256<UInt64> _clsVar1;
private static Vector256<UInt64> _clsVar2;
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AndNotUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<UInt64>(Vector256<UInt64>, Vector256<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AverageByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector256<Byte> _clsVar1;
private static Vector256<Byte> _clsVar2;
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AverageByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AverageByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)((left[i] + right[i] + 1) >> 1) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Average)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Average)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AverageUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector256<UInt16> _clsVar1;
private static Vector256<UInt16> _clsVar2;
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AverageUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AverageUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)((left[i] + right[i] + 1) >> 1) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Average)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Average)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleTernaryOpTest__BlendVariableByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
- private static Byte[] _data3 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int Op3ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
+ private static Byte[] _data3 = new Byte[Op3ElementCount];
private static Vector256<Byte> _clsVar1;
private static Vector256<Byte> _clsVar2;
private Vector256<Byte> _fld2;
private Vector256<Byte> _fld3;
- private SimpleTernaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleTernaryOpTest__DataTable<Byte, Byte, Byte, Byte> _dataTable;
static SimpleTernaryOpTest__BlendVariableByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar3), ref Unsafe.As<Byte, byte>(ref _data3[0]), VectorSize);
}
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld3), ref Unsafe.As<Byte, byte>(ref _data3[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
- _dataTable = new SimpleTernaryOpTest__DataTable<Byte>(_data1, _data2, _data3, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
+ _dataTable = new SimpleTernaryOpTest__DataTable<Byte, Byte, Byte, Byte>(_data1, _data2, _data3, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Byte> firstOp, Vector256<Byte> secondOp, Vector256<Byte> thirdOp, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] inArray3 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] inArray3 = new Byte[Op3ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), firstOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), secondOp);
private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] inArray3 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] inArray3 = new Byte[Op3ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.BlendVariable)}<Byte>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.BlendVariable)}<Byte>(Vector256<Byte>, Vector256<Byte>, Vector256<Byte>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
Console.WriteLine($" thirdOp: ({string.Join(", ", thirdOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleTernaryOpTest__BlendVariableSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
- private static SByte[] _data3 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int Op3ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
+ private static SByte[] _data3 = new SByte[Op3ElementCount];
private static Vector256<SByte> _clsVar1;
private static Vector256<SByte> _clsVar2;
private Vector256<SByte> _fld2;
private Vector256<SByte> _fld3;
- private SimpleTernaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleTernaryOpTest__DataTable<SByte, SByte, SByte, SByte> _dataTable;
static SimpleTernaryOpTest__BlendVariableSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar3), ref Unsafe.As<SByte, byte>(ref _data3[0]), VectorSize);
}
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld3), ref Unsafe.As<SByte, byte>(ref _data3[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
- _dataTable = new SimpleTernaryOpTest__DataTable<SByte>(_data1, _data2, _data3, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
+ _dataTable = new SimpleTernaryOpTest__DataTable<SByte, SByte, SByte, SByte>(_data1, _data2, _data3, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<SByte> firstOp, Vector256<SByte> secondOp, Vector256<SByte> thirdOp, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] inArray3 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] inArray3 = new SByte[Op3ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), firstOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), secondOp);
private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] inArray3 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] inArray3 = new SByte[Op3ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.BlendVariable)}<SByte>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.BlendVariable)}<SByte>(Vector256<SByte>, Vector256<SByte>, Vector256<SByte>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
Console.WriteLine($" thirdOp: ({string.Join(", ", thirdOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector256<Byte> _clsVar1;
private static Vector256<Byte> _clsVar2;
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__CompareEqualByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector256<Int16> _clsVar1;
private static Vector256<Int16> _clsVar2;
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector256<Int32> _clsVar1;
private static Vector256<Int32> _clsVar2;
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector256<Int64> _clsVar1;
private static Vector256<Int64> _clsVar2;
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector256<SByte> _clsVar1;
private static Vector256<SByte> _clsVar2;
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__CompareEqualSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector256<UInt16> _clsVar1;
private static Vector256<UInt16> _clsVar2;
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector256<UInt32> _clsVar1;
private static Vector256<UInt32> _clsVar2;
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector256<UInt64> _clsVar1;
private static Vector256<UInt64> _clsVar2;
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<UInt64>(Vector256<UInt64>, Vector256<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector256<Int16> _clsVar1;
private static Vector256<Int16> _clsVar2;
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector256<Int32> _clsVar1;
private static Vector256<Int32> _clsVar2;
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector256<Int64> _clsVar1;
private static Vector256<Int64> _clsVar2;
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector256<SByte> _clsVar1;
private static Vector256<SByte> _clsVar2;
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector256<Byte> _clsVar1;
private static Vector256<Byte> _clsVar2;
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__OrByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector256<Int16> _clsVar1;
private static Vector256<Int16> _clsVar2;
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__OrInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector256<Int32> _clsVar1;
private static Vector256<Int32> _clsVar2;
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__OrInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector256<Int64> _clsVar1;
private static Vector256<Int64> _clsVar2;
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__OrInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector256<SByte> _clsVar1;
private static Vector256<SByte> _clsVar2;
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__OrSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector256<UInt16> _clsVar1;
private static Vector256<UInt16> _clsVar2;
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__OrUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector256<UInt32> _clsVar1;
private static Vector256<UInt32> _clsVar2;
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__OrUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector256<UInt64> _clsVar1;
private static Vector256<UInt64> _clsVar2;
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__OrUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<UInt64>(Vector256<UInt64>, Vector256<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
["AndNot.UInt64"] = AndNotUInt64,
["Average.Byte"] = AverageByte,
["Average.UInt16"] = AverageUInt16,
+ ["BlendVariable.Byte"] = BlendVariableByte,
+ ["BlendVariable.SByte"] = BlendVariableSByte,
["CompareEqual.Byte"] = CompareEqualByte,
["CompareEqual.Int16"] = CompareEqualInt16,
["CompareEqual.Int32"] = CompareEqualInt32,
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector256<Byte> _clsVar1;
private static Vector256<Byte> _clsVar2;
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__SubtractByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector256<Int16> _clsVar1;
private static Vector256<Int16> _clsVar2;
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__SubtractInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector256<Int32> _clsVar1;
private static Vector256<Int32> _clsVar2;
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__SubtractInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector256<Int64> _clsVar1;
private static Vector256<Int64> _clsVar2;
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__SubtractInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector256<SByte> _clsVar1;
private static Vector256<SByte> _clsVar2;
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__SubtractSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector256<UInt16> _clsVar1;
private static Vector256<UInt16> _clsVar2;
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__SubtractUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector256<UInt32> _clsVar1;
private static Vector256<UInt32> _clsVar2;
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__SubtractUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector256<UInt64> _clsVar1;
private static Vector256<UInt64> _clsVar2;
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__SubtractUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<UInt64>(Vector256<UInt64>, Vector256<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector256<Byte> _clsVar1;
private static Vector256<Byte> _clsVar2;
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__XorByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector256<Int16> _clsVar1;
private static Vector256<Int16> _clsVar2;
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__XorInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector256<Int32> _clsVar1;
private static Vector256<Int32> _clsVar2;
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__XorInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector256<Int64> _clsVar1;
private static Vector256<Int64> _clsVar2;
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__XorInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector256<SByte> _clsVar1;
private static Vector256<SByte> _clsVar2;
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__XorSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector256<UInt16> _clsVar1;
private static Vector256<UInt16> _clsVar2;
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__XorUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector256<UInt32> _clsVar1;
private static Vector256<UInt32> _clsVar2;
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__XorUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector256<UInt64> _clsVar1;
private static Vector256<UInt64> _clsVar2;
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__XorUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<UInt64>(Vector256<UInt64>, Vector256<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{{
public static partial class Program
{{
- private static void {2}{3}()
+ private static void {2}{4}()
{{
- var test = new BooleanComparisonOpTest__{2}{3}();
+ var test = new BooleanComparisonOpTest__{2}{4}();
if (test.IsSupported)
{{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }}
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }}
// Validates passing the field of a local works
test.RunLclFldScenario();
}}
}}
- public sealed unsafe class BooleanComparisonOpTest__{2}{3}
+ public sealed unsafe class BooleanComparisonOpTest__{2}{4}
{{
- private const int VectorSize = {5};
- private const int ElementCount = VectorSize / sizeof({3});
+ private const int VectorSize = {9};
- private static {3}[] _data1 = new {3}[ElementCount];
- private static {3}[] _data2 = new {3}[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof({6});
+ private const int Op2ElementCount = VectorSize / sizeof({8});
- private static {4}<{3}> _clsVar1;
- private static {4}<{3}> _clsVar2;
+ private static {6}[] _data1 = new {6}[Op1ElementCount];
+ private static {8}[] _data2 = new {8}[Op2ElementCount];
- private {4}<{3}> _fld1;
- private {4}<{3}> _fld2;
+ private static {5}<{6}> _clsVar1;
+ private static {7}<{8}> _clsVar2;
- private BooleanComparisonOpTest__DataTable<{3}> _dataTable;
+ private {5}<{6}> _fld1;
+ private {7}<{8}> _fld2;
- static BooleanComparisonOpTest__{2}{3}()
+ private BooleanComparisonOpTest__DataTable<{6}, {8}> _dataTable;
+
+ static BooleanComparisonOpTest__{2}{4}()
{{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar1), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar2), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _clsVar1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _clsVar2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
}}
- public BooleanComparisonOpTest__{2}{3}()
+ public BooleanComparisonOpTest__{2}{4}()
{{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld1), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld2), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _fld1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _fld2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- _dataTable = new BooleanComparisonOpTest__DataTable<{3}>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ _dataTable = new BooleanComparisonOpTest__DataTable<{6}, {8}>(_data1, _data2, VectorSize);
}}
public bool IsSupported => {0}.IsSupported;
public void RunBasicScenario_UnsafeRead()
{{
var result = {0}.{2}(
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr)
);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
public void RunBasicScenario_Load()
{{
var result = {0}.{2}(
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr))
);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
public void RunBasicScenario_LoadAligned()
{{
var result = {0}.{2}(
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr))
);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
public void RunReflectionScenario_UnsafeRead()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr)
}});
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
public void RunReflectionScenario_Load()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr))
}});
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
public void RunReflectionScenario_LoadAligned()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr))
}});
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
public void RunLclVarScenario_UnsafeRead()
{{
- var left = Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr);
- var right = Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr);
+ var left = Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr);
+ var right = Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr);
var result = {0}.{2}(left, right);
ValidateResult(left, right, result);
public void RunLclVarScenario_Load()
{{
- var left = {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr));
- var right = {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr));
+ var left = {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr));
+ var right = {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr));
var result = {0}.{2}(left, right);
ValidateResult(left, right, result);
public void RunLclVarScenario_LoadAligned()
{{
- var left = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr));
- var right = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr));
+ var left = {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr));
+ var right = {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr));
var result = {0}.{2}(left, right);
ValidateResult(left, right, result);
public void RunLclFldScenario()
{{
- var test = new BooleanComparisonOpTest__{2}{3}();
+ var test = new BooleanComparisonOpTest__{2}{4}();
var result = {0}.{2}(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
}}
}}
- private void ValidateResult({4}<{3}> left, {4}<{3}> right, bool result, [CallerMemberName] string method = "")
+ private void ValidateResult({5}<{6}> left, {7}<{8}> right, bool result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{6}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{8}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
ValidateResult(inArray1, inArray2, result, method);
}}
- private void ValidateResult({3}[] left, {3}[] right, bool result, [CallerMemberName] string method = "")
+ private void ValidateResult({6}[] left, {8}[] right, bool result, [CallerMemberName] string method = "")
{{
- if ({7})
+ if ({12})
{{
Succeeded = false;
- Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{3}>: {{method}} failed:");
+ Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{4}>({5}<{6}>, {7}<{8}>): {{method}} failed:");
Console.WriteLine($" left: ({{string.Join(", ", left)}})");
Console.WriteLine($" right: ({{string.Join(", ", right)}})");
Console.WriteLine($" result: ({{string.Join(", ", result)}})");
namespace JIT.HardwareIntrinsics.X86
{
- public unsafe struct BooleanComparisonOpTest__DataTable<T> : IDisposable where T : struct
+ public unsafe struct BooleanComparisonOpTest__DataTable<TOp1, TOp2> : IDisposable
+ where TOp1 : struct
+ where TOp2 : struct
{
private byte[] inArray1;
private byte[] inArray2;
private byte simdSize;
- public BooleanComparisonOpTest__DataTable(T[] inArray1, T[] inArray2, int simdSize)
+ public BooleanComparisonOpTest__DataTable(TOp1[] inArray1, TOp2[] inArray2, int simdSize)
{
this.inArray1 = new byte[simdSize * 2];
this.inArray2 = new byte[simdSize * 2];
this.simdSize = unchecked((byte)(simdSize));
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<T, byte>(ref inArray1[0]), this.simdSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<T, byte>(ref inArray2[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<TOp1, byte>(ref inArray1[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<TOp2, byte>(ref inArray2[0]), this.simdSize);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), simdSize);
private static readonly (string templateFileName, string[] templateData)[] SseInputs = new []
{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Add", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "AddScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "And", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "AndNot", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareEqualOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] == right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareEqualUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] == right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThan", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] > right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] > right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] >= right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] >= right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThan", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] < right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] < right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] <= right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] <= right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] != right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] != right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThan", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanOrEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanOrEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThan", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanOrEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanOrEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareOrdered", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((!float.IsNaN(left[i]) && !float.IsNaN(right[i])) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareUnordered", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((float.IsNaN(left[i]) || float.IsNaN(right[i])) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Divide", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "DivideScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Max", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(Math.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "MaxScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Min", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(Math.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "MinScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Multiply", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "MultiplyScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Or", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Subtract", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "SubtractScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Xor", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
+ // TemplateName Isa, LoadIsa, Method, RetVectorType RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3TBaseype, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Add", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "AddScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "And", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "AndNot", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareEqualOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] == right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareEqualUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] == right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThan", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] > right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] > right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] >= right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] >= right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThan", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] < right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] < right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] <= right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] <= right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] != right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] != right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThan", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanOrEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanOrEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThan", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanOrEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanOrEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareOrdered", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((!float.IsNaN(left[i]) && !float.IsNaN(right[i])) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareOrderedScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareUnordered", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((float.IsNaN(left[i]) || float.IsNaN(right[i])) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareUnorderedScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Divide", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "DivideScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Max", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(Math.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "MaxScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Min", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(Math.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "MinScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Multiply", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "MultiplyScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Or", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Subtract", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "SubtractScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Xor", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
};
private static readonly (string templateFileName, string[] templateData)[] Sse2Inputs = new []
{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] + right[0]) != result[0]", "(byte)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] + right[0]) != result[0]", "(short)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] + right[0]) != result[0]", "(int)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] + right[0]) != result[0]", "(long)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] + right[0]) != result[0]", "(sbyte)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] + right[0]) != result[0]", "(ushort)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] + right[0]) != result[0]", "(uint)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] + right[0]) != result[0]", "(ulong)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Double", "Vector128", "16", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] & right[0]) != result[0]", "(byte)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] & right[0]) != result[0]", "(short)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] & right[0]) != result[0]", "(int)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] & right[0]) != result[0]", "(long)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] & right[0]) != result[0]", "(sbyte)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] & right[0]) != result[0]", "(ushort)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] & right[0]) != result[0]", "(uint)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] & right[0]) != result[0]", "(ulong)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Double", "Vector128", "16", "(double)(random.NextDouble())", "(~BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(~BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(~left[0] & right[0]) != result[0]", "(byte)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(~left[0] & right[0]) != result[0]", "(short)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(~left[0] & right[0]) != result[0]", "(int)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(~left[0] & right[0]) != result[0]", "(long)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(~left[0] & right[0]) != result[0]", "(sbyte)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(~left[0] & right[0]) != result[0]", "(ushort)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(~left[0] & right[0]) != result[0]", "(uint)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(~left[0] & right[0]) != result[0]", "(ulong)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ushort)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((uint)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThanOrEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((short)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((int)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThanOrEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotGreaterThan", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotGreaterThanOrEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotLessThan", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotLessThanOrEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareOrdered", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((!double.IsNaN(left[0]) && !double.IsNaN(right[0])) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((!double.IsNaN(left[i]) && !double.IsNaN(right[i])) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareUnordered", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((double.IsNaN(left[0]) || double.IsNaN(right[0])) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((double.IsNaN(left[i]) || double.IsNaN(right[i])) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Divide", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Max", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Max", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "Math.Max(left[0], right[0]) != result[0]", "Math.Max(left[i], right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Max", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "Math.Max(left[0], right[0]) != result[0]", "Math.Max(left[i], right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Min", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Min", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MinValue))", "Math.Min(left[0], right[0]) != result[0]", "Math.Min(left[i], right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Min", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MinValue))", "Math.Min(left[0], right[0]) != result[0]", "Math.Min(left[i], right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Multiply", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Double", "Vector128", "16", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] | right[0]) != result[0]", "(byte)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] | right[0]) != result[0]", "(short)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] | right[0]) != result[0]", "(int)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] | right[0]) != result[0]", "(long)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] | right[0]) != result[0]", "(sbyte)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] | right[0]) != result[0]", "(ushort)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] | right[0]) != result[0]", "(uint)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] | right[0]) != result[0]", "(ulong)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] - right[0]) != result[0]", "(byte)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] - right[0]) != result[0]", "(short)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] - right[0]) != result[0]", "(int)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] - right[0]) != result[0]", "(long)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] - right[0]) != result[0]", "(sbyte)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] - right[0]) != result[0]", "(ushort)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] - right[0]) != result[0]", "(uint)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] - right[0]) != result[0]", "(ulong)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Double", "Vector128", "16", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] ^ right[0]) != result[0]", "(byte)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] ^ right[0]) != result[0]", "(short)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] ^ right[0]) != result[0]", "(int)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] ^ right[0]) != result[0]", "(long)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] ^ right[0]) != result[0]", "(sbyte)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] ^ right[0]) != result[0]", "(ushort)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] ^ right[0]) != result[0]", "(uint)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] ^ right[0]) != result[0]", "(ulong)(left[i] ^ right[i]) != result[i]"}),
+ // TemplateName Isa, LoadIsa, Method, RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] + right[0]) != result[0]", "(byte)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] + right[0]) != result[0]", "(short)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] + right[0]) != result[0]", "(int)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] + right[0]) != result[0]", "(long)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] + right[0]) != result[0]", "(sbyte)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] + right[0]) != result[0]", "(ushort)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] + right[0]) != result[0]", "(uint)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] + right[0]) != result[0]", "(ulong)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] & right[0]) != result[0]", "(byte)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] & right[0]) != result[0]", "(short)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] & right[0]) != result[0]", "(int)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] & right[0]) != result[0]", "(long)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] & right[0]) != result[0]", "(sbyte)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] & right[0]) != result[0]", "(ushort)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] & right[0]) != result[0]", "(uint)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] & right[0]) != result[0]", "(ulong)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "(~BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(~BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(~left[0] & right[0]) != result[0]", "(byte)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(~left[0] & right[0]) != result[0]", "(short)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(~left[0] & right[0]) != result[0]", "(int)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(~left[0] & right[0]) != result[0]", "(long)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(~left[0] & right[0]) != result[0]", "(sbyte)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(~left[0] & right[0]) != result[0]", "(ushort)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(~left[0] & right[0]) != result[0]", "(uint)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(~left[0] & right[0]) != result[0]", "(ulong)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ushort)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((uint)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThanOrEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((short)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((int)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThanOrEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotGreaterThan", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotGreaterThanOrEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotLessThan", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotLessThanOrEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareOrdered", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((!double.IsNaN(left[0]) && !double.IsNaN(right[0])) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((!double.IsNaN(left[i]) && !double.IsNaN(right[i])) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareUnordered", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((double.IsNaN(left[0]) || double.IsNaN(right[0])) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((double.IsNaN(left[i]) || double.IsNaN(right[i])) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Divide", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Max", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Max", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "Math.Max(left[0], right[0]) != result[0]", "Math.Max(left[i], right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Max", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "Math.Max(left[0], right[0]) != result[0]", "Math.Max(left[i], right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Min", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Min", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MinValue))", "(byte)(random.Next(0, byte.MinValue))", "Math.Min(left[0], right[0]) != result[0]", "Math.Min(left[i], right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Min", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MinValue))", "(short)(random.Next(short.MinValue, short.MinValue))", "Math.Min(left[0], right[0]) != result[0]", "Math.Min(left[i], right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Multiply", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] | right[0]) != result[0]", "(byte)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] | right[0]) != result[0]", "(short)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] | right[0]) != result[0]", "(int)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] | right[0]) != result[0]", "(long)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] | right[0]) != result[0]", "(sbyte)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] | right[0]) != result[0]", "(ushort)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] | right[0]) != result[0]", "(uint)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] | right[0]) != result[0]", "(ulong)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] - right[0]) != result[0]", "(byte)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] - right[0]) != result[0]", "(short)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] - right[0]) != result[0]", "(int)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] - right[0]) != result[0]", "(long)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] - right[0]) != result[0]", "(sbyte)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] - right[0]) != result[0]", "(ushort)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] - right[0]) != result[0]", "(uint)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] - right[0]) != result[0]", "(ulong)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] ^ right[0]) != result[0]", "(byte)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] ^ right[0]) != result[0]", "(short)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] ^ right[0]) != result[0]", "(int)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] ^ right[0]) != result[0]", "(long)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] ^ right[0]) != result[0]", "(sbyte)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] ^ right[0]) != result[0]", "(ushort)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] ^ right[0]) != result[0]", "(uint)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] ^ right[0]) != result[0]", "(ulong)(left[i] ^ right[i]) != result[i]"}),
};
private static readonly (string templateFileName, string[] templateData)[] Sse41Inputs = new []
{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Sse41", "Sse2", "CompareEqual", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse41", "Sse2", "CompareEqual", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ulong)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0)"}),
+ // TemplateName Isa, LoadIsa, Method, RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Sse41", "Sse2", "CompareEqual", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse41", "Sse2", "CompareEqual", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ulong)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0)"}),
};
private static readonly (string templateFileName, string[] templateData)[] Sse42Inputs = new []
{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Sse42", "Sse2", "CompareGreaterThan","Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0)"}),
+ // TemplateName Isa, LoadIsa, Method, RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Sse42", "Sse2", "CompareGreaterThan", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0)"}),
};
private static readonly (string templateFileName, string[] templateData)[] AvxInputs = new []
-{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Add", "Double", "Vector256", "32", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Add", "Single", "Vector256", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "AddSubtract", "Double", "Vector256", "32", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "((i % 2 != 0) && (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])))"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "AddSubtract", "Single", "Vector256", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", "((i % 2 != 0) && (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])))"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "And", "Double", "Vector256", "32", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "And", "Single", "Vector256", "32", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[i]) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "AndNot", "Double", "Vector256", "32", "(double)(random.NextDouble())", "((~BitConverter.DoubleToInt64Bits(left[0])) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "((~BitConverter.DoubleToInt64Bits(left[i])) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "AndNot", "Single", "Vector256", "32", "(float)(random.NextDouble())", "((~BitConverter.SingleToInt32Bits(left[0])) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "((~BitConverter.SingleToInt32Bits(left[i])) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleTernOpTest.template",new string[] { "Avx", "Avx", "BlendVariable", "Double", "Vector256", "32", "(double)(random.NextDouble())", "(double)(((i % 2) == 0) ? -0.0 : 1.0)", "((BitConverter.DoubleToInt64Bits(thirdOp[0]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[0]) != BitConverter.DoubleToInt64Bits(result[0]) : BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", "((BitConverter.DoubleToInt64Bits(thirdOp[i]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[i]) != BitConverter.DoubleToInt64Bits(result[i]) : BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleTernOpTest.template",new string[] { "Avx", "Avx", "BlendVariable", "Single", "Vector256", "32", "(float)(random.NextDouble())", "(float)(((i % 2) == 0) ? -0.0 : 1.0)", "((BitConverter.SingleToInt32Bits(thirdOp[0]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[0]) != BitConverter.SingleToInt32Bits(result[0]) : BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", "((BitConverter.SingleToInt32Bits(thirdOp[i]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[i]) != BitConverter.SingleToInt32Bits(result[i]) : BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleUnOpTest.template", new string[] { "Avx", "Avx", "DuplicateEvenIndexed","Double", "Vector256", "32", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", "(i % 2 == 0) ? (BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])) : (BitConverter.DoubleToInt64Bits(firstOp[i - 1]) != BitConverter.DoubleToInt64Bits(result[i]))"}),
- ("SimpleUnOpTest.template", new string[] { "Avx", "Avx", "DuplicateEvenIndexed","Single", "Vector256", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i - 1]) != BitConverter.SingleToInt32Bits(result[i]))"}),
- ("SimpleUnOpTest.template", new string[] { "Avx", "Avx", "DuplicateOddIndexed", "Single", "Vector256", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(firstOp[1]) != BitConverter.SingleToInt32Bits(result[0])", "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i + 1]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Divide", "Double", "Vector256", "32", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Divide", "Single", "Vector256", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Max", "Double", "Vector256", "32", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Max", "Single", "Vector256", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(MathF.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(MathF.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Min", "Double", "Vector256", "32", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Min", "Single", "Vector256", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(MathF.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(MathF.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Multiply", "Double", "Vector256", "32", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Multiply", "Single", "Vector256", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Or", "Double", "Vector256", "32", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Or", "Single", "Vector256", "32", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[i]) | BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Subtract", "Double", "Vector256", "32", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Subtract", "Single", "Vector256", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Xor", "Double", "Vector256", "32", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Xor", "Single", "Vector256", "32", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[i]) ^ BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+{
+ // TemplateName Isa, LoadIsa, Method, RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Add", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Add", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "AddSubtract", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "((i % 2 != 0) && (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])))"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "AddSubtract", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", "((i % 2 != 0) && (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])))"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "And", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "And", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[i]) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "AndNot", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "((~BitConverter.DoubleToInt64Bits(left[0])) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "((~BitConverter.DoubleToInt64Bits(left[i])) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "AndNot", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "((~BitConverter.SingleToInt32Bits(left[0])) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "((~BitConverter.SingleToInt32Bits(left[i])) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleTernOpTest.template", new string[] { "Avx", "Avx", "BlendVariable", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "(double)(((i % 2) == 0) ? -0.0 : 1.0)", "((BitConverter.DoubleToInt64Bits(thirdOp[0]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[0]) != BitConverter.DoubleToInt64Bits(result[0]) : BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", "((BitConverter.DoubleToInt64Bits(thirdOp[i]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[i]) != BitConverter.DoubleToInt64Bits(result[i]) : BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleTernOpTest.template", new string[] { "Avx", "Avx", "BlendVariable", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(float)(((i % 2) == 0) ? -0.0 : 1.0)", "((BitConverter.SingleToInt32Bits(thirdOp[0]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[0]) != BitConverter.SingleToInt32Bits(result[0]) : BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", "((BitConverter.SingleToInt32Bits(thirdOp[i]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[i]) != BitConverter.SingleToInt32Bits(result[i]) : BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Divide", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Divide", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleUnOpTest.template", new string[] { "Avx", "Avx", "DuplicateEvenIndexed", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", "(i % 2 == 0) ? (BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])) : (BitConverter.DoubleToInt64Bits(firstOp[i - 1]) != BitConverter.DoubleToInt64Bits(result[i]))"}),
+ ("SimpleUnOpTest.template", new string[] { "Avx", "Avx", "DuplicateEvenIndexed", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i - 1]) != BitConverter.SingleToInt32Bits(result[i]))"}),
+ ("SimpleUnOpTest.template", new string[] { "Avx", "Avx", "DuplicateOddIndexed", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(firstOp[1]) != BitConverter.SingleToInt32Bits(result[0])", "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i + 1]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Max", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Max", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(MathF.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(MathF.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Min", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Min", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(MathF.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(MathF.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Multiply", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Multiply", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Or", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Or", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[i]) | BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Subtract", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Subtract", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Xor", "Vector256", "Double", "Vector256", "Double", "Vector256", "Double", "32", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Xor", "Vector256", "Single", "Vector256", "Single", "Vector256", "Single", "32", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[i]) ^ BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
};
private static readonly (string templateFileName, string[] templateData)[] Avx2Inputs = new []
{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] + right[0]) != result[0]", "(byte)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] + right[0]) != result[0]", "(short)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] + right[0]) != result[0]", "(int)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] + right[0]) != result[0]", "(long)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] + right[0]) != result[0]", "(sbyte)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] + right[0]) != result[0]", "(ushort)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] + right[0]) != result[0]", "(uint)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] + right[0]) != result[0]", "(ulong)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] & right[0]) != result[0]", "(byte)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] & right[0]) != result[0]", "(short)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] & right[0]) != result[0]", "(int)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] & right[0]) != result[0]", "(long)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] & right[0]) != result[0]", "(sbyte)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] & right[0]) != result[0]", "(ushort)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] & right[0]) != result[0]", "(uint)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] & right[0]) != result[0]", "(ulong)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(~left[0] & right[0]) != result[0]", "(byte)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(~left[0] & right[0]) != result[0]", "(short)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(~left[0] & right[0]) != result[0]", "(int)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(~left[0] & right[0]) != result[0]", "(long)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(~left[0] & right[0]) != result[0]", "(sbyte)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(~left[0] & right[0]) != result[0]", "(ushort)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(~left[0] & right[0]) != result[0]", "(uint)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(~left[0] & right[0]) != result[0]", "(ulong)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Average", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)((left[0] + right[0] + 1) >> 1) != result[0]", "(byte)((left[i] + right[i] + 1) >> 1) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Average", "UInt16", "Vector256", "32", "(ushort)(random.Next(short.MinValue, short.MaxValue))","(ushort)((left[0] + right[0] + 1) >> 1) != result[0]", "(ushort)((left[i] + right[i] + 1) >> 1) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ushort)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((uint)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ulong)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan","Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan","Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan","Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan","SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] | right[0]) != result[0]", "(byte)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] | right[0]) != result[0]", "(short)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] | right[0]) != result[0]", "(int)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] | right[0]) != result[0]", "(long)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] | right[0]) != result[0]", "(sbyte)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] | right[0]) != result[0]", "(ushort)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] | right[0]) != result[0]", "(uint)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] | right[0]) != result[0]", "(ulong)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] - right[0]) != result[0]", "(byte)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] - right[0]) != result[0]", "(short)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] - right[0]) != result[0]", "(int)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] - right[0]) != result[0]", "(long)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] - right[0]) != result[0]", "(sbyte)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] - right[0]) != result[0]", "(ushort)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] - right[0]) != result[0]", "(uint)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] - right[0]) != result[0]", "(ulong)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] ^ right[0]) != result[0]", "(byte)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] ^ right[0]) != result[0]", "(short)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] ^ right[0]) != result[0]", "(int)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] ^ right[0]) != result[0]", "(long)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] ^ right[0]) != result[0]", "(sbyte)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] ^ right[0]) != result[0]", "(ushort)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] ^ right[0]) != result[0]", "(uint)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] ^ right[0]) != result[0]", "(ulong)(left[i] ^ right[i]) != result[i]"}),
+ // TemplateName Isa, LoadIsa, Method, RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] + right[0]) != result[0]", "(byte)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] + right[0]) != result[0]", "(short)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] + right[0]) != result[0]", "(int)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] + right[0]) != result[0]", "(long)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] + right[0]) != result[0]", "(sbyte)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] + right[0]) != result[0]", "(ushort)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] + right[0]) != result[0]", "(uint)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] + right[0]) != result[0]", "(ulong)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] & right[0]) != result[0]", "(byte)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] & right[0]) != result[0]", "(short)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] & right[0]) != result[0]", "(int)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] & right[0]) != result[0]", "(long)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] & right[0]) != result[0]", "(sbyte)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] & right[0]) != result[0]", "(ushort)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] & right[0]) != result[0]", "(uint)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] & right[0]) != result[0]", "(ulong)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(~left[0] & right[0]) != result[0]", "(byte)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(~left[0] & right[0]) != result[0]", "(short)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(~left[0] & right[0]) != result[0]", "(int)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(~left[0] & right[0]) != result[0]", "(long)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(~left[0] & right[0]) != result[0]", "(sbyte)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(~left[0] & right[0]) != result[0]", "(ushort)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(~left[0] & right[0]) != result[0]", "(uint)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(~left[0] & right[0]) != result[0]", "(ulong)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Average", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)((left[0] + right[0] + 1) >> 1) != result[0]", "(byte)((left[i] + right[i] + 1) >> 1) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Average", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(short.MinValue, short.MaxValue))", "(ushort)(random.Next(short.MinValue, short.MaxValue))", "(ushort)((left[0] + right[0] + 1) >> 1) != result[0]", "(ushort)((left[i] + right[i] + 1) >> 1) != result[i]"}),
+ ("SimpleTernOpTest.template", new string[] { "Avx2", "Avx", "BlendVariable", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(((i % 2) == 0) ? 128 : 1)", "((thirdOp[0] >> 7) & 1) == 1 ? secondOp[0] != result[0] : firstOp[0] != result[0]", "((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i]"}),
+ ("SimpleTernOpTest.template", new string[] { "Avx2", "Avx", "BlendVariable", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(((i % 2) == 0) ? -128 : 1)", "((thirdOp[0] >> 7) & 1) == 1 ? secondOp[0] != result[0] : firstOp[0] != result[0]", "((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ushort)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((uint)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ulong)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] | right[0]) != result[0]", "(byte)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] | right[0]) != result[0]", "(short)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] | right[0]) != result[0]", "(int)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] | right[0]) != result[0]", "(long)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] | right[0]) != result[0]", "(sbyte)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] | right[0]) != result[0]", "(ushort)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] | right[0]) != result[0]", "(uint)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] | right[0]) != result[0]", "(ulong)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] - right[0]) != result[0]", "(byte)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] - right[0]) != result[0]", "(short)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] - right[0]) != result[0]", "(int)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] - right[0]) != result[0]", "(long)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] - right[0]) != result[0]", "(sbyte)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] - right[0]) != result[0]", "(ushort)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] - right[0]) != result[0]", "(uint)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] - right[0]) != result[0]", "(ulong)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] ^ right[0]) != result[0]", "(byte)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] ^ right[0]) != result[0]", "(short)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] ^ right[0]) != result[0]", "(int)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] ^ right[0]) != result[0]", "(long)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] ^ right[0]) != result[0]", "(sbyte)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] ^ right[0]) != result[0]", "(ushort)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] ^ right[0]) != result[0]", "(uint)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] ^ right[0]) != result[0]", "(ulong)(left[i] ^ right[i]) != result[i]"}),
};
private static void ProcessInputs(string isa, (string templateFileName, string[] templateData)[] inputs)
private static void ProcessInput(StreamWriter testListFile, (string templateFileName, string[] templateData) input)
{
- var testName = $"{input.templateData[2]}.{input.templateData[3]}";
+ var testName = $"{input.templateData[2]}.{input.templateData[4]}";
// Ex: ["Add.Single"] = AddSingle
- testListFile.WriteLine($@" [""{testName}""] = {input.templateData[2]}{input.templateData[3]},");
+ testListFile.WriteLine($@" [""{testName}""] = {input.templateData[2]}{input.templateData[4]},");
var testFileName = Path.Combine("..", input.templateData[0], $"{testName}.cs");
var template = File.ReadAllText(input.templateFileName);
{{
public static partial class Program
{{
- private static void {2}{3}()
+ private static void {2}{4}()
{{
- var test = new SimpleBinaryOpTest__{2}{3}();
+ var test = new SimpleBinaryOpTest__{2}{4}();
if (test.IsSupported)
{{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }}
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }}
// Validates passing the field of a local works
test.RunLclFldScenario();
}}
}}
- public sealed unsafe class SimpleBinaryOpTest__{2}{3}
+ public sealed unsafe class SimpleBinaryOpTest__{2}{4}
{{
- private const int VectorSize = {5};
- private const int ElementCount = VectorSize / sizeof({3});
+ private const int VectorSize = {9};
+
+ private const int Op1ElementCount = VectorSize / sizeof({6});
+ private const int Op2ElementCount = VectorSize / sizeof({8});
+ private const int RetElementCount = VectorSize / sizeof({4});
- private static {3}[] _data1 = new {3}[ElementCount];
- private static {3}[] _data2 = new {3}[ElementCount];
+ private static {6}[] _data1 = new {6}[Op1ElementCount];
+ private static {8}[] _data2 = new {8}[Op2ElementCount];
- private static {4}<{3}> _clsVar1;
- private static {4}<{3}> _clsVar2;
+ private static {5}<{6}> _clsVar1;
+ private static {7}<{8}> _clsVar2;
- private {4}<{3}> _fld1;
- private {4}<{3}> _fld2;
+ private {5}<{6}> _fld1;
+ private {7}<{8}> _fld2;
- private SimpleBinaryOpTest__DataTable<{3}> _dataTable;
+ private SimpleBinaryOpTest__DataTable<{4}, {6}, {8}> _dataTable;
- static SimpleBinaryOpTest__{2}{3}()
+ static SimpleBinaryOpTest__{2}{4}()
{{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar1), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar2), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _clsVar1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _clsVar2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
}}
- public SimpleBinaryOpTest__{2}{3}()
+ public SimpleBinaryOpTest__{2}{4}()
{{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld1), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld2), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _fld1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _fld2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- _dataTable = new SimpleBinaryOpTest__DataTable<{3}>(_data1, _data2, new {3}[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ _dataTable = new SimpleBinaryOpTest__DataTable<{4}, {6}, {8}>(_data1, _data2, new {4}[RetElementCount], VectorSize);
}}
public bool IsSupported => {0}.IsSupported;
public void RunBasicScenario_UnsafeRead()
{{
var result = {0}.{2}(
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunBasicScenario_Load()
{{
var result = {0}.{2}(
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunBasicScenario_LoadAligned()
{{
var result = {0}.{2}(
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunReflectionScenario_UnsafeRead()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr)
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_Load()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_LoadAligned()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}}
public void RunLclVarScenario_UnsafeRead()
{{
- var left = Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr);
- var right = Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr);
+ var left = Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr);
+ var right = Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr);
var result = {0}.{2}(left, right);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunLclVarScenario_Load()
{{
- var left = {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr));
- var right = {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr));
+ var left = {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr));
+ var right = {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr));
var result = {0}.{2}(left, right);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunLclVarScenario_LoadAligned()
{{
- var left = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr));
- var right = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr));
+ var left = {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr));
+ var right = {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr));
var result = {0}.{2}(left, right);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunLclFldScenario()
{{
- var test = new SimpleBinaryOpTest__{2}{3}();
+ var test = new SimpleBinaryOpTest__{2}{4}();
var result = {0}.{2}(test._fld1, test._fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
}}
}}
- private void ValidateResult({4}<{3}> left, {4}<{3}> right, void* result, [CallerMemberName] string method = "")
+ private void ValidateResult({5}<{6}> left, {7}<{8}> right, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray1, inArray2, outArray, method);
}}
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{6}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{8}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray1, inArray2, outArray, method);
}}
- private void ValidateResult({3}[] left, {3}[] right, {3}[] result, [CallerMemberName] string method = "")
+ private void ValidateResult({6}[] left, {8}[] right, {4}[] result, [CallerMemberName] string method = "")
{{
- if ({7})
+ if ({12})
{{
Succeeded = false;
}}
else
{{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{{
- if ({8})
+ if ({13})
{{
Succeeded = false;
break;
if (!Succeeded)
{{
- Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{3}>: {{method}} failed:");
+ Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{4}>({5}<{6}>, {7}<{8}>): {{method}} failed:");
Console.WriteLine($" left: ({{string.Join(", ", left)}})");
Console.WriteLine($" right: ({{string.Join(", ", right)}})");
Console.WriteLine($" result: ({{string.Join(", ", result)}})");
namespace JIT.HardwareIntrinsics.X86
{
- public unsafe struct SimpleBinaryOpTest__DataTable<T> : IDisposable where T : struct
+ public unsafe struct SimpleBinaryOpTest__DataTable<TResult, TOp1, TOp2> : IDisposable
+ where TResult : struct
+ where TOp1 : struct
+ where TOp2 : struct
{
private byte[] inArray1;
private byte[] inArray2;
private byte simdSize;
- public SimpleBinaryOpTest__DataTable(T[] inArray1, T[] inArray2, T[] outArray, int simdSize)
+ public SimpleBinaryOpTest__DataTable(TOp1[] inArray1, TOp2[] inArray2, TResult[] outArray, int simdSize)
{
this.inArray1 = new byte[simdSize * 2];
this.inArray2 = new byte[simdSize * 2];
this.simdSize = unchecked((byte)(simdSize));
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<T, byte>(ref inArray1[0]), this.simdSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<T, byte>(ref inArray2[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<TOp1, byte>(ref inArray1[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<TOp2, byte>(ref inArray2[0]), this.simdSize);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), simdSize);
{{
public static partial class Program
{{
- private static void {2}{3}()
+ private static void {2}{4}()
{{
- var test = new SimpleTernaryOpTest__{2}{3}();
+ var test = new SimpleTernaryOpTest__{2}{4}();
if (test.IsSupported)
{{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }}
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }}
// Validates passing the field of a local works
test.RunLclFldScenario();
}}
}}
- public sealed unsafe class SimpleTernaryOpTest__{2}{3}
+ public sealed unsafe class SimpleTernaryOpTest__{2}{4}
{{
- private const int VectorSize = {5};
- private const int ElementCount = VectorSize / sizeof({3});
+ private const int VectorSize = {11};
- private static {3}[] _data1 = new {3}[ElementCount];
- private static {3}[] _data2 = new {3}[ElementCount];
- private static {3}[] _data3 = new {3}[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof({6});
+ private const int Op2ElementCount = VectorSize / sizeof({8});
+ private const int Op3ElementCount = VectorSize / sizeof({10});
+ private const int RetElementCount = VectorSize / sizeof({4});
- private static {4}<{3}> _clsVar1;
- private static {4}<{3}> _clsVar2;
- private static {4}<{3}> _clsVar3;
+ private static {6}[] _data1 = new {6}[Op1ElementCount];
+ private static {8}[] _data2 = new {8}[Op2ElementCount];
+ private static {10}[] _data3 = new {10}[Op3ElementCount];
- private {4}<{3}> _fld1;
- private {4}<{3}> _fld2;
- private {4}<{3}> _fld3;
+ private static {5}<{6}> _clsVar1;
+ private static {7}<{8}> _clsVar2;
+ private static {9}<{10}> _clsVar3;
- private SimpleTernaryOpTest__DataTable<{3}> _dataTable;
+ private {5}<{6}> _fld1;
+ private {7}<{8}> _fld2;
+ private {9}<{10}> _fld3;
- static SimpleTernaryOpTest__{2}{3}()
+ private SimpleTernaryOpTest__DataTable<{4}, {6}, {8}, {10}> _dataTable;
+
+ static SimpleTernaryOpTest__{2}{4}()
{{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; _data3[i] = {7}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar1), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar2), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar3), ref Unsafe.As<{3}, byte>(ref _data3[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {12}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _clsVar1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {13}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _clsVar2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) {{ _data3[i] = {14}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{9}<{10}>, byte>(ref _clsVar3), ref Unsafe.As<{10}, byte>(ref _data3[0]), VectorSize);
}}
- public SimpleTernaryOpTest__{2}{3}()
+ public SimpleTernaryOpTest__{2}{4}()
{{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; _data3[i] = {7}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld1), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld2), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld3), ref Unsafe.As<{3}, byte>(ref _data3[0]), VectorSize);
-
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; _data3[i] = {7}; }}
- _dataTable = new SimpleTernaryOpTest__DataTable<{3}>(_data1, _data2, _data3, new {3}[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {12}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _fld1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {13}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _fld2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) {{ _data3[i] = {14}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{9}<{10}>, byte>(ref _fld3), ref Unsafe.As<{10}, byte>(ref _data3[0]), VectorSize);
+
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {12}; }}
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {13}; }}
+ for (var i = 0; i < Op3ElementCount; i++) {{ _data3[i] = {14}; }}
+ _dataTable = new SimpleTernaryOpTest__DataTable<{4}, {6}, {8}, {10}>(_data1, _data2, _data3, new {4}[RetElementCount], VectorSize);
}}
public bool IsSupported => {0}.IsSupported;
public void RunBasicScenario_UnsafeRead()
{{
var result = {0}.{2}(
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray3Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr),
+ Unsafe.Read<{9}<{10}>>(_dataTable.inArray3Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunBasicScenario_Load()
{{
var result = {0}.{2}(
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray3Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr)),
+ {1}.Load{9}(({10}*)(_dataTable.inArray3Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunBasicScenario_LoadAligned()
{{
var result = {0}.{2}(
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray3Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr)),
+ {1}.LoadAligned{9}(({10}*)(_dataTable.inArray3Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunReflectionScenario_UnsafeRead()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>), typeof({9}<{10}>) }})
.Invoke(null, new object[] {{
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray3Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr),
+ Unsafe.Read<{9}<{10}>>(_dataTable.inArray3Ptr)
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_Load()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>), typeof({9}<{10}>) }})
.Invoke(null, new object[] {{
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray3Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr)),
+ {1}.Load{9}(({10}*)(_dataTable.inArray3Ptr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_LoadAligned()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>), typeof({9}<{10}>) }})
.Invoke(null, new object[] {{
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray3Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr)),
+ {1}.LoadAligned{9}(({10}*)(_dataTable.inArray3Ptr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}}
public void RunLclVarScenario_UnsafeRead()
{{
- var firstOp = Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr);
- var secondOp = Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr);
- var thirdOp = Unsafe.Read<{4}<{3}>>(_dataTable.inArray3Ptr);
+ var firstOp = Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr);
+ var secondOp = Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr);
+ var thirdOp = Unsafe.Read<{9}<{10}>>(_dataTable.inArray3Ptr);
var result = {0}.{2}(firstOp, secondOp, thirdOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunLclVarScenario_Load()
{{
- var firstOp = {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr));
- var secondOp = {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr));
- var thirdOp = {1}.Load{4}(({3}*)(_dataTable.inArray3Ptr));
+ var firstOp = {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr));
+ var secondOp = {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr));
+ var thirdOp = {1}.Load{9}(({10}*)(_dataTable.inArray3Ptr));
var result = {0}.{2}(firstOp, secondOp, thirdOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunLclVarScenario_LoadAligned()
{{
- var firstOp = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr));
- var secondOp = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr));
- var thirdOp = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray3Ptr));
+ var firstOp = {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr));
+ var secondOp = {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr));
+ var thirdOp = {1}.LoadAligned{9}(({10}*)(_dataTable.inArray3Ptr));
var result = {0}.{2}(firstOp, secondOp, thirdOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunLclFldScenario()
{{
- var test = new SimpleTernaryOpTest__{2}{3}();
+ var test = new SimpleTernaryOpTest__{2}{4}();
var result = {0}.{2}(test._fld1, test._fld2, test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
}}
}}
- private void ValidateResult({4}<{3}> firstOp, {4}<{3}> secondOp, {4}<{3}> thirdOp, void* result, [CallerMemberName] string method = "")
+ private void ValidateResult({5}<{6}> firstOp, {7}<{8}> secondOp, {9}<{10}> thirdOp, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
- {3}[] inArray3 = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
+ {10}[] inArray3 = new {10}[Op3ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), firstOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), secondOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray3[0]), thirdOp);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray1, inArray2, inArray3, outArray, method);
}}
private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
- {3}[] inArray3 = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
+ {10}[] inArray3 = new {10}[Op3ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(thirdOp), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{6}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{8}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{10}, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(thirdOp), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray1, inArray2, inArray3, outArray, method);
}}
- private void ValidateResult({3}[] firstOp, {3}[] secondOp, {3}[] thirdOp, {3}[] result, [CallerMemberName] string method = "")
+ private void ValidateResult({6}[] firstOp, {8}[] secondOp, {10}[] thirdOp, {4}[] result, [CallerMemberName] string method = "")
{{
- if ({8})
+ if ({15})
{{
Succeeded = false;
}}
else
{{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{{
- if ({9})
+ if ({16})
{{
Succeeded = false;
break;
if (!Succeeded)
{{
- Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{3}>: {{method}} failed:");
- Console.WriteLine($" firstOp: ({{string.Join(", ", firstOp)}})");
- Console.WriteLine($" secondOp: ({{string.Join(", ", secondOp)}})");
+ Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{4}>({5}<{6}>, {7}<{8}>, {9}<{10}>): {{method}} failed:");
+ Console.WriteLine($" firstOp: ({{string.Join(", ", firstOp)}})");
+ Console.WriteLine($" secondOp: ({{string.Join(", ", secondOp)}})");
Console.WriteLine($" thirdOp: ({{string.Join(", ", thirdOp)}})");
- Console.WriteLine($" result: ({{string.Join(", ", result)}})");
+ Console.WriteLine($" result: ({{string.Join(", ", result)}})");
Console.WriteLine();
}}
}}
namespace JIT.HardwareIntrinsics.X86
{
- public unsafe struct SimpleTernaryOpTest__DataTable<T> : IDisposable where T : struct
+ public unsafe struct SimpleTernaryOpTest__DataTable<TResult, TOp1, TOp2, TOp3> : IDisposable
+ where TResult : struct
+ where TOp1 : struct
+ where TOp2 : struct
+ where TOp3 : struct
{
private byte[] inArray1;
private byte[] inArray2;
private byte simdSize;
- public SimpleTernaryOpTest__DataTable(T[] inArray1, T[] inArray2, T[] inArray3, T[] outArray, int simdSize)
+ public SimpleTernaryOpTest__DataTable(TOp1[] inArray1, TOp2[] inArray2, TOp3[] inArray3, TResult[] outArray, int simdSize)
{
this.inArray1 = new byte[simdSize * 2];
this.inArray2 = new byte[simdSize * 2];
this.simdSize = unchecked((byte)(simdSize));
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<T, byte>(ref inArray1[0]), this.simdSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<T, byte>(ref inArray2[0]), this.simdSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<T, byte>(ref inArray3[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<TOp1, byte>(ref inArray1[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<TOp2, byte>(ref inArray2[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<TOp3, byte>(ref inArray3[0]), this.simdSize);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), simdSize);
{{
public static partial class Program
{{
- private static void {2}{3}()
+ private static void {2}{4}()
{{
- var test = new SimpleUnaryOpTest__{2}{3}();
+ var test = new SimpleUnaryOpTest__{2}{4}();
if (test.IsSupported)
{{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }}
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }}
// Validates passing the field of a local works
test.RunLclFldScenario();
}}
}}
- public sealed unsafe class SimpleUnaryOpTest__{2}{3}
+ public sealed unsafe class SimpleUnaryOpTest__{2}{4}
{{
- private const int VectorSize = {5};
- private const int ElementCount = VectorSize / sizeof({3});
+ private const int VectorSize = {7};
+
+ private const int Op1ElementCount = VectorSize / sizeof({6});
+ private const int RetElementCount = VectorSize / sizeof({4});
- private static {3}[] _data = new {3}[ElementCount];
+ private static {6}[] _data = new {6}[Op1ElementCount];
- private static {4}<{3}> _clsVar;
+ private static {5}<{6}> _clsVar;
- private {4}<{3}> _fld;
+ private {5}<{6}> _fld;
- private SimpleUnaryOpTest__DataTable<{3}> _dataTable;
+ private SimpleUnaryOpTest__DataTable<{4}, {6}> _dataTable;
- static SimpleUnaryOpTest__{2}{3}()
+ static SimpleUnaryOpTest__{2}{4}()
{{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar), ref Unsafe.As<{3}, byte>(ref _data[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data[i] = {8}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _clsVar), ref Unsafe.As<{6}, byte>(ref _data[0]), VectorSize);
}}
- public SimpleUnaryOpTest__{2}{3}()
+ public SimpleUnaryOpTest__{2}{4}()
{{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld), ref Unsafe.As<{3}, byte>(ref _data[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data[i] = {8}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _fld), ref Unsafe.As<{6}, byte>(ref _data[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) {{ _data[i] = {6}; }}
- _dataTable = new SimpleUnaryOpTest__DataTable<{3}>(_data, new {3}[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data[i] = {8}; }}
+ _dataTable = new SimpleUnaryOpTest__DataTable<{4}, {6}>(_data, new {4}[RetElementCount], VectorSize);
}}
public bool IsSupported => {0}.IsSupported;
public void RunBasicScenario_UnsafeRead()
{{
var result = {0}.{2}(
- Unsafe.Read<{4}<{3}>>(_dataTable.inArrayPtr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArrayPtr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunBasicScenario_Load()
{{
var result = {0}.{2}(
- {1}.Load{4}(({3}*)(_dataTable.inArrayPtr))
+ {1}.Load{5}(({6}*)(_dataTable.inArrayPtr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunBasicScenario_LoadAligned()
{{
var result = {0}.{2}(
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArrayPtr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArrayPtr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunReflectionScenario_UnsafeRead()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>) }})
.Invoke(null, new object[] {{
- Unsafe.Read<{4}<{3}>>(_dataTable.inArrayPtr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArrayPtr)
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_Load()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>) }})
.Invoke(null, new object[] {{
- {1}.Load{4}(({3}*)(_dataTable.inArrayPtr))
+ {1}.Load{5}(({6}*)(_dataTable.inArrayPtr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_LoadAligned()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>) }})
.Invoke(null, new object[] {{
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArrayPtr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArrayPtr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}}
public void RunLclVarScenario_UnsafeRead()
{{
- var firstOp = Unsafe.Read<{4}<{3}>>(_dataTable.inArrayPtr);
+ var firstOp = Unsafe.Read<{5}<{6}>>(_dataTable.inArrayPtr);
var result = {0}.{2}(firstOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunLclVarScenario_Load()
{{
- var firstOp = {1}.Load{4}(({3}*)(_dataTable.inArrayPtr));
+ var firstOp = {1}.Load{5}(({6}*)(_dataTable.inArrayPtr));
var result = {0}.{2}(firstOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunLclVarScenario_LoadAligned()
{{
- var firstOp = {1}.LoadAligned{4}(({3}*)(_dataTable.inArrayPtr));
+ var firstOp = {1}.LoadAligned{5}(({6}*)(_dataTable.inArrayPtr));
var result = {0}.{2}(firstOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
public void RunLclFldScenario()
{{
- var test = new SimpleUnaryOpTest__{2}{3}();
+ var test = new SimpleUnaryOpTest__{2}{4}();
var result = {0}.{2}(test._fld);
Unsafe.Write(_dataTable.outArrayPtr, result);
}}
}}
- private void ValidateResult({4}<{3}> firstOp, void* result, [CallerMemberName] string method = "")
+ private void ValidateResult({5}<{6}> firstOp, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray = new {6}[Op1ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray, outArray, method);
}}
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray = new {6}[Op1ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{6}, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray, outArray, method);
}}
- private void ValidateResult({3}[] firstOp, {3}[] result, [CallerMemberName] string method = "")
+ private void ValidateResult({6}[] firstOp, {4}[] result, [CallerMemberName] string method = "")
{{
- if ({7})
+ if ({9})
{{
Succeeded = false;
}}
else
{{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{{
- if ({8})
+ if ({10})
{{
Succeeded = false;
break;
if (!Succeeded)
{{
- Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{3}>: {{method}} failed:");
- Console.WriteLine($" firstOp: ({{string.Join(", ", firstOp)}})");
- Console.WriteLine($" result: ({{string.Join(", ", result)}})");
+ Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{4}>({5}<{6}>): {{method}} failed:");
+ Console.WriteLine($" firstOp: ({{string.Join(", ", firstOp)}})");
+ Console.WriteLine($" result: ({{string.Join(", ", result)}})");
Console.WriteLine();
}}
}}
namespace JIT.HardwareIntrinsics.X86
{
- public unsafe struct SimpleUnaryOpTest__DataTable<T> : IDisposable where T : struct
+ public unsafe struct SimpleUnaryOpTest__DataTable<TResult, TOp1> : IDisposable
+ where TResult : struct
+ where TOp1 : struct
{
private byte[] inArray;
private byte[] outArray;
private byte simdSize;
- public SimpleUnaryOpTest__DataTable(T[] inArray, T[] outArray, int simdSize)
+ public SimpleUnaryOpTest__DataTable(TOp1[] inArray, TResult[] outArray, int simdSize)
{
this.inArray = new byte[simdSize * 2];
this.outArray = new byte[simdSize * 2];
this.simdSize = unchecked((byte)(simdSize));
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArrayPtr), ref Unsafe.As<T, byte>(ref inArray[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArrayPtr), ref Unsafe.As<TOp1, byte>(ref inArray[0]), this.simdSize);
}
public void* inArrayPtr => Align((byte*)(inHandle.AddrOfPinnedObject().ToPointer()), simdSize);
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AddSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Add)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Add)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AddScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.AddScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.AddScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AndSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.And)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.And)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AndNotSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.AndNot)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.AndNot)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareEqualOrderedScalarSingle()
+ private static void CompareEqualOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareEqualOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareEqualOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareEqualOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean();
var result = Sse.CompareEqualOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareEqualUnorderedScalarSingle()
+ private static void CompareEqualUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareEqualUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareEqualUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareEqualUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean();
var result = Sse.CompareEqualUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThan)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThan)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareGreaterThanOrEqualOrderedScalarSingle()
+ private static void CompareGreaterThanOrEqualOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean();
var result = Sse.CompareGreaterThanOrEqualOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareGreaterThanOrEqualUnorderedScalarSingle()
+ private static void CompareGreaterThanOrEqualUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean();
var result = Sse.CompareGreaterThanOrEqualUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareGreaterThanOrderedScalarSingle()
+ private static void CompareGreaterThanOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareGreaterThanOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareGreaterThanOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean();
var result = Sse.CompareGreaterThanOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareGreaterThanUnorderedScalarSingle()
+ private static void CompareGreaterThanUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean();
var result = Sse.CompareGreaterThanUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareLessThanSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThan)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThan)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanOrEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareLessThanOrEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanOrEqualSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareLessThanOrEqualOrderedScalarSingle()
+ private static void CompareLessThanOrEqualOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean();
var result = Sse.CompareLessThanOrEqualOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareLessThanOrEqualUnorderedScalarSingle()
+ private static void CompareLessThanOrEqualUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean();
var result = Sse.CompareLessThanOrEqualUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareLessThanOrderedScalarSingle()
+ private static void CompareLessThanOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareLessThanOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareLessThanOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean();
var result = Sse.CompareLessThanOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareLessThanScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareLessThanUnorderedScalarSingle()
+ private static void CompareLessThanUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareLessThanUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareLessThanUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareLessThanUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareLessThanUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareLessThanUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean();
var result = Sse.CompareLessThanUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotEqualSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareNotEqualOrderedScalarSingle()
+ private static void CompareNotEqualOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareNotEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareNotEqualOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareNotEqualOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareNotEqualOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareNotEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean();
var result = Sse.CompareNotEqualOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotEqualScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
{
public static partial class Program
{
- private static void CompareNotEqualUnorderedScalarSingle()
+ private static void CompareNotEqualUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareNotEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareNotEqualUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareNotEqualUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareNotEqualUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareNotEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean();
var result = Sse.CompareNotEqualUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThan)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThan)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanOrEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanOrEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanOrEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanOrEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThan)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThan)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanOrEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanOrEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanOrEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanOrEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareOrderedSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareOrderedSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareOrderedSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((!float.IsNaN(left[i]) && !float.IsNaN(right[i])) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareOrdered)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareOrdered)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareOrderedScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareOrderedScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareOrderedScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareOrderedScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareUnorderedSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareUnorderedSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareUnorderedSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((float.IsNaN(left[i]) || float.IsNaN(right[i])) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareUnordered)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareUnordered)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareUnorderedScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareUnorderedScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareUnorderedScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareUnorderedScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__DivideSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__DivideSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__DivideSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Divide)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Divide)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__DivideScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__DivideScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__DivideScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.DivideScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.DivideScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MaxSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MaxSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(Math.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Max)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Max)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MaxScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MaxScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MaxScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MaxScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MinSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MinSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(Math.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Min)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Min)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MinScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MinScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MinScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MinScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MultiplySingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MultiplySingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MultiplySingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Multiply)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Multiply)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MultiplyScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MultiplyScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MultiplyScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MultiplyScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MultiplyScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__OrSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Or)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Or)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
["AndNot.Single"] = AndNotSingle,
["CompareEqual.Single"] = CompareEqualSingle,
["CompareEqualScalar.Single"] = CompareEqualScalarSingle,
- ["CompareEqualOrderedScalar.Single"] = CompareEqualOrderedScalarSingle,
- ["CompareEqualUnorderedScalar.Single"] = CompareEqualUnorderedScalarSingle,
+ ["CompareEqualOrderedScalar.Boolean"] = CompareEqualOrderedScalarBoolean,
+ ["CompareEqualUnorderedScalar.Boolean"] = CompareEqualUnorderedScalarBoolean,
["CompareGreaterThan.Single"] = CompareGreaterThanSingle,
["CompareGreaterThanScalar.Single"] = CompareGreaterThanScalarSingle,
- ["CompareGreaterThanOrderedScalar.Single"] = CompareGreaterThanOrderedScalarSingle,
- ["CompareGreaterThanUnorderedScalar.Single"] = CompareGreaterThanUnorderedScalarSingle,
+ ["CompareGreaterThanOrderedScalar.Boolean"] = CompareGreaterThanOrderedScalarBoolean,
+ ["CompareGreaterThanUnorderedScalar.Boolean"] = CompareGreaterThanUnorderedScalarBoolean,
["CompareGreaterThanOrEqual.Single"] = CompareGreaterThanOrEqualSingle,
["CompareGreaterThanOrEqualScalar.Single"] = CompareGreaterThanOrEqualScalarSingle,
- ["CompareGreaterThanOrEqualOrderedScalar.Single"] = CompareGreaterThanOrEqualOrderedScalarSingle,
- ["CompareGreaterThanOrEqualUnorderedScalar.Single"] = CompareGreaterThanOrEqualUnorderedScalarSingle,
+ ["CompareGreaterThanOrEqualOrderedScalar.Boolean"] = CompareGreaterThanOrEqualOrderedScalarBoolean,
+ ["CompareGreaterThanOrEqualUnorderedScalar.Boolean"] = CompareGreaterThanOrEqualUnorderedScalarBoolean,
["CompareLessThan.Single"] = CompareLessThanSingle,
["CompareLessThanScalar.Single"] = CompareLessThanScalarSingle,
- ["CompareLessThanOrderedScalar.Single"] = CompareLessThanOrderedScalarSingle,
- ["CompareLessThanUnorderedScalar.Single"] = CompareLessThanUnorderedScalarSingle,
+ ["CompareLessThanOrderedScalar.Boolean"] = CompareLessThanOrderedScalarBoolean,
+ ["CompareLessThanUnorderedScalar.Boolean"] = CompareLessThanUnorderedScalarBoolean,
["CompareLessThanOrEqual.Single"] = CompareLessThanOrEqualSingle,
["CompareLessThanOrEqualScalar.Single"] = CompareLessThanOrEqualScalarSingle,
- ["CompareLessThanOrEqualOrderedScalar.Single"] = CompareLessThanOrEqualOrderedScalarSingle,
- ["CompareLessThanOrEqualUnorderedScalar.Single"] = CompareLessThanOrEqualUnorderedScalarSingle,
+ ["CompareLessThanOrEqualOrderedScalar.Boolean"] = CompareLessThanOrEqualOrderedScalarBoolean,
+ ["CompareLessThanOrEqualUnorderedScalar.Boolean"] = CompareLessThanOrEqualUnorderedScalarBoolean,
["CompareNotEqual.Single"] = CompareNotEqualSingle,
["CompareNotEqualScalar.Single"] = CompareNotEqualScalarSingle,
- ["CompareNotEqualOrderedScalar.Single"] = CompareNotEqualOrderedScalarSingle,
- ["CompareNotEqualUnorderedScalar.Single"] = CompareNotEqualUnorderedScalarSingle,
+ ["CompareNotEqualOrderedScalar.Boolean"] = CompareNotEqualOrderedScalarBoolean,
+ ["CompareNotEqualUnorderedScalar.Boolean"] = CompareNotEqualUnorderedScalarBoolean,
["CompareNotGreaterThan.Single"] = CompareNotGreaterThanSingle,
["CompareNotGreaterThanScalar.Single"] = CompareNotGreaterThanScalarSingle,
["CompareNotGreaterThanOrEqual.Single"] = CompareNotGreaterThanOrEqualSingle,
<Compile Include="AndNot.Single.cs" />
<Compile Include="CompareEqual.Single.cs" />
<Compile Include="CompareEqualScalar.Single.cs" />
- <Compile Include="CompareEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareGreaterThan.Single.cs" />
<Compile Include="CompareGreaterThanScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrderedScalar.Single.cs" />
- <Compile Include="CompareGreaterThanUnorderedScalar.Single.cs" />
+ <Compile Include="CompareGreaterThanOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareGreaterThanUnorderedScalar.Boolean.cs" />
<Compile Include="CompareGreaterThanOrEqual.Single.cs" />
<Compile Include="CompareGreaterThanOrEqualScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareGreaterThanOrEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareLessThan.Single.cs" />
<Compile Include="CompareLessThanScalar.Single.cs" />
- <Compile Include="CompareLessThanOrderedScalar.Single.cs" />
- <Compile Include="CompareLessThanUnorderedScalar.Single.cs" />
+ <Compile Include="CompareLessThanOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareLessThanUnorderedScalar.Boolean.cs" />
<Compile Include="CompareLessThanOrEqual.Single.cs" />
<Compile Include="CompareLessThanOrEqualScalar.Single.cs" />
- <Compile Include="CompareLessThanOrEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareLessThanOrEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareLessThanOrEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareLessThanOrEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareNotEqual.Single.cs" />
<Compile Include="CompareNotEqualScalar.Single.cs" />
- <Compile Include="CompareNotEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareNotEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareNotEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareNotEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareNotGreaterThan.Single.cs" />
<Compile Include="CompareNotGreaterThanScalar.Single.cs" />
<Compile Include="CompareNotGreaterThanOrEqual.Single.cs" />
<Compile Include="AndNot.Single.cs" />
<Compile Include="CompareEqual.Single.cs" />
<Compile Include="CompareEqualScalar.Single.cs" />
- <Compile Include="CompareEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareGreaterThan.Single.cs" />
<Compile Include="CompareGreaterThanScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrderedScalar.Single.cs" />
- <Compile Include="CompareGreaterThanUnorderedScalar.Single.cs" />
+ <Compile Include="CompareGreaterThanOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareGreaterThanUnorderedScalar.Boolean.cs" />
<Compile Include="CompareGreaterThanOrEqual.Single.cs" />
<Compile Include="CompareGreaterThanOrEqualScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareGreaterThanOrEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareLessThan.Single.cs" />
<Compile Include="CompareLessThanScalar.Single.cs" />
- <Compile Include="CompareLessThanOrderedScalar.Single.cs" />
- <Compile Include="CompareLessThanUnorderedScalar.Single.cs" />
+ <Compile Include="CompareLessThanOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareLessThanUnorderedScalar.Boolean.cs" />
<Compile Include="CompareLessThanOrEqual.Single.cs" />
<Compile Include="CompareLessThanOrEqualScalar.Single.cs" />
- <Compile Include="CompareLessThanOrEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareLessThanOrEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareLessThanOrEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareLessThanOrEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareNotEqual.Single.cs" />
<Compile Include="CompareNotEqualScalar.Single.cs" />
- <Compile Include="CompareNotEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareNotEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareNotEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareNotEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareNotGreaterThan.Single.cs" />
<Compile Include="CompareNotGreaterThanScalar.Single.cs" />
<Compile Include="CompareNotGreaterThanOrEqual.Single.cs" />
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__SubtractSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Subtract)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Subtract)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__SubtractScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractScalarSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.SubtractScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.SubtractScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__XorSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorSingle()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Xor)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Xor)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AddByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AddDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AddInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AddInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AddInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AddSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AddUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AddUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AddUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AddUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] + right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AndByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AndDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AndInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AndInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AndInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AndSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AndUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AndUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AndUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AndNotByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AndNotDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((~BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AndNotInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AndNotInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AndNotInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AndNotSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AndNotUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AndNotUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AndNotUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(~left[i] & right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__CompareEqualByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__CompareEqualSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThanOrEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThanOrEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareLessThanDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__CompareLessThanInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] < right[i]) ? unchecked((short)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__CompareLessThanInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] < right[i]) ? unchecked((int)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__CompareLessThanSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] < right[i]) ? unchecked((sbyte)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanOrEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareLessThanOrEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanOrEqualDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThanOrEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThanOrEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareNotEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotEqualDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotGreaterThan)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotGreaterThan)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotGreaterThanOrEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotGreaterThanOrEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotLessThan)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotLessThan)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotLessThanOrEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotLessThanOrEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareOrderedDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareOrderedDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareOrderedDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((!double.IsNaN(left[i]) && !double.IsNaN(right[i])) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareOrdered)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareOrdered)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareUnorderedDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareUnorderedDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareUnorderedDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((double.IsNaN(left[i]) || double.IsNaN(right[i])) ? -1 : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareUnordered)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareUnordered)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__DivideDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__DivideDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__DivideDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Divide)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Divide)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MaxByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__MaxByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (Math.Max(left[i], right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MaxDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MaxDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MaxInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__MaxInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (Math.Max(left[i], right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MinByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__MinByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); _data2[i] = (byte)(random.Next(0, byte.MinValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MinValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); _data2[i] = (byte)(random.Next(0, byte.MinValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MinValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); _data2[i] = (byte)(random.Next(0, byte.MinValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MinValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (Math.Min(left[i], right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MinDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MinDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MinInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__MinInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (Math.Min(left[i], right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__MultiplyDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MultiplyDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MultiplyDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Multiply)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Multiply)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__OrByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__OrDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__OrInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__OrInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__OrInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__OrSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__OrUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__OrUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__OrUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__OrUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] | right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__SubtractByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__SubtractDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__SubtractInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__SubtractInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__SubtractInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__SubtractSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__SubtractUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__SubtractUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__SubtractUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] - right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__XorByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__XorDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorDouble()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__XorInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__XorInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__XorInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__XorSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorSByte()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__XorUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorUInt16()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__XorUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorUInt32()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__XorUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__XorUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] ^ right[i]) != result[i])
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse41.IsSupported;
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.CompareEqual)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.CompareEqual)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualUInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse41.IsSupported;
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.CompareEqual)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.CompareEqual)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanInt64()
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse42.IsSupported;
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0))
{
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse42)}.{nameof(Sse42.CompareGreaterThan)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse42)}.{nameof(Sse42.CompareGreaterThan)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");