Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #21361 from fiigii/x64tests
Browse files Browse the repository at this point in the history
Improve hardware intrinsic tests
  • Loading branch information
CarolEidt authored Dec 7, 2018
2 parents 78de81c + ddd6ddb commit 02d37e4
Show file tree
Hide file tree
Showing 72 changed files with 1,147 additions and 592 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ScalarBinaryOpTest__AndNotUInt64()
_data2 = TestLibrary.Generator.GetUInt64();
}

public bool IsSupported => Bmi1.X64.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));
public bool IsSupported => Bmi1.X64.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ScalarUnaryOpTest__ExtractLowestSetBitUInt64()
_data = TestLibrary.Generator.GetUInt64();
}

public bool IsSupported => Bmi1.X64.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));
public bool IsSupported => Bmi1.X64.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt64()
_data = TestLibrary.Generator.GetUInt64();
}

public bool IsSupported => Bmi1.X64.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));
public bool IsSupported => Bmi1.X64.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ScalarUnaryOpTest__ResetLowestSetBitUInt64()
_data = TestLibrary.Generator.GetUInt64();
}

public bool IsSupported => Bmi1.X64.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));
public bool IsSupported => Bmi1.X64.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ScalarUnaryOpTest__TrailingZeroCountUInt64()
_data = TestLibrary.Generator.GetUInt64();
}

public bool IsSupported => Bmi1.X64.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));
public bool IsSupported => Bmi1.X64.IsSupported;

public bool Succeeded { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion tests/src/JIT/HardwareIntrinsics/X86/Bmi1/AndNot.UInt32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ScalarBinaryOpTest__AndNotUInt32()
_data2 = TestLibrary.Generator.GetUInt32();
}

public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong))));
public bool IsSupported => Bmi1.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ScalarUnaryOpTest__ExtractLowestSetBitUInt32()
_data = TestLibrary.Generator.GetUInt32();
}

public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong))));
public bool IsSupported => Bmi1.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt32()
_data = TestLibrary.Generator.GetUInt32();
}

public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong))));
public bool IsSupported => Bmi1.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ScalarUnaryOpTest__ResetLowestSetBitUInt32()
_data = TestLibrary.Generator.GetUInt32();
}

public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong))));
public bool IsSupported => Bmi1.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ScalarUnaryOpTest__TrailingZeroCountUInt32()
_data = TestLibrary.Generator.GetUInt32();
}

public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong))));
public bool IsSupported => Bmi1.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ScalarBinaryOpTest__ParallelBitDepositUInt64()
_data2 = TestLibrary.Generator.GetUInt64();
}

public bool IsSupported => Bmi2.X64.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));
public bool IsSupported => Bmi2.X64.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ScalarBinaryOpTest__ParallelBitExtractUInt64()
_data2 = TestLibrary.Generator.GetUInt64();
}

public bool IsSupported => Bmi2.X64.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong))));
public bool IsSupported => Bmi2.X64.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ScalarBinaryOpTest__ParallelBitDepositUInt32()
_data2 = TestLibrary.Generator.GetUInt32();
}

public bool IsSupported => Bmi2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong))));
public bool IsSupported => Bmi2.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ScalarBinaryOpTest__ParallelBitExtractUInt32()
_data2 = TestLibrary.Generator.GetUInt32();
}

public bool IsSupported => Bmi2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong))));
public bool IsSupported => Bmi2.IsSupported;

public bool Succeeded { get; set; }

Expand Down
12 changes: 11 additions & 1 deletion tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ static int Main(string[] args)
Convert.ToBoolean(typeof(Avx).GetMethod(issupported).Invoke(null, null)) != Avx.IsSupported ||
Convert.ToBoolean(typeof(Avx2).GetMethod(issupported).Invoke(null, null)) != Avx2.IsSupported ||
Convert.ToBoolean(typeof(Lzcnt).GetMethod(issupported).Invoke(null, null)) != Lzcnt.IsSupported ||
Convert.ToBoolean(typeof(Popcnt).GetMethod(issupported).Invoke(null, null)) != Popcnt.IsSupported
Convert.ToBoolean(typeof(Popcnt).GetMethod(issupported).Invoke(null, null)) != Popcnt.IsSupported ||
Convert.ToBoolean(typeof(Bmi1).GetMethod(issupported).Invoke(null, null)) != Bmi1.IsSupported ||
Convert.ToBoolean(typeof(Bmi2).GetMethod(issupported).Invoke(null, null)) != Bmi2.IsSupported ||
Convert.ToBoolean(typeof(Sse.X64).GetMethod(issupported).Invoke(null, null)) != Sse.X64.IsSupported ||
Convert.ToBoolean(typeof(Sse2.X64).GetMethod(issupported).Invoke(null, null)) != Sse2.X64.IsSupported ||
Convert.ToBoolean(typeof(Sse41.X64).GetMethod(issupported).Invoke(null, null)) != Sse41.X64.IsSupported ||
Convert.ToBoolean(typeof(Sse42.X64).GetMethod(issupported).Invoke(null, null)) != Sse42.X64.IsSupported ||
Convert.ToBoolean(typeof(Lzcnt.X64).GetMethod(issupported).Invoke(null, null)) != Lzcnt.X64.IsSupported ||
Convert.ToBoolean(typeof(Popcnt.X64).GetMethod(issupported).Invoke(null, null)) != Popcnt.X64.IsSupported ||
Convert.ToBoolean(typeof(Bmi1.X64).GetMethod(issupported).Invoke(null, null)) != Bmi1.X64.IsSupported ||
Convert.ToBoolean(typeof(Bmi2.X64).GetMethod(issupported).Invoke(null, null)) != Bmi2.X64.IsSupported
)
{
result = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace JIT.HardwareIntrinsics.X86
_dataTable = new SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}>(_data, new {RetBaseType}[RetElementCount], LargestVectorSize);
}

public bool IsSupported => {Isa}.IsSupported && (Environment.Is64BitProcess || ((typeof({RetBaseType}) != typeof(long)) && (typeof({RetBaseType}) != typeof(ulong))));
public bool IsSupported => {Isa}.IsSupported;

public bool Succeeded { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ private static readonly (string templateFileName, Dictionary<string, string> tem
("SimpleUnOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertToVector128Single", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((float)firstOp[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((i < 2) ? BitConverter.SingleToInt32Bits((float)firstOp[i]) : 0)"}),
("SimpleUnOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertToVector128Single", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((float)firstOp[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits((float)firstOp[i])"}),
("SimpleBinOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128Double", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "(double)right != result[0]"}),
("ScalarSimdUnOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128Int32", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "firstOp != result[0]", ["ValidateRemainingResults"] = "false"}),
("ScalarSimdUnOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128UInt32", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "firstOp != result[0]", ["ValidateRemainingResults"] = "false"}),
("SimpleBinOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Divide", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
("SimpleBinOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "DivideScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
("ExtractScalarTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}),
Expand Down Expand Up @@ -324,6 +326,8 @@ private static readonly (string templateFileName, Dictionary<string, string> tem
("SimdScalarUnOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2.X64", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertToUInt64", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "firstOp[0] != result"}),
("SimdScalarUnOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2.X64", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertToInt64WithTruncation", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "(long)firstOp[0] != result"}),
("SimpleBinOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2.X64", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128Double", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "(double)right != result[0]"}),
("ScalarSimdUnOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2.X64", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128Int64", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "firstOp != result[0]", ["ValidateRemainingResults"] = "false"}),
("ScalarSimdUnOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2.X64", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128UInt64", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "firstOp != result[0]", ["ValidateRemainingResults"] = "false"}),
};

private static readonly (string templateFileName, Dictionary<string, string> templateData)[] Sse3Inputs = new []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace JIT.HardwareIntrinsics.X86
_dataTable = new SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}>(_data, new {RetBaseType}[RetElementCount], LargestVectorSize);
}

public bool IsSupported => {Isa}.IsSupported && (Environment.Is64BitProcess || ((typeof({RetBaseType}) != typeof(long)) && (typeof({RetBaseType}) != typeof(ulong))));
public bool IsSupported => {Isa}.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace JIT.HardwareIntrinsics.X86
_data2 = {NextValueOp2};
}

public bool IsSupported => {Isa}.IsSupported && (Environment.Is64BitProcess || ((typeof({RetBaseType}) != typeof(long)) && (typeof({RetBaseType}) != typeof(ulong))));
public bool IsSupported => {Isa}.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace JIT.HardwareIntrinsics.X86
_dataTable = new ScalarSimdUnaryOpTest__DataTable<{RetBaseType}>(new {RetBaseType}[RetElementCount], LargestVectorSize);
}

public bool IsSupported => {Isa}.IsSupported && (Environment.Is64BitProcess || ((typeof({RetBaseType}) != typeof(long)) && (typeof({RetBaseType}) != typeof(ulong))));
public bool IsSupported => {Isa}.IsSupported;

public bool Succeeded { get; set; }

Expand Down Expand Up @@ -255,7 +255,7 @@ namespace JIT.HardwareIntrinsics.X86

if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>): {method} failed:");
TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1BaseType}): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace JIT.HardwareIntrinsics.X86
_data = {NextValueOp1};
}

public bool IsSupported => {Isa}.IsSupported && (Environment.Is64BitProcess || ((typeof({RetBaseType}) != typeof(long)) && (typeof({RetBaseType}) != typeof(ulong))));
public bool IsSupported => {Isa}.IsSupported;

public bool Succeeded { get; set; }

Expand Down
Loading

0 comments on commit 02d37e4

Please sign in to comment.