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 Sep 27, 2023
1 parent 9281464 commit 3b82ea8
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,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
7 changes: 7 additions & 0 deletions Src/ILGPU.Tests.Velocity/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*.cs]

# CA1707: Identifiers should not contain underscores
dotnet_diagnostic.CA1707.severity = none

# CA1014: Mark assemblies with CLSCompliant
dotnet_diagnostic.CA1014.severity = none
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 #>> { }

<# } #>
}
55 changes: 55 additions & 0 deletions Src/ILGPU.Tests.Velocity/ILGPU.Tests.Velocity.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<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="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<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>
45 changes: 45 additions & 0 deletions Src/ILGPU.Tests.Velocity/TestContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// ---------------------------------------------------------------------------------------
// 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(VelocityDeviceType.Scalar2)),
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, _ => { })
{ }
}
}
7 changes: 7 additions & 0 deletions Src/ILGPU.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILGPU.Algorithms.Tests.Open
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILGPU.Algorithms.Tests", "ILGPU.Algorithms.Tests\ILGPU.Algorithms.Tests.csproj", "{18F2225C-82FD-4B01-8AF9-CF746D16EDA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILGPU.Tests.Velocity", "ILGPU.Tests.Velocity\ILGPU.Tests.Velocity.csproj", "{4AFD2AAD-FA52-43EA-B9A8-10E948F9A139}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -71,6 +73,10 @@ Global
{18F2225C-82FD-4B01-8AF9-CF746D16EDA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18F2225C-82FD-4B01-8AF9-CF746D16EDA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18F2225C-82FD-4B01-8AF9-CF746D16EDA1}.Release|Any CPU.Build.0 = Release|Any CPU
{4AFD2AAD-FA52-43EA-B9A8-10E948F9A139}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4AFD2AAD-FA52-43EA-B9A8-10E948F9A139}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4AFD2AAD-FA52-43EA-B9A8-10E948F9A139}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4AFD2AAD-FA52-43EA-B9A8-10E948F9A139}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -84,6 +90,7 @@ Global
{AA73D3B1-873F-4A79-8347-E0781E382FF8} = {7701FE3C-4187-401C-9612-44667203B0E5}
{6ED7EDA1-E6DA-4867-8084-C0327EEFB7A9} = {7701FE3C-4187-401C-9612-44667203B0E5}
{18F2225C-82FD-4B01-8AF9-CF746D16EDA1} = {7701FE3C-4187-401C-9612-44667203B0E5}
{4AFD2AAD-FA52-43EA-B9A8-10E948F9A139} = {7701FE3C-4187-401C-9612-44667203B0E5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {22270DEE-D42D-479D-A76F-B2E7A5F7C949}
Expand Down

0 comments on commit 3b82ea8

Please sign in to comment.