diff --git a/Src/ILGPU.Tests/CompareFloatOperations.tt b/Src/ILGPU.Tests/CompareFloatOperations.tt index 2d0880ec61..22840ca686 100644 --- a/Src/ILGPU.Tests/CompareFloatOperations.tt +++ b/Src/ILGPU.Tests/CompareFloatOperations.tt @@ -1,6 +1,6 @@ // --------------------------------------------------------------------------------------- // ILGPU -// Copyright (c) 2021 ILGPU Project +// Copyright (c) 2021-2023 ILGPU Project // www.ilgpu.net // // File: CompareFloatOperations.tt/CompareFloatOperations.cs @@ -59,6 +59,7 @@ namespace ILGPU.Tests <# foreach (var (operationName, infix) in operationConfigurations) { #> <# foreach (var type in FloatTypes) { #> +<# bool isFP16 = type == FloatTypes[0]; #> <# var floatRanges = GetFloatRanges(type, true, true, true, false); #> <# var baseName = "_" + operationName + "_" + type.Name; #> <# var testName = "CompareOperation" + baseName; #> @@ -83,23 +84,30 @@ namespace ILGPU.Tests <# } #> }; +<# if (isFP16) { #> + [SkippableTheory] +<# } else { #> [Theory] +<# } #> [MemberData(nameof(<#= testName #>Data))] [KernelMethod(nameof(<#= kernelName #>))] public void <#= testName #>( <#= type.Type #> left, <#= type.Type #> right) { - const int length = 32; - using var a = Accelerator.Allocate1D<<#= type.Type #>>(length); - using var b = Accelerator.Allocate1D<<#= type.Type #>>(length); - using var c = Accelerator.Allocate1D(length); +<# if (isFP16) { #> + Skip.If(!Accelerator.Capabilities.Float16); +<# } #> + const int Length = 32; + using var a = Accelerator.Allocate1D<<#= type.Type #>>(Length); + using var b = Accelerator.Allocate1D<<#= type.Type #>>(Length); + using var c = Accelerator.Allocate1D(Length); Initialize(a.View, left); Initialize(b.View, right); - Execute(length, a.View, b.View, c.View); + Execute(Length, a.View, b.View, c.View); var result = left <#= infix #> right ? 1 : 0; - var reference = Enumerable.Repeat(result, length).ToArray(); + var reference = Enumerable.Repeat(result, Length).ToArray(); Verify(c.View, reference); } @@ -107,6 +115,7 @@ namespace ILGPU.Tests <# } #> <# foreach (var type in FloatTypes) { #> +<# bool isFP16 = type == FloatTypes[0]; #> <# foreach (var (limitName, limitFormat) in floatLimits) { #> <# var baseName = "_" + limitName + "_" + type.Name; #> <# var testName = "Constant" + baseName; #> @@ -124,10 +133,17 @@ namespace ILGPU.Tests output[index] = input[index] == <#= testValue #> ? 1 : 0; } +<# if (isFP16) { #> + [SkippableFact] +<# } else { #> [Fact] +<# } #> [KernelMethod(nameof(<#= kernelName #>))] public void <#= testName #>() { +<# if (isFP16) { #> + Skip.If(!Accelerator.Capabilities.Float16); +<# } #> var inputArray = new [] { <#= type.FormatNumber("0.0") #>, <#= testValue #> }; var expected = inputArray.Select( x => x == <#= testValue #> ? 1 : 0).ToArray(); diff --git a/Src/ILGPU.Tests/ConvertFloatOperations.tt b/Src/ILGPU.Tests/ConvertFloatOperations.tt index e890809408..39502136cf 100644 --- a/Src/ILGPU.Tests/ConvertFloatOperations.tt +++ b/Src/ILGPU.Tests/ConvertFloatOperations.tt @@ -1,6 +1,6 @@ // --------------------------------------------------------------------------------------- // ILGPU -// Copyright (c) 2021 ILGPU Project +// Copyright (c) 2021-2023 ILGPU Project // www.ilgpu.net // // File: ConvertFloatOperations.tt/ConvertFloatOperations.cs @@ -34,7 +34,7 @@ namespace ILGPU.Tests <# foreach (var type in FloatTypes) { #> <# foreach (var targetType in types) { #> -<# var floatRanges = GetFloatRanges(type, true); #> +<# bool isFP16 = type == FloatTypes[0] || targetType == FloatTypes[0]; #> <# var baseName = "_" + type.Name + "_" + targetType.Name; #> <# var testName = "ConvertOperation" + baseName; #> <# var kernelName = "ConvertOperationKernel" + baseName; #> @@ -46,7 +46,11 @@ namespace ILGPU.Tests b[index] = (<#= targetType.Type #>)a[index]; } +<# if (isFP16) { #> + [SkippableTheory] +<# } else { #> [Theory] +<# } #> [InlineData(0.0f)] [InlineData(1.0f)] [InlineData((float)Math.PI)] @@ -56,15 +60,18 @@ namespace ILGPU.Tests [KernelMethod(nameof(<#= kernelName #>))] public void <#= testName #>(float value) { +<# if (isFP16) { #> + Skip.If(!Accelerator.Capabilities.Float16); +<# } #> var convertedValue = (<#= type.Type #>)value; - const int length = 32; - using var a = Accelerator.Allocate1D<<#= type.Type #>>(length); - using var b = Accelerator.Allocate1D<<#= targetType.Type #>>(length); + const int Length = 32; + using var a = Accelerator.Allocate1D<<#= type.Type #>>(Length); + using var b = Accelerator.Allocate1D<<#= targetType.Type #>>(Length); Initialize(a.View, convertedValue); - Execute(length, a.View, b.View); + Execute(Length, a.View, b.View); var result = (<#= targetType.Type #>)convertedValue; - var reference = Enumerable.Repeat(result, length).ToArray(); + var reference = Enumerable.Repeat(result, Length).ToArray(); Verify(b.View, reference); } diff --git a/Src/ILGPU.Tests/ConvertIntOperations.Generated.tt b/Src/ILGPU.Tests/ConvertIntOperations.Generated.tt index 6ebcab31b2..655cbdb068 100644 --- a/Src/ILGPU.Tests/ConvertIntOperations.Generated.tt +++ b/Src/ILGPU.Tests/ConvertIntOperations.Generated.tt @@ -1,6 +1,6 @@ // --------------------------------------------------------------------------------------- // ILGPU -// Copyright (c) 2021 ILGPU Project +// Copyright (c) 2021-2023 ILGPU Project // www.ilgpu.net // // File: ConvertIntOperations.Generated.tt/ConvertIntOperations.Generated.cs @@ -30,6 +30,7 @@ namespace ILGPU.Tests { <# foreach (var type in IntTypes) { #> <# foreach (var targetType in types) { #> +<# bool isFP16 = type == FloatTypes[0] || targetType == FloatTypes[0]; #> <# var baseName = "_" + type.Name + "_" + targetType.Name; #> <# var testName = "ConvertOperation" + baseName; #> <# var kernelName = "ConvertOperationKernel" + baseName; #> @@ -41,9 +42,11 @@ namespace ILGPU.Tests b[index] = (<#= targetType.Type #>)a[index]; } - [Theory] <# // Half conversions of these values is implementation specific in these cases #> -<# if (targetType != FloatTypes[0]) { #> +<# if (isFP16) { #> + [SkippableTheory] +<# } else { #> + [Theory] [InlineData(<#= type.Type #>.MaxValue)] [InlineData(<#= type.Type #>.MinValue)] [InlineData(<#= type.Type #>.MinValue + 1)] @@ -54,6 +57,9 @@ namespace ILGPU.Tests [KernelMethod(nameof(<#= kernelName #>))] public void <#= testName #>(<#= type.Type #> value) { +<# if (isFP16) { #> + Skip.If(!Accelerator.Capabilities.Float16); +<# } #> const int length = 32; using var a = Accelerator.Allocate1D<<#= type.Type #>>(length); using var b = Accelerator.Allocate1D<<#= targetType.Type #>>(length); @@ -75,10 +81,18 @@ namespace ILGPU.Tests } } +<# if (targetType != FloatTypes[0]) { #> [Fact] +<# } else { #> + [SkippableFact] +<# } #> [KernelMethod(nameof(<#= kernelName #>_MaxValue))] public void <#= testName #>_MaxValue() { +<# if (targetType == FloatTypes[0]) { #> + Skip.If(!Accelerator.Capabilities.Float16); +<# } #> + const int length = 32; using var output = Accelerator.Allocate1D<<#= targetType.Type #>>(length); Execute(length, output.View); diff --git a/Src/ILGPU.Tests/FixedBuffers.tt b/Src/ILGPU.Tests/FixedBuffers.tt index fcb7eae41e..0163c3fcbf 100644 --- a/Src/ILGPU.Tests/FixedBuffers.tt +++ b/Src/ILGPU.Tests/FixedBuffers.tt @@ -142,8 +142,9 @@ namespace ILGPU.Tests ref FixedBufferStruct<#= type.Name #> value, <#= type.Type #> scalarValue) { - for (int i = 0; i < Length; ++i) - value.Data[i] += scalarValue; +<# for (int i = 0; i < FixedBufferLength; ++i) { #> + value.Data[<#= i #>] += scalarValue; +<# } #> } internal static void FixedBuffer<#= type.Name #>Kernel( @@ -265,7 +266,7 @@ namespace ILGPU.Tests Accelerator.Allocate1D>(1); Execute(Length, buffer1.View, buffer2.View, buffer3.View, fixedBuffers.View); - + <#= type.Type #> scalarValue = 2; var expected = new[] @@ -274,7 +275,7 @@ namespace ILGPU.Tests }; Verify(fixedBuffers.View, expected); } - + internal static readonly MultiFixedBufferStruct<#= type.Name #> Local<#= type.Name #>Struct = new MultiFixedBufferStruct<#= type.Name #>((<#= type.Type #>)2); @@ -289,7 +290,7 @@ namespace ILGPU.Tests data2[index] = Local<#= type.Name #>Struct.B[index]; data3[index] = Local<#= type.Name #>Struct.C[index]; } - + [Fact] [KernelMethod(nameof(GetStaticMultiFixedBuffer<#= type.Name #>Kernel))] public void GetStaticMultiFixedBuffer<#= type.Name #>() diff --git a/Src/ILGPU.Tests/Generic/TestData.cs b/Src/ILGPU.Tests/Generic/TestData.cs index 369c679f08..66628b83fc 100644 --- a/Src/ILGPU.Tests/Generic/TestData.cs +++ b/Src/ILGPU.Tests/Generic/TestData.cs @@ -472,6 +472,18 @@ public void Serialize(IXunitSerializationInfo info) for (int i = 0; i < Length; ++i) info.AddValue(nameof(Data) + i, Data[i]); } + + public override string ToString() + { + string result = string.Empty; + for (int i = 0; i < Length; ++i) + { + result += Data[i]; + if (i + 1 < Length) + result += ", "; + } + return result; + } } public unsafe struct LongFixedBufferStruct : IXunitSerializable @@ -497,6 +509,18 @@ public void Serialize(IXunitSerializationInfo info) for (int i = 0; i < Length; ++i) info.AddValue(nameof(Data) + i, Data[i]); } + + public override string ToString() + { + string result = string.Empty; + for (int i = 0; i < Length; ++i) + { + result += Data[i]; + if (i + 1 < Length) + result += ", "; + } + return result; + } } #endregion diff --git a/Src/ILGPU.Tests/GridOperations.cs b/Src/ILGPU.Tests/GridOperations.cs index 9bdc8010ae..151f652e84 100644 --- a/Src/ILGPU.Tests/GridOperations.cs +++ b/Src/ILGPU.Tests/GridOperations.cs @@ -1,6 +1,6 @@ // --------------------------------------------------------------------------------------- // ILGPU -// Copyright (c) 2021 ILGPU Project +// Copyright (c) 2021-2023 ILGPU Project // www.ilgpu.net // // File: GridOperations.cs @@ -37,7 +37,7 @@ internal static void GridDimensionKernel( Debug.Assert(Grid.IdxZ < Grid.DimZ); } - [Theory] + [SkippableTheory] [InlineData(1, 0, 0)] [InlineData(0, 1, 0)] [InlineData(0, 0, 1)] @@ -54,6 +54,9 @@ public void GridDimension(int xMask, int yMask, int zMask) Math.Max(i * zMask, 1)), Index3D.One); + Skip.If(extent.GridDim.Y > Accelerator.MaxGridSize.Y); + Skip.If(extent.GridDim.Z > Accelerator.MaxGridSize.Z); + Execute(extent, buffer.View); var expected = new int[] diff --git a/Src/ILGPU.Tests/GroupOperations.cs b/Src/ILGPU.Tests/GroupOperations.cs index fcc551deeb..1a396dfcbc 100644 --- a/Src/ILGPU.Tests/GroupOperations.cs +++ b/Src/ILGPU.Tests/GroupOperations.cs @@ -1,6 +1,6 @@ // --------------------------------------------------------------------------------------- // ILGPU -// Copyright (c) 2021 ILGPU Project +// Copyright (c) 2021-2023 ILGPU Project // www.ilgpu.net // // File: GroupOperations.cs diff --git a/Src/ILGPU.Tests/ReinterpretCasts.tt b/Src/ILGPU.Tests/ReinterpretCasts.tt index 693c909853..bb3948f545 100644 --- a/Src/ILGPU.Tests/ReinterpretCasts.tt +++ b/Src/ILGPU.Tests/ReinterpretCasts.tt @@ -1,6 +1,6 @@ // --------------------------------------------------------------------------------------- // ILGPU -// Copyright (c) 2021 ILGPU Project +// Copyright (c) 2021-2023 ILGPU Project // www.ilgpu.net // // File: ReinterpretCasts.tt/ReinterpretCasts.cs @@ -41,10 +41,13 @@ namespace ILGPU.Tests data[index] = Interop.FloatAsInt(value); } - [Fact] + [SkippableFact] [KernelMethod(nameof(<#= floatType.Name #>AsIntKernel))] public void <#= floatType.Name #>AsInt() { +<# if (floatType == FloatTypes[0]) { #> + Skip.If(!Accelerator.Capabilities.Float16); +<# } #> var floatValue = (<#= floatType.Type #>)2.0; using var data = Accelerator.Allocate1D<<#= intType.Type #>>(Length); Execute(Length, data.View, floatValue); @@ -63,10 +66,13 @@ namespace ILGPU.Tests data[index] = Interop.IntAsFloat(value); } - [Fact] + [SkippableFact] [KernelMethod(nameof(IntAs<#= floatType.Name #>Kernel))] public void IntAs<#= floatType.Name #>() { +<# if (floatType == FloatTypes[0]) { #> + Skip.If(!Accelerator.Capabilities.Float16); +<# } #> var intValue = Interop.FloatAsInt((<#= floatType.Type #>)2.0); using var data = Accelerator.Allocate1D<<#= floatType.Type #>>(Length); Execute(Length, data.View, intValue); diff --git a/Src/ILGPU.Tests/SharedMemory.cs b/Src/ILGPU.Tests/SharedMemory.cs index 80ca30fdf4..1b635688b8 100644 --- a/Src/ILGPU.Tests/SharedMemory.cs +++ b/Src/ILGPU.Tests/SharedMemory.cs @@ -149,7 +149,7 @@ internal static void DynamicSharedMemoryKernel( data[idx] = value + DynamicSharedMemoryNested(); } - [Theory] + [SkippableTheory] [InlineData(1)] [InlineData(10)] [InlineData(32)] @@ -386,4 +386,4 @@ public void MultiDimensionalSharedMemory3DDenseZY() Verify(buffer.View, expected); } } -} \ No newline at end of file +} diff --git a/Src/ILGPU.Tests/UnaryFloatOperations.cs b/Src/ILGPU.Tests/UnaryFloatOperations.cs index 36b9d0f018..1a65feefed 100644 --- a/Src/ILGPU.Tests/UnaryFloatOperations.cs +++ b/Src/ILGPU.Tests/UnaryFloatOperations.cs @@ -46,7 +46,7 @@ internal static void IsPredicateF16Kernel( data[index + 4] = Half.IsNaN(value) ? 1 : 0; } - [Theory] + [SkippableTheory] [MemberData(nameof(HalfData))] [KernelMethod(nameof(IsPredicateF16Kernel))] public void IsPredicateF16( @@ -56,6 +56,8 @@ public void IsPredicateF16( bool isPositiveInfinity, bool isNegativeInfinity) { + Skip.If(!Accelerator.Capabilities.Float16); + using var buffer = Accelerator.Allocate1D(5); Execute(1, buffer.View, value); diff --git a/Src/ILGPU.Tests/WarpOperations.cs b/Src/ILGPU.Tests/WarpOperations.cs index 518df6357c..3e126f4160 100644 --- a/Src/ILGPU.Tests/WarpOperations.cs +++ b/Src/ILGPU.Tests/WarpOperations.cs @@ -1,6 +1,6 @@ // --------------------------------------------------------------------------------------- // ILGPU -// Copyright (c) 2021-2022 ILGPU Project +// Copyright (c) 2021-2023 ILGPU Project // www.ilgpu.net // // File: WarpOperations.cs @@ -286,7 +286,7 @@ internal static void DivergentWarpBarrierKernel( data[index] = sharedMemory[Warp.WarpIdx] * Warp.WarpSize + value; } - [Theory] + [SkippableTheory] [InlineData(1)] [InlineData(2)] [InlineData(3)]