From 3b82ea87b0b7bef5dd797c8ecce919334fb1a11a Mon Sep 17 00:00:00 2001 From: Marcel Koester Date: Thu, 2 Mar 2023 15:50:14 +0100 Subject: [PATCH] Added core ILGPU Velocity tests. --- .gitignore | 1 + Src/ILGPU.Tests.Velocity/.editorconfig | 7 +++ Src/ILGPU.Tests.Velocity/Configurations.tt | 51 +++++++++++++++++ .../ILGPU.Tests.Velocity.csproj | 55 +++++++++++++++++++ Src/ILGPU.Tests.Velocity/TestContext.cs | 45 +++++++++++++++ Src/ILGPU.sln | 7 +++ 6 files changed, 166 insertions(+) create mode 100644 Src/ILGPU.Tests.Velocity/.editorconfig create mode 100644 Src/ILGPU.Tests.Velocity/Configurations.tt create mode 100644 Src/ILGPU.Tests.Velocity/ILGPU.Tests.Velocity.csproj create mode 100644 Src/ILGPU.Tests.Velocity/TestContext.cs diff --git a/.gitignore b/.gitignore index b2d60c4c9..0fb0024c3 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Src/ILGPU.Tests.Velocity/.editorconfig b/Src/ILGPU.Tests.Velocity/.editorconfig new file mode 100644 index 000000000..09af4abce --- /dev/null +++ b/Src/ILGPU.Tests.Velocity/.editorconfig @@ -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 diff --git a/Src/ILGPU.Tests.Velocity/Configurations.tt b/Src/ILGPU.Tests.Velocity/Configurations.tt new file mode 100644 index 000000000..3290ac580 --- /dev/null +++ b/Src/ILGPU.Tests.Velocity/Configurations.tt @@ -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> { } + +<# } #> +} \ No newline at end of file diff --git a/Src/ILGPU.Tests.Velocity/ILGPU.Tests.Velocity.csproj b/Src/ILGPU.Tests.Velocity/ILGPU.Tests.Velocity.csproj new file mode 100644 index 000000000..b6f4fb3af --- /dev/null +++ b/Src/ILGPU.Tests.Velocity/ILGPU.Tests.Velocity.csproj @@ -0,0 +1,55 @@ + + + + $(LibraryUnitTestTargetFrameworks) + false + + + + $(MSBuildProjectDirectory)\..\ILGPU.Tests\.test.runsettings + + + + true + AllEnabledByDefault + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + True + True + Configurations.tt + + + + + + TextTemplatingFileGenerator + Configurations.cs + + + + + + True + True + Configurations.tt + + + diff --git a/Src/ILGPU.Tests.Velocity/TestContext.cs b/Src/ILGPU.Tests.Velocity/TestContext.cs new file mode 100644 index 000000000..4431d6963 --- /dev/null +++ b/Src/ILGPU.Tests.Velocity/TestContext.cs @@ -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 +{ + /// + /// An abstract test context for Velocity accelerators. + /// + public abstract class VelocityTestContext : TestContext + { + /// + /// Creates a new test context instance. + /// + /// The optimization level to use. + /// The context preparation handler. + protected VelocityTestContext( + OptimizationLevel optimizationLevel, + Action prepareContext) + : base( + optimizationLevel, + builder => prepareContext( + builder.Velocity(VelocityDeviceType.Scalar2)), + context => context.CreateVelocityAccelerator()) + { } + + /// + /// Creates a new test context instance. + /// + /// The optimization level to use. + protected VelocityTestContext(OptimizationLevel optimizationLevel) + : this(optimizationLevel, _ => { }) + { } + } +} diff --git a/Src/ILGPU.sln b/Src/ILGPU.sln index 56c81a8cd..74d3f49db 100644 --- a/Src/ILGPU.sln +++ b/Src/ILGPU.sln @@ -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 @@ -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 @@ -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}