Skip to content

Commit

Permalink
Added core ILGPU Velocity tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rs-mt committed Mar 2, 2023
1 parent 747dc6a commit 699fb91
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ Src/ILGPU.Tests/.test.runsettings
Src/ILGPU.Tests.CPU/Configurations.cs
Src/ILGPU.Tests.Cuda/Configurations.cs
Src/ILGPU.Tests.OpenCL/Configurations.cs
Src/ILGPU.Tests.Velocity/Configurations.cs

# Generated test source files (Algorithms)
Src/ILGPU.Algorithms.Tests/Generic/ConfigurationBase.cs
Expand Down
51 changes: 51 additions & 0 deletions Src/ILGPU.Tests.Velocity/Configurations.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2023 ILGPU Project
// www.ilgpu.net
//
// File: Configurations.tt/Configurations.cs
//
// This file is part of ILGPU and is distributed under the University of Illinois Open
// Source License. See LICENSE.txt for details.
// ---------------------------------------------------------------------------------------

<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ include file="../ILGPU.Tests/Generic/ConfigurationBase.tt" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.IO" #>
using Xunit;
using Xunit.Abstractions;

<#
var configurationFile = Host.ResolvePath("../ILGPU.Tests/Configurations.txt");
var configurations = TestConfig.Parse(configurationFile);
#>
namespace ILGPU.Tests.Velocity
{
<# foreach (var (test, level, collection) in configurations) { #>
<# var name = $"Velocity{test}_{level}"; #>
[Collection("VelocityContextCollection<#= collection #>")]
public sealed partial class <#= name #> : <#= test #>
{
public <#= name #>(
ITestOutputHelper output,
VelocityTestContext<#= collection #> testContext)
: base(output, testContext)
{ }
}

<# } #>
<# foreach (var (config, level) in TestConfig.AllConfigurations) { #>
public class VelocityTestContext<#= config #> : VelocityTestContext
{
public VelocityTestContext<#= config #>()
: base(OptimizationLevel.<#= level #>)
{ }
}

[CollectionDefinition("VelocityContextCollection<#= config #>")]
public class VelocityContextCollection<#= config #> :
ICollectionFixture<VelocityTestContext<#= config #>> { }

<# } #>
}
57 changes: 57 additions & 0 deletions Src/ILGPU.Tests.Velocity/ILGPU.Tests.Velocity.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(LibraryUnitTestTargetFrameworks)</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup>
<RunSettingsFilePath>$(MSBuildProjectDirectory)\..\ILGPU.Tests\.test.runsettings</RunSettingsFilePath>
</PropertyGroup>

<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="2.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="T4.Build" Version="0.2.4" PrivateAssets="All" />
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Src\ILGPU\ILGPU.csproj" />
<ProjectReference Include="..\ILGPU.Tests\ILGPU.Tests.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="Configurations.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Configurations.tt</DependentUpon>
</None>
</ItemGroup>

<ItemGroup>
<None Update="Configurations.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Configurations.cs</LastGenOutput>
</None>
</ItemGroup>

<ItemGroup>
<Compile Update="Configurations.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Configurations.tt</DependentUpon>
</Compile>
</ItemGroup>
</Project>
44 changes: 44 additions & 0 deletions Src/ILGPU.Tests.Velocity/TestContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2023 ILGPU Project
// www.ilgpu.net
//
// File: TestContext.cs
//
// This file is part of ILGPU and is distributed under the University of Illinois Open
// Source License. See LICENSE.txt for details.
// ---------------------------------------------------------------------------------------

using ILGPU.Runtime.Velocity;
using System;

namespace ILGPU.Tests.Velocity
{
/// <summary>
/// An abstract test context for Velocity accelerators.
/// </summary>
public abstract class VelocityTestContext : TestContext
{
/// <summary>
/// Creates a new test context instance.
/// </summary>
/// <param name="optimizationLevel">The optimization level to use.</param>
/// <param name="prepareContext">The context preparation handler.</param>
protected VelocityTestContext(
OptimizationLevel optimizationLevel,
Action<Context.Builder> prepareContext)
: base(
optimizationLevel,
builder => prepareContext(builder.Velocity()),
context => context.CreateVelocityAccelerator())
{ }

/// <summary>
/// Creates a new test context instance.
/// </summary>
/// <param name="optimizationLevel">The optimization level to use.</param>
protected VelocityTestContext(OptimizationLevel optimizationLevel)
: this(optimizationLevel, _ => { })
{ }
}
}

0 comments on commit 699fb91

Please sign in to comment.