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

Velocity SIMD CPU Runtime #891

Closed
wants to merge 66 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
43e2831
Added .vscode directory to .gitignore file.
m4rs-mt Nov 24, 2022
eebd13d
Enhanced comment in Device class.
m4rs-mt Nov 24, 2022
eec6210
Changed visibility of Interop.WriteImplementation.
m4rs-mt Nov 24, 2022
249ccd2
Added helper to get the field names of managed structure types.
m4rs-mt Nov 24, 2022
5eed500
Added helper to get a managed type corresponding to ArithmeticBasicVa…
m4rs-mt Nov 24, 2022
a04f4cb
Adapted PhiBindings to support gathering of all phi nodes in a function.
m4rs-mt Nov 24, 2022
cc62d17
Fixed typo in EntryPoint class.
m4rs-mt Jan 26, 2023
bfbfb71
Extended TypeNode functionality to support custom managed type genera…
m4rs-mt Jan 26, 2023
31d1d9f
Updated Atomic functions to use readonly structures.
m4rs-mt Jan 26, 2023
f555f7e
Exposed Method of MethodEmitter in RuntimeSystem.
m4rs-mt Jan 26, 2023
381de60
Added more code-generation functions to IBackendCodeGenerator.
m4rs-mt Jan 26, 2023
41196ed
Adapted Backends to updated IBackendCodeGenerator.
m4rs-mt Jan 26, 2023
aec3541
Adapted ILAcceleratorSpecializer to make it reusable.
m4rs-mt Jan 26, 2023
0d9bafb
Added ILEmitter extensions to simplify MSIL code generation.
m4rs-mt Jan 26, 2023
77ca9b1
Updated ArgumentMapper to use common field names.
m4rs-mt Jan 26, 2023
924c7bf
Unsealed PTXArgumentMapper to make it reusable.
m4rs-mt Jan 26, 2023
63d78f1
Extended static TypeInformation classes to support additional Velocit…
m4rs-mt Jan 26, 2023
94c8d34
Extended static TypeInformation.ttinclude to support valid mapping of…
m4rs-mt Mar 2, 2023
dce9ac9
Extended static TypeInformation to support enhanced queries of Float1…
m4rs-mt Mar 2, 2023
d819ce1
Fixed typo in CPURuntimeContext.
m4rs-mt Mar 2, 2023
8109545
Added simplification of IfBranch terminators.
m4rs-mt Feb 17, 2023
cd1a12a
Extended ILEmitter by adding a new WriteLine instruction for debugging.
m4rs-mt Jan 26, 2023
57f1b74
Extended declarative unary math functions with implementation details…
m4rs-mt Jan 26, 2023
0a86c90
Extended declarative binary math functions with implementation detail…
m4rs-mt Mar 2, 2023
a144448
Extended declarative ternary math functions with implementation detai…
m4rs-mt Mar 2, 2023
a4c48ce
Added VelocityWarpVerifier to verify specific warp-wide operations at…
m4rs-mt Jan 26, 2023
63375a7
Added specialized 32bit warp implementation (VelocityWarp32).
m4rs-mt Jan 26, 2023
a909c23
Added specialized 32bit warp operations (VelocityWarp32.Operations).
m4rs-mt Jan 26, 2023
e8d2bf7
Added specialized 64bit warp implementation (VelocityWarp64).
m4rs-mt Jan 26, 2023
d889743
Added specialized 64bit warp operations (VelocityWarp64.Operations).
m4rs-mt Jan 26, 2023
9fc7e26
Added automatically generated and specialized VelocityWarp operations.
m4rs-mt Jan 26, 2023
0cf3014
Added VelocityWarps.cs to .gitignore file.
m4rs-mt Jan 26, 2023
0d370f8
Added new VelocityLaneMask structure to track active lanes inside a w…
m4rs-mt Jan 26, 2023
e88f06d
Added new VelocityCodeGenerator to build mask-based SIMD control flow…
m4rs-mt Jan 26, 2023
9a8d6dc
Added new VelocityCodeGenerator.Views to generate code for View-based…
m4rs-mt Mar 2, 2023
05ed2b3
Added new VelocityCodeGenerator.Values to generate code for general I…
m4rs-mt Mar 2, 2023
ca9edc0
Added new VelocityCodeGenerator.Threads to generate code for Thread-b…
m4rs-mt Mar 2, 2023
e965440
Added new VelocityCodeGenerator.Terminators to generate code for SIMD…
m4rs-mt Mar 2, 2023
6d20a92
Added new VelocityCodeGenerator.IO to generate code for SIMD-based IO…
m4rs-mt Mar 2, 2023
7889db1
Added additional Velocity-specific instructions to Velocity backend.
m4rs-mt Jan 26, 2023
cc7a87e
Added new Velocity type generator to created vectorized managed type …
m4rs-mt Jan 26, 2023
f4de003
Registered new Velocity backend type.
m4rs-mt Jan 26, 2023
cf09ebf
Added new VelocityArgumentMapper that constructs padded argument stru…
m4rs-mt Jan 26, 2023
d53b856
Added VelocityKernelFunction generator to Velocity backend.
m4rs-mt Jan 26, 2023
d252feb
Added VelocityFunction generator to Velocity backend.
m4rs-mt Mar 2, 2023
4048fab
Added VelocityGenerationModule to map methods to the managed world an…
m4rs-mt Jan 26, 2023
7bbc079
Added new Velocity argument mapper class to convert input .Net argume…
m4rs-mt Jan 26, 2023
ec78daa
Added new VelocityCompiledKernel class to represent compiled Velocity…
m4rs-mt Mar 2, 2023
6ad0bc5
Added new general VelocityBackend class to convert compile Velocity k…
m4rs-mt Mar 2, 2023
9972042
Added Velocity accelerator AcceleratorType enumeration and extension …
m4rs-mt Jan 26, 2023
e766187
Update runtime error messages.
m4rs-mt Jan 26, 2023
178b3b9
Added new VelocityAccelerator class to work with SIMD-based kernels.
m4rs-mt Jan 26, 2023
af00ab3
Refined peer-access implementation of CPUAccelerator.
m4rs-mt Jan 26, 2023
e372cbc
Added new VelocityDevice class to represent and configure SIMD-based …
m4rs-mt Mar 2, 2023
9106dd1
Added new VelocityAccelerator builder extension methods.
m4rs-mt Mar 2, 2023
a426bdc
Added new VelocityStream to represent streams in Velocity land.
m4rs-mt Mar 2, 2023
3e6cd50
Added new VelocityMultiprocessor to represent individual SIMD-cores t…
m4rs-mt Mar 2, 2023
8e96a23
Added new VelocityMemoryBuffer to represent memory buffers in Velocit…
m4rs-mt Mar 2, 2023
235a537
Adapted CPUMemoryBuffer to support new Velocity buffers.
m4rs-mt Mar 2, 2023
544ffe6
Added new VelocityKernel to represent optimized and compiled Velocity…
m4rs-mt Mar 2, 2023
1047b0f
Added abstract internal VelocityParameters class to pass automaticall…
m4rs-mt Mar 2, 2023
6de9171
Added new type extension helpers.
m4rs-mt Mar 2, 2023
67854be
Adapted GroupOperation tests to support different group configurations.
m4rs-mt Mar 2, 2023
11c96ea
Adapted KernelEntryPoint tests to support different group configurati…
m4rs-mt Mar 2, 2023
da556d4
Adapted MemoryBufferOperation tests to support different group config…
m4rs-mt Mar 2, 2023
74c1871
Added core ILGPU Velocity tests.
m4rs-mt Mar 2, 2023
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ ModelManifest.xml
# macOS
.DS_Store

# VSCode
.vscode/

# Ignore specific template outputs
Src/ILGPU/AtomicFunctions.cs
Src/ILGPU/Backends/PTX/PTXIntrinsics.Generated.cs
Expand All @@ -274,6 +277,7 @@ Src/ILGPU/Runtime/Cuda/LibDevice.cs
Src/ILGPU/Runtime/KernelLoaders.cs
Src/ILGPU/Runtime/MemoryBuffers.cs
Src/ILGPU/Runtime/PageLockedArrays.Generated.cs
Src/ILGPU/Runtime/Velocity/VelocityWarps.cs
Src/ILGPU/Static/ArithmeticEnums.cs
Src/ILGPU/Static/CapabilityContext.cs
Src/ILGPU/Static/DllImports.cs
Expand Down Expand Up @@ -334,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 Expand Up @@ -362,3 +367,4 @@ Src/ILGPU.Algorithms.Tests/XMathTests.Trig.cs
Src/ILGPU.Algorithms.Tests.CPU/Configurations.cs
Src/ILGPU.Algorithms.Tests.Cuda/Configurations.cs
Src/ILGPU.Algorithms.Tests.OpenCL/Configurations.cs

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, _ => { })
{ }
}
}
22 changes: 19 additions & 3 deletions Src/ILGPU.Tests/GroupOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ internal static void GroupDimensionKernel(ArrayView1D<int, Stride1D.Dense> data)
data[2] = Group.DimZ;
}

[Theory]
[SkippableTheory]
[InlineData(1, 0, 0)]
[InlineData(0, 1, 0)]
[InlineData(0, 0, 1)]
[KernelMethod(nameof(GroupDimensionKernel))]
public void GroupDimension1D(int xMask, int yMask, int zMask)
{
Skip.If(
xMask >= Accelerator.MaxGroupSize.X ||
yMask >= Accelerator.MaxGroupSize.Y ||
zMask >= Accelerator.MaxGroupSize.Z);

for (int i = 2; i <= Math.Min(8, Accelerator.MaxNumThreadsPerGroup); i <<= 1)
{
using var buffer = Accelerator.Allocate1D<int>(3);
Expand All @@ -61,13 +66,18 @@ public void GroupDimension1D(int xMask, int yMask, int zMask)
}
}

[Theory]
[SkippableTheory]
[InlineData(1, 1, 0)]
[InlineData(0, 1, 1)]
[InlineData(1, 0, 1)]
[KernelMethod(nameof(GroupDimensionKernel))]
public void GroupDimension2D(int xMask, int yMask, int zMask)
{
Skip.If(
xMask >= Accelerator.MaxGroupSize.X ||
yMask >= Accelerator.MaxGroupSize.Y ||
zMask >= Accelerator.MaxGroupSize.Z);

var end = (int)Math.Sqrt(Accelerator.MaxNumThreadsPerGroup);
for (int i = 2; i <= end; i <<= 1)
{
Expand Down Expand Up @@ -121,6 +131,7 @@ internal static void GroupBarrierKernel(ArrayView1D<int, Stride1D.Dense> data)
}

[SkippableTheory]
[InlineData(2)]
[InlineData(32)]
[InlineData(256)]
[InlineData(1024)]
Expand All @@ -129,7 +140,7 @@ public void GroupBarrier(int length)
{
Skip.If(length > Accelerator.MaxNumThreadsPerGroup);

for (int i = 1; i <= Accelerator.MaxNumThreadsPerGroup; i <<= 1)
for (int i = 2; i <= Accelerator.MaxNumThreadsPerGroup; i <<= 1)
{
using var buffer = Accelerator.Allocate1D<int>(length * i);
var extent = new KernelConfig(
Expand All @@ -151,6 +162,7 @@ internal static void GroupBarrierAndKernel(
}

[SkippableTheory]
[InlineData(2)]
[InlineData(32)]
[InlineData(256)]
[InlineData(1024)]
Expand Down Expand Up @@ -184,6 +196,7 @@ internal static void GroupBarrierOrKernel(
}

[SkippableTheory]
[InlineData(2)]
[InlineData(32)]
[InlineData(256)]
[InlineData(1024)]
Expand Down Expand Up @@ -219,6 +232,7 @@ internal static void GroupBarrierPopCountKernel(
}

[SkippableTheory]
[InlineData(2)]
[InlineData(32)]
[InlineData(256)]
[InlineData(1024)]
Expand Down Expand Up @@ -250,6 +264,7 @@ internal static void GroupBroadcastKernel(
}

[SkippableTheory]
[InlineData(2)]
[InlineData(32)]
[InlineData(256)]
[InlineData(1024)]
Expand Down Expand Up @@ -283,6 +298,7 @@ internal static void GroupDivergentControlFlowKernel(
}

[SkippableTheory]
[InlineData(2)]
[InlineData(32)]
[InlineData(256)]
[InlineData(1024)]
Expand Down
Loading