Skip to content

Commit

Permalink
Add tests for ILGPU types and intrinsics and finish renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Yey007 committed Mar 30, 2024
1 parent e642cd2 commit 4c00f4e
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 32 deletions.
5 changes: 3 additions & 2 deletions Src/ILGPU.Analyzers.Tests/ManagedTypeAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ public class ManagedTypeAnalyzer
{
[Theory]
[InlineData("Simple")]
[InlineData("Complex")]
[InlineData("Arrays")]
[InlineData("Functions")]
[InlineData("Constructors")]
[InlineData("ManagedUnmanaged")]
[InlineData("LoadDiscovery")]
[InlineData("ILGPUTypesIntrinsics")]
public async Task FileTests(string file)
{
// In build, we copy all programs to output directory. See ILGPU.Analyzers.Tests.csproj
var code = await File.ReadAllTextAsync($"Programs/RefType/{file}.cs");
var code = await File.ReadAllTextAsync($"Programs/ManagedType/{file}.cs");
await VerifyCS.Verify(code, settings => settings.UseParameters(file));
}
}
2 changes: 1 addition & 1 deletion Src/ILGPU.Analyzers.Tests/Programs/ManagedType/Arrays.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ILGPU.Runtime;

namespace ILGPU.Analyzers.Tests.Programs.RefType;
namespace ILGPU.Analyzers.Tests.Programs.ManagedType;

class Arrays
{
Expand Down
2 changes: 1 addition & 1 deletion Src/ILGPU.Analyzers.Tests/Programs/ManagedType/Complex.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ILGPU.Runtime;

namespace ILGPU.Analyzers.Tests.Programs.RefType;
namespace ILGPU.Analyzers.Tests.Programs.ManagedType;

class ManagedUnmanaged
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ILGPU.Runtime;

namespace ILGPU.Analyzers.Tests.Programs.RefType;
namespace ILGPU.Analyzers.Tests.Programs.ManagedType;

class Constructors
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ILGPU.Runtime;

namespace ILGPU.Analyzers.Tests.Programs.RefType;
namespace ILGPU.Analyzers.Tests.Programs.ManagedType;

class Functions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;

namespace ILGPU.Analyzers.Tests.Programs.ManagedType;

class ILGPUTypesIntrinsics
{
static void Kernel(Index1D index, ArrayView<int> input)
{
var a = input.SubView(0, 10);
int b = a[index];
int c = Warp.WarpIdx;
Group.Barrier();
}

static void Run()
{
using var context = Context.CreateDefault();
var device = context.GetPreferredDevice(false);
using var accelerator = device.CreateAccelerator(context);

using var input = accelerator.Allocate1D<int>(1024);

var kernel =
accelerator.LoadAutoGroupedStreamKernel<Index1D, ArrayView<int>>(Kernel);

kernel(input.IntExtent, input.View);

accelerator.Synchronize();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ILGPU.Runtime;

namespace ILGPU.Analyzers.Tests.Programs.RefType;
namespace ILGPU.Analyzers.Tests.Programs.ManagedType;

class Functions
{
Expand Down
2 changes: 1 addition & 1 deletion Src/ILGPU.Analyzers.Tests/Programs/ManagedType/Simple.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ILGPU.Runtime;

namespace ILGPU.Analyzers.Tests.Programs.RefType;
namespace ILGPU.Analyzers.Tests.Programs.ManagedType;

class Simple
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
WarningLevel: 1,
Location: : (29,25)-(29,42),
MessageFormat: Type '{0}' is an array of type '{1}', which is a managed type. Arrays of managed types cannot be used in kernels.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Arrays.RefType[]' is an array of type 'ILGPU.Analyzers.Tests.Programs.RefType.Arrays.RefType', which is a managed type. Arrays of managed types cannot be used in kernels.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Arrays.RefType[]' is an array of type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Arrays.RefType', which is a managed type. Arrays of managed types cannot be used in kernels.,
Category: Usage
},
{
Expand All @@ -16,7 +16,7 @@
WarningLevel: 1,
Location: : (29,27)-(29,40),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Arrays.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Arrays.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
WarningLevel: 1,
Location: : (40,22)-(40,35),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.ManagedUnmanaged.Managed' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.ManagedUnmanaged.Managed' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
WarningLevel: 1,
Location: : (17,20)-(17,33),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Constructors.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Constructors.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
WarningLevel: 1,
Location: : (20,27)-(20,40),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
},
{
Expand All @@ -16,7 +16,7 @@
WarningLevel: 1,
Location: : (14,27)-(14,40),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
},
{
Expand All @@ -26,7 +26,7 @@
WarningLevel: 1,
Location: : (32,15)-(32,28),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
WarningLevel: 1,
Location: : (14,21)-(14,34),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
},
{
Expand All @@ -16,7 +16,7 @@
WarningLevel: 1,
Location: : (19,21)-(19,34),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
},
{
Expand All @@ -26,7 +26,7 @@
WarningLevel: 1,
Location: : (24,21)-(24,34),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
},
{
Expand All @@ -36,7 +36,7 @@
WarningLevel: 1,
Location: : (29,21)-(29,34),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
},
{
Expand All @@ -46,7 +46,7 @@
WarningLevel: 1,
Location: : (34,21)-(34,34),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
},
{
Expand All @@ -56,7 +56,7 @@
WarningLevel: 1,
Location: : (39,21)-(39,34),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Functions.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
WarningLevel: 1,
Location: : (13,22)-(13,35),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Simple.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Simple.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
},
{
Expand All @@ -16,7 +16,7 @@
WarningLevel: 1,
Location: : (14,38)-(14,45),
MessageFormat: Type '{0}' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.RefType.Simple.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Message: Type 'ILGPU.Analyzers.Tests.Programs.ManagedType.Simple.RefType' is a managed type. Managed types like classes cannot be used in kernels, except for arrays of unmanaged types.,
Category: Usage
}
]
27 changes: 18 additions & 9 deletions Src/ILGPU.Analyzers/ILGPU.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
</ItemGroup>

<ItemGroup>
<Compile Update="Resources\DiagnosticCategory.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>DiagnosticCategory.resx</DependentUpon>
</Compile>
<Compile Update="Resources\ILA001_StructMustBePartial.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand All @@ -51,13 +46,19 @@
<AutoGen>True</AutoGen>
<DependentUpon>ILA002_ContainingTypeMustBePartial.resx</DependentUpon>
</Compile>
<Compile Update="Resources\ILA003_ManagedTypeInKernel.resx">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>ILA003_ManagedTypeInKernel.Designer.cs</DependentUpon>
</Compile>
<Compile Update="Resources\ILA004_ManagedTypeArrayInKernel.resx">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>ILA004_ManagedTypeArrayInKernel.Designer.cs</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Resources\DiagnosticCategory.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>DiagnosticCategory.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Resources\ILA001_StructMustBePartial.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ILA001_StructMustBePartial.Designer.cs</LastGenOutput>
Expand All @@ -66,6 +67,14 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ILA002_ContainingTypeMustBePartial.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Resources\ILA003_ManagedTypeInKernel.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ILA003_ManagedTypeInKernel.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Resources\ILA004_ManagedTypeArrayInKernel.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ILA004_ManagedTypeArrayInKernel.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

</Project>

0 comments on commit 4c00f4e

Please sign in to comment.