static unsafe int Main(string[] args) { int testResult = Pass; if (Avx.IsSupported) { { byte * inBuffer = stackalloc byte[64]; float *inArray = (float *)Align(inBuffer, 32); float *outArray = stackalloc float[8]; var vf = Avx.LoadAlignedVector256(inArray); Unsafe.Write(outArray, vf); for (var i = 0; i < 8; i++) { if (BitConverter.SingleToInt32Bits(inArray[i]) != BitConverter.SingleToInt32Bits(outArray[i])) { Console.WriteLine("AVX LoadAlignedVector256 failed on float:"); for (var n = 0; n < 8; n++) { Console.Write(outArray[n] + ", "); } Console.WriteLine(); testResult = Fail; break; } } } { byte * inBuffer = stackalloc byte[64]; double *inArray = (double *)Align(inBuffer, 32); double *outArray = stackalloc double[4]; var vf = Avx.LoadAlignedVector256(inArray); Unsafe.Write(outArray, vf); for (var i = 0; i < 4; i++) { if (BitConverter.DoubleToInt64Bits(inArray[i]) != BitConverter.DoubleToInt64Bits(outArray[i])) { Console.WriteLine("AVX LoadAlignedVector256 failed on double:"); for (var n = 0; n < 4; n++) { Console.Write(outArray[n] + ", "); } Console.WriteLine(); testResult = Fail; break; } } } { byte *inBuffer = stackalloc byte[64]; int * inArray = (int *)Align(inBuffer, 32); int * outArray = stackalloc int[8]; var vf = Avx.LoadAlignedVector256(inArray); Unsafe.Write(outArray, vf); for (var i = 0; i < 8; i++) { if (inArray[i] != outArray[i]) { Console.WriteLine("AVX LoadAlignedVector256 failed on int:"); for (var n = 0; n < 8; n++) { Console.Write(outArray[n] + ", "); } Console.WriteLine(); testResult = Fail; break; } } } { byte *inBuffer = stackalloc byte[64]; long *inArray = (long *)Align(inBuffer, 32); long *outArray = stackalloc long[4]; var vf = Avx.LoadAlignedVector256(inArray); Unsafe.Write(outArray, vf); for (var i = 0; i < 4; i++) { if (inArray[i] != outArray[i]) { Console.WriteLine("AVX LoadAlignedVector256 failed on long:"); for (var n = 0; n < 4; n++) { Console.Write(outArray[n] + ", "); } Console.WriteLine(); testResult = Fail; break; } } } { byte *inBuffer = stackalloc byte[64]; uint *inArray = (uint *)Align(inBuffer, 32); uint *outArray = stackalloc uint[8]; var vf = Avx.LoadAlignedVector256(inArray); Unsafe.Write(outArray, vf); for (var i = 0; i < 8; i++) { if (inArray[i] != outArray[i]) { Console.WriteLine("AVX LoadAlignedVector256 failed on uint:"); for (var n = 0; n < 8; n++) { Console.Write(outArray[n] + ", "); } Console.WriteLine(); testResult = Fail; break; } } } { byte * inBuffer = stackalloc byte[64]; ulong *inArray = (ulong *)Align(inBuffer, 32); ulong *outArray = stackalloc ulong[4]; var vf = Avx.LoadAlignedVector256(inArray); Unsafe.Write(outArray, vf); for (var i = 0; i < 4; i++) { if (inArray[i] != outArray[i]) { Console.WriteLine("AVX LoadAlignedVector256 failed on ulong:"); for (var n = 0; n < 4; n++) { Console.Write(outArray[n] + ", "); } Console.WriteLine(); testResult = Fail; break; } } } { byte * inBuffer = stackalloc byte[64]; short *inArray = (short *)Align(inBuffer, 32); short *outArray = stackalloc short[16]; var vf = Avx.LoadAlignedVector256(inArray); Unsafe.Write(outArray, vf); for (var i = 0; i < 16; i++) { if (inArray[i] != outArray[i]) { Console.WriteLine("AVX LoadAlignedVector256 failed on short:"); for (var n = 0; n < 16; n++) { Console.Write(outArray[n] + ", "); } Console.WriteLine(); testResult = Fail; break; } } } { byte * inBuffer = stackalloc byte[64]; ushort *inArray = (ushort *)Align(inBuffer, 32); ushort *outArray = stackalloc ushort[16]; var vf = Avx.LoadAlignedVector256(inArray); Unsafe.Write(outArray, vf); for (var i = 0; i < 16; i++) { if (inArray[i] != outArray[i]) { Console.WriteLine("AVX LoadAlignedVector256 failed on ushort:"); for (var n = 0; n < 16; n++) { Console.Write(outArray[n] + ", "); } Console.WriteLine(); testResult = Fail; break; } } } { byte * inBuffer = stackalloc byte[64]; sbyte *inArray = (sbyte *)Align(inBuffer, 32); sbyte *outArray = stackalloc sbyte[32]; var vf = Avx.LoadAlignedVector256(inArray); Unsafe.Write(outArray, vf); for (var i = 0; i < 32; i++) { if (inArray[i] != outArray[i]) { Console.WriteLine("AVX LoadAlignedVector256 failed on sbyte:"); for (var n = 0; n < 32; n++) { Console.Write(outArray[n] + ", "); } Console.WriteLine(); testResult = Fail; break; } } } { byte *inBuffer = stackalloc byte[64]; byte *inArray = (byte *)Align(inBuffer, 32); byte *outArray = stackalloc byte[32]; var vf = Avx.LoadAlignedVector256(inArray); Unsafe.Write(outArray, vf); for (var i = 0; i < 32; i++) { if (inArray[i] != outArray[i]) { Console.WriteLine("AVX LoadAlignedVector256 failed on byte:"); for (var n = 0; n < 32; n++) { Console.Write(outArray[n] + ", "); } Console.WriteLine(); testResult = Fail; break; } } } } return(testResult); }
public Operand With(float value) { return(With(OperandKind.Constant, OperandType.FP32, (ulong)BitConverter.SingleToInt32Bits(value))); }
/// <summary> /// Write float to output stream. /// </summary> /// <param name="value">value to write.</param> public void WriteSingle(Single value) { Int32 v = BitConverter.SingleToInt32Bits(value); this.writer.Write(IPAddress.HostToNetworkOrder(v)); }
private void ValidateResult(Single[] firstOp, Single[] secondOp, Single[] thirdOp, Single[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (((BitConverter.SingleToInt32Bits(thirdOp[0]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[0]) != BitConverter.SingleToInt32Bits(result[0]) : BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])) { succeeded = false; } else { 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])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Sse41)}.{nameof(Sse41.BlendVariable)}<Single>(Vector128<Single>, Vector128<Single>, Vector128<Single>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($"secondOp: ({string.Join(", ", secondOp)})"); TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } }
private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[2])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(result[1]) != BitConverter.SingleToInt32Bits(firstOp[0]) || BitConverter.SingleToInt32Bits(result[2]) != BitConverter.SingleToInt32Bits(firstOp[0])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.Permute)}<Single>(Vector128<Single><9>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } }
static unsafe int Main(string[] args) { int testResult = Pass; if (Avx.IsSupported) { using (TestTable <float> floatTable = new TestTable <float>(new float[8] { 1, -5, 100, 0, 1, 2, 3, 4 }, new float[4])) { var vf = Avx.BroadcastScalarToVector128((float *)(floatTable.inArrayPtr)); Unsafe.Write(floatTable.outArrayPtr, vf); if (!floatTable.CheckResult((x, y) => BitConverter.SingleToInt32Bits(x) == BitConverter.SingleToInt32Bits(y))) { Console.WriteLine("AVX BroadcastScalarToVector128 failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } } return(testResult); }
private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(Helpers.RoundToPositiveInfinity(firstOp[i])) != BitConverter.SingleToInt32Bits(result[i])) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.RoundToPositiveInfinity)}<Single>(Vector128<Single>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } }
private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.SingleToInt32Bits(result[0]) != (BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0]))) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(result[i]) != (BitConverter.SingleToInt32Bits(left[i]) & BitConverter.SingleToInt32Bits(right[i]))) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector128)}.op_BitwiseAnd<Single>(Vector128<Single>, Vector128<Single>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } }
public static float Not(float op1) => BitConverter.Int32BitsToSingle(~BitConverter.SingleToInt32Bits(op1));
private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { if (BitConverter.SingleToInt32Bits(MathF.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])) { Succeeded = false; } else { for (var i = 1; i < left.Length; i++) { if (BitConverter.SingleToInt32Bits(MathF.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])) { Succeeded = false; break; } } } if (!Succeeded) { Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Max)}<Single>: {method} failed:"); Console.WriteLine($" left: ({string.Join(", ", left)})"); Console.WriteLine($" right: ({string.Join(", ", right)})"); Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } }
private void ValidateResult(UInt32[] firstOp, Single[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.SingleToInt32Bits(Helpers.ConvertToSingle(firstOp[0])) != BitConverter.SingleToInt32Bits(result[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(result[i]) != 0) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ConvertToSingleScalar)}<Single>(Vector64<UInt32>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } }
private void ValidateResult(Single[] firstOp, Single[] secondOp, Single[] thirdOp, Single[] result, [CallerMemberName] string method = "") { if (BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))) { Succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))) { Succeeded = false; break; } } } if (!Succeeded) { Console.WriteLine($"{nameof(Fma)}.{nameof(Fma.MultiplySubtract)}<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(); } }
private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") { for (var i = 0; i < RetElementCount; i++) { if ((i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) { Succeeded = false; break; } } if (!Succeeded) { Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}<Single>(Vector128<Single><9>): {method} failed:"); Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } }
private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[0])) { Succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) { Succeeded = false; break; } } } if (!Succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Sse41)}.{nameof(Sse41.Insert)}<Single>(Vector128<Single>, Vector128<Single>.8): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); } }
public static void ToStringRoundtrip_R(float value) { float result = float.Parse(value.ToString("R")); Assert.Equal(BitConverter.SingleToInt32Bits(value), BitConverter.SingleToInt32Bits(result)); }
public static float BitwiseClear(float op1, float op2) => BitConverter.Int32BitsToSingle(BitwiseClear(BitConverter.SingleToInt32Bits(op1), BitConverter.SingleToInt32Bits(op2)));
private void ValidateResult(Single[] firstOp, Single[] secondOp, Single[] thirdOp, Single[] result, [CallerMemberName] string method = "") { if (BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))) { Succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))) { Succeeded = false; break; } } } if (!Succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Fma)}.{nameof(Fma.MultiplyAdd)}<Single>(Vector128<Single>, Vector128<Single>, Vector128<Single>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" secondOp: ({string.Join(", ", secondOp)})"); TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); } }
public static float Xor(float op1, float op2) => BitConverter.Int32BitsToSingle(Xor(BitConverter.SingleToInt32Bits(op1), BitConverter.SingleToInt32Bits(op2)));
private void ValidateResult(Single[] firstOp, Single[] secondOp, Single[] thirdOp, Single[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.SingleToInt32Bits(Helpers.FusedMultiplyAdd(firstOp[0], secondOp[0], thirdOp[Imm])) != BitConverter.SingleToInt32Bits(result[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(result[i]) != 0) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.FusedMultiplyAddScalarBySelectedScalar)}<Single>(Vector64<Single>, Vector64<Single>, Vector128<Single>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($"secondOp: ({string.Join(", ", secondOp)})"); TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } }
public static float BitwiseSelect(float op1, float op2, float op3) => BitConverter.Int32BitsToSingle(BitwiseSelect(BitConverter.SingleToInt32Bits(op1), BitConverter.SingleToInt32Bits(op2), BitConverter.SingleToInt32Bits(op3)));
static unsafe int Main(string[] args) { int testResult = Pass; if (Sse.IsSupported) { using (TestTable <float> floatTable = new TestTable <float>(new float[4] { 1, -5, 100, 3 }, new float[4])) { var vf = Unsafe.Read <Vector128 <float> >(floatTable.inArrayPtr); Sse.StoreScalar((float *)(floatTable.outArrayPtr), vf); if (!floatTable.CheckResult((x, y) => BitConverter.SingleToInt32Bits(x[0]) == BitConverter.SingleToInt32Bits(y[0]) && BitConverter.SingleToInt32Bits(y[1]) == 0 && BitConverter.SingleToInt32Bits(y[2]) == 0 && BitConverter.SingleToInt32Bits(y[3]) == 0)) { Console.WriteLine("SSE StoreScalar failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } } return(testResult); }
private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") { if (BitConverter.SingleToInt32Bits(firstOp[1]) != BitConverter.SingleToInt32Bits(result[0])) { Succeeded = false; } else { 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]))) { Succeeded = false; break; } } } if (!Succeeded) { 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(); } }
private static IEnumerable <ulong> _2S_F_W_() { // int yield return(0xCF000001CF000001ul); // -2.1474839E9f (-2147483904) yield return(0xCF000000CF000000ul); // -2.14748365E9f (-2147483648) yield return(0xCEFFFFFFCEFFFFFFul); // -2.14748352E9f (-2147483520) yield return(0x4F0000014F000001ul); // 2.1474839E9f (2147483904) yield return(0x4F0000004F000000ul); // 2.14748365E9f (2147483648) yield return(0x4EFFFFFF4EFFFFFFul); // 2.14748352E9f (2147483520) // uint yield return(0x4F8000014F800001ul); // 4.2949678E9f (4294967808) yield return(0x4F8000004F800000ul); // 4.2949673E9f (4294967296) yield return(0x4F7FFFFF4F7FFFFFul); // 4.29496704E9f (4294967040) yield return(0xFF7FFFFFFF7FFFFFul); // -Max Normal (float.MinValue) yield return(0x8080000080800000ul); // -Min Normal yield return(0x807FFFFF807FFFFFul); // -Max Subnormal yield return(0x8000000180000001ul); // -Min Subnormal (-float.Epsilon) yield return(0x7F7FFFFF7F7FFFFFul); // +Max Normal (float.MaxValue) yield return(0x0080000000800000ul); // +Min Normal yield return(0x007FFFFF007FFFFFul); // +Max Subnormal yield return(0x0000000100000001ul); // +Min Subnormal (float.Epsilon) if (!NoZeros) { yield return(0x8000000080000000ul); // -Zero yield return(0x0000000000000000ul); // +Zero } if (!NoInfs) { yield return(0xFF800000FF800000ul); // -Infinity yield return(0x7F8000007F800000ul); // +Infinity } if (!NoNaNs) { yield return(0xFFC00000FFC00000ul); // -QNaN (all zeros payload) (float.NaN) yield return(0xFFBFFFFFFFBFFFFFul); // -SNaN (all ones payload) yield return(0x7FC000007FC00000ul); // +QNaN (all zeros payload) (-float.NaN) (DefaultNaN) yield return(0x7FBFFFFF7FBFFFFFul); // +SNaN (all ones payload) } for (int cnt = 1; cnt <= RndCnt; cnt++) { ulong rnd1 = (uint)BitConverter.SingleToInt32Bits( (float)((int)TestContext.CurrentContext.Random.NextUInt())); ulong rnd2 = (uint)BitConverter.SingleToInt32Bits( (float)((uint)TestContext.CurrentContext.Random.NextUInt())); ulong rnd3 = GenNormalS(); ulong rnd4 = GenSubnormalS(); yield return((rnd1 << 32) | rnd1); yield return((rnd2 << 32) | rnd2); yield return((rnd3 << 32) | rnd3); yield return((rnd4 << 32) | rnd4); } }
private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { if ((BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])) { Succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if ((BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])) { Succeeded = false; break; } } } if (!Succeeded) { 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)})"); Console.WriteLine(); } }
private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.SingleToInt32Bits(Helpers.AbsoluteCompareGreaterThanOrEqual(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(result[i]) != 0) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.AbsoluteCompareGreaterThanOrEqualScalar)}<Single>(Vector64<Single>, Vector64<Single>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } }
public void WriteFloat(float value) => WriteInt(BitConverter.SingleToInt32Bits(value));
private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { if (BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])) { Succeeded = false; } else { 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])))) { Succeeded = false; break; } } } if (!Succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.AddSubtract)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); } }
public static Operand ConstF(float value) { return(new Operand(OperandType.Constant, BitConverter.SingleToInt32Bits(value))); }
private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(Helpers.Multiply(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.Multiply)}<Single>(Vector64<Single>, Vector64<Single>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } }
/// <inheritdoc /> public int SingleToInt32Bits(float value) { return(BitConverter.SingleToInt32Bits(value)); }