Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AVX support via 256 registers to Velocity runtime #1218

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,26 @@ jobs:
os: ${{ fromJson(needs.setup-os-matrix.outputs.os) }}
library: [ILGPU, ILGPU.Algorithms, ILGPU.Analyzers]
framework: [net6.0, net7.0, net8.0]
flavor: [CPU, Velocity, Velocity128]
flavor: [CPU, Velocity, Velocity128, Velocity256]
exclude:
- library: ILGPU.Algorithms
flavor: Velocity
- library: ILGPU.Algorithms
flavor: Velocity128
- library: ILGPU.Algorithms
flavor: Velocity256
- library: ILGPU.Analyzers
flavor: Velocity
- library: ILGPU.Analyzers
flavor: Velocity128
- library: ILGPU.Analyzers
flavor: Velocity256
- os: cuda
flavor: Velocity
- os: cuda
flavor: Velocity128
- os: cuda
flavor: Velocity256
- os: cuda
library: ILGPU.Analyzers
fail-fast: false
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ Src/ILGPU/Backends/PTX/PTXLibDeviceMethods.cs
Src/ILGPU/Backends/PTX/PTXLibDeviceNvvm.cs
Src/ILGPU/Backends/Velocity/Scalar/ScalarOperations.cs
Src/ILGPU/Backends/Velocity/Vec128/Vec128Operations.cs
Src/ILGPU/Backends/Velocity/Vec256/Vec256Operations.cs
Src/ILGPU/Backends/Velocity/VelocityIntrinsics.Generated.cs
Src/ILGPU/Frontend/Intrinsic/RemappedIntrinsics.Generated.cs
Src/ILGPU/HalfConversion.cs
Expand Down Expand Up @@ -345,6 +346,7 @@ Src/ILGPU.Tests.Cuda/Configurations.cs
Src/ILGPU.Tests.OpenCL/Configurations.cs
Src/ILGPU.Tests.Velocity/Configurations.cs
Src/ILGPU.Tests.Velocity128/Configurations.cs
Src/ILGPU.Tests.Velocity256/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.Velocity256/.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
60 changes: 60 additions & 0 deletions Src/ILGPU.Tests.Velocity256/Configurations.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2024 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);
#>

#if NET7_0_OR_GREATER

namespace ILGPU.Tests.Velocity256
{
<# foreach (var (test, level, collection) in configurations) { #>
<# var name = $"Velocity256{test}_{level}"; #>
[Collection("Velocity256ContextCollection<#= collection #>")]
public sealed partial class <#= name #> : <#= test #>
{
public <#= name #>(
ITestOutputHelper output,
Velocity256TestContext<#= collection #> testContext)
: base(output, testContext)
{ }
}

<# } #>
<# foreach (var (config, level) in TestConfig.AllConfigurations) { #>
public class Velocity256TestContext<#= config #> : Velocity256TestContext
{
public Velocity256TestContext<#= config #>()
: base(
OptimizationLevel.<#= level #>,
enableAssertions: true,
forceDebugConfig: true,
_ => { })
{ }
}

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

<# } #>
}

#endif
60 changes: 60 additions & 0 deletions Src/ILGPU.Tests.Velocity256/ILGPU.Tests.Velocity256.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<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.9.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<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>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>

<ItemGroup>
<Compile Update="Configurations.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Configurations.tt</DependentUpon>
</Compile>
</ItemGroup>

</Project>
51 changes: 51 additions & 0 deletions Src/ILGPU.Tests.Velocity256/TestContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2024 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;

#if NET7_0_OR_GREATER

namespace ILGPU.Tests.Velocity256
{
/// <summary>
/// An abstract test context for Velocity accelerators.
/// </summary>
public abstract class Velocity256TestContext : TestContext
{
/// <summary>
/// Creates a new test context instance.
/// </summary>
/// <param name="optimizationLevel">The optimization level to use.</param>
/// <param name="enableAssertions">
/// Enables use of assertions.
/// </param>
/// <param name="forceDebugConfig">
/// Forces use of debug configuration in O1 and O2 builds.
/// </param>
/// <param name="prepareContext">The context preparation handler.</param>
protected Velocity256TestContext(
OptimizationLevel optimizationLevel,
bool enableAssertions,
bool forceDebugConfig,
Action<Context.Builder> prepareContext)
: base(
optimizationLevel,
enableAssertions,
forceDebugConfig,
builder => prepareContext(
builder.Velocity(VelocityDeviceType.Vector256)),
context => context.CreateVelocityAccelerator())
{ }
}
}

#endif
7 changes: 7 additions & 0 deletions Src/ILGPU.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILGPU.Analyzers", "ILGPU.An
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILGPU.Tests.Velocity128", "ILGPU.Tests.Velocity128\ILGPU.Tests.Velocity128.csproj", "{422BA1AE-858D-4AA4-815B-CF42A429D305}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILGPU.Tests.Velocity256", "ILGPU.Tests.Velocity256\ILGPU.Tests.Velocity256.csproj", "{F24B884D-A64B-4511-85B6-FEEDA92CBBA1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -98,6 +100,10 @@ Global
{422BA1AE-858D-4AA4-815B-CF42A429D305}.Debug|Any CPU.Build.0 = Debug|Any CPU
{422BA1AE-858D-4AA4-815B-CF42A429D305}.Release|Any CPU.ActiveCfg = Release|Any CPU
{422BA1AE-858D-4AA4-815B-CF42A429D305}.Release|Any CPU.Build.0 = Release|Any CPU
{F24B884D-A64B-4511-85B6-FEEDA92CBBA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F24B884D-A64B-4511-85B6-FEEDA92CBBA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F24B884D-A64B-4511-85B6-FEEDA92CBBA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F24B884D-A64B-4511-85B6-FEEDA92CBBA1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -114,6 +120,7 @@ Global
{4AFD2AAD-FA52-43EA-B9A8-10E948F9A139} = {7701FE3C-4187-401C-9612-44667203B0E5}
{B0101B27-F153-4041-8DEE-741B651453D5} = {7701FE3C-4187-401C-9612-44667203B0E5}
{422BA1AE-858D-4AA4-815B-CF42A429D305} = {7701FE3C-4187-401C-9612-44667203B0E5}
{F24B884D-A64B-4511-85B6-FEEDA92CBBA1} = {7701FE3C-4187-401C-9612-44667203B0E5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {22270DEE-D42D-479D-A76F-B2E7A5F7C949}
Expand Down
Loading
Loading