Skip to content

Commit

Permalink
Added support for net80 SDK. (#1132)
Browse files Browse the repository at this point in the history
* Added workaround for net80 compiler.
* Mark formatter-based serialization as obsolete.
* Fixed compilation `ref readonly parameters` not available in C# 11.0.
* CA1859: Use concrete types when possible for improved performance
* CA1860: Avoid using 'Enumerable.Any()' extension method
* CA1861: Avoid constant arrays as arguments
* CA1862: Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
* Suppress warnings for functionality that is only available from net8.0 onwards.
* Added support for net80 SDK.
  • Loading branch information
MoFtZ authored Dec 14, 2023
1 parent d49fd60 commit 88e1dd7
Show file tree
Hide file tree
Showing 35 changed files with 161 additions and 49 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ jobs:
with:
fetch-depth: 0

- name: Setup the latest .NET 7 SDK
- name: Setup the latest .NET 8 SDK
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Check Copyright Headers
run: |
Expand Down Expand Up @@ -138,10 +138,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup the latest .NET 7 SDK
- name: Setup the latest .NET 8 SDK
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Build
run: dotnet build ${{ matrix.path }} --configuration=Release -p:TreatWarningsAsErrors=true
Expand All @@ -153,7 +153,7 @@ jobs:
matrix:
os: ${{ fromJson(needs.setup-os-matrix.outputs.os) }}
library: [ILGPU, ILGPU.Algorithms]
framework: [net6.0, net7.0]
framework: [net6.0, net7.0, net8.0]
flavor: [CPU, Velocity]
exclude:
- library: ILGPU.Algorithms
Expand All @@ -173,10 +173,16 @@ jobs:
dotnet-version: 6.0.x

- name: Setup the latest .NET 7 SDK
if: matrix.framework == 'net7.0'
uses: actions/[email protected]
with:
dotnet-version: 7.0.x

- name: Setup the latest .NET 8 SDK
uses: actions/[email protected]
with:
dotnet-version: 8.0.x

- name: Set test flavor
id: test-flavor
shell: bash
Expand Down Expand Up @@ -234,10 +240,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup the latest .NET 7 SDK
- name: Setup the latest .NET 8 SDK
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Create NuGet packages
run: |
Expand Down Expand Up @@ -265,10 +271,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup the latest .NET 7 SDK
- name: Setup the latest .NET 8 SDK
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

# Change the ILGPU project references to NuGet package references
- name: Update sample references
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ jobs:
fail-fast: false
matrix:
solution: [Src/ILGPU.sln, Samples/ILGPU.Samples.sln]
framework: [net6.0, net7.0]
framework: [net6.0, net7.0, net8.0]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup the latest .NET 7 SDK
- name: Setup the latest .NET 8 SDK
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand All @@ -66,13 +66,17 @@ jobs:
{
"net6.0" { $LibrarySamplesTargetFrameworksWindows="net6.0-windows" }
"net7.0" { $LibrarySamplesTargetFrameworksWindows="net7.0-windows" }
"net8.0" { $LibrarySamplesTargetFrameworksWindows="net8.0-windows" }
}
dotnet build -p:UseSharedCompilation=false `
-p:LibraryTargetFrameworks=$LibraryTargetFrameworks `
-p:LibraryUnitTestTargetFrameworks=$LibraryUnitTestTargetFrameworks `
-p:LibrarySamplesTargetFrameworks=$LibrarySamplesTargetFrameworks `
-p:LibrarySamplesTargetFrameworksWindows=$LibrarySamplesTargetFrameworksWindows `
${{ matrix.solution }}
env:
ILGPU_DOTNET_PREVIEW: ${{ matrix.preview }}
continue-on-error: ${{ matrix.preview }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
4 changes: 2 additions & 2 deletions .github/workflows/update-copyright-year.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
with:
fetch-depth: 0

- name: Setup the latest .NET 7 SDK
- name: Setup the latest .NET 8 SDK
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Update copyright year
uses: technote-space/create-pr-action@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-cuda-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup the latest .NET 7 SDK
- name: Setup the latest .NET 8 SDK
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Update Cuda versions
uses: technote-space/create-pr-action@v2
Expand Down
2 changes: 1 addition & 1 deletion Samples/BlazorSampleApp/BlazorSampleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
12 changes: 8 additions & 4 deletions Samples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<Project>
<PropertyGroup Condition="'$(MSBuildVersion)' &gt;= '17.4'">
<PropertyGroup Condition="'$(MSBuildVersion)' &gt;= '17.8'">
<LibrarySamplesTargetFrameworks>net8.0</LibrarySamplesTargetFrameworks>
<LibrarySamplesTargetFrameworksWindows>net8.0-windows</LibrarySamplesTargetFrameworksWindows>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildVersion)' &gt;= '17.4' AND '$(MSBuildVersion)' &lt; '17.8' ">
<LibrarySamplesTargetFrameworks>net7.0</LibrarySamplesTargetFrameworks>
<LibrarySamplesTargetFrameworksWindows>net7.0-windows</LibrarySamplesTargetFrameworksWindows>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildVersion)' &lt; '17.4'">
<LibrarySamplesTargetFrameworks>net6.0</LibrarySamplesTargetFrameworks>
<LibrarySamplesTargetFrameworksWindows>net6.0-windows</LibrarySamplesTargetFrameworksWindows>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<LibrarySamplesTargetFrameworks>net6.0;net7.0</LibrarySamplesTargetFrameworks>
<LibrarySamplesTargetFrameworksWindows>net6.0-windows;net7.0-windows</LibrarySamplesTargetFrameworksWindows>
<LibrarySamplesTargetFrameworks>net6.0;net7.0;net8.0</LibrarySamplesTargetFrameworks>
<LibrarySamplesTargetFrameworksWindows>net6.0-windows;net7.0-windows;net8.0-windows</LibrarySamplesTargetFrameworksWindows>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>

</Project>
21 changes: 21 additions & 0 deletions Src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,24 @@ dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_code_quality.ca1711.allowed_suffixes = Flag|Flags|Collection
dotnet_code_quality.CAXXXX.api_surface = public, protected

# -----------------------------------------------------------------------------
# WORKAROUND: The following functionality requires NET8_0_OR_GREATER
# -----------------------------------------------------------------------------
# CA1865: Use char overload
dotnet_diagnostic.CA1865.severity = none

# CA1863: Use 'CompositeFormat'
dotnet_diagnostic.CA1863.severity = none

# CA1510: Use ArgumentNullException throw helper
dotnet_diagnostic.CA1510.severity = none

# CA1511:Use ArgumentException throw helper
dotnet_diagnostic.CA1511.severity = none

# CA1512: Use ArgumentOutOfRangeException throw helper
dotnet_diagnostic.CA1512.severity = none

# CA1513: Use ObjectDisposedException throw helper
dotnet_diagnostic.CA1513.severity = none
8 changes: 4 additions & 4 deletions Src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project>
<!-- Library Project Configuration -->
<PropertyGroup>
<LibraryTargetFrameworks>net7.0</LibraryTargetFrameworks>
<LibraryTargetFrameworks>net8.0</LibraryTargetFrameworks>
<LibraryLatestTargetFramework>$(LibraryTargetFrameworks)</LibraryLatestTargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<LibraryTargetFrameworks>$(LibraryTargetFrameworks);net6.0</LibraryTargetFrameworks>
<LibraryTargetFrameworks>$(LibraryTargetFrameworks);net6.0;net7.0</LibraryTargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>

Expand All @@ -18,11 +18,11 @@

<!-- Unit Test Project Configuration -->
<PropertyGroup>
<LibraryUnitTestTargetFrameworks>net7.0</LibraryUnitTestTargetFrameworks>
<LibraryUnitTestTargetFrameworks>net8.0</LibraryUnitTestTargetFrameworks>
<LibraryLatestUnitTestTargetFramework>$(LibraryUnitTestTargetFrameworks)</LibraryLatestUnitTestTargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<LibraryUnitTestTargetFrameworks>$(LibraryUnitTestTargetFrameworks);net6.0</LibraryUnitTestTargetFrameworks>
<LibraryUnitTestTargetFrameworks>$(LibraryUnitTestTargetFrameworks);net6.0;net7.0</LibraryUnitTestTargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>

Expand Down
5 changes: 3 additions & 2 deletions Src/ILGPU.Algorithms.Tests/OptimizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#pragma warning disable CA1034
#pragma warning disable CA1819
#pragma warning disable CA1861 // Avoid constant arrays as arguments
#pragma warning disable xUnit1026

namespace ILGPU.Algorithms.Tests
Expand Down Expand Up @@ -196,6 +197,6 @@ public void ParticleSwarmOptimization<
}

#pragma warning restore xUnit1026
#pragma warning restore CA1034
#pragma warning restore CA1861 // Avoid constant arrays as arguments
#pragma warning restore CA1819

#pragma warning restore CA1034
3 changes: 3 additions & 0 deletions Src/ILGPU.Algorithms/ILGPU.Algorithms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<NeutralLanguage>en-US</NeutralLanguage>
<LangVersion>11.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<LangVersion>12.0</LangVersion>
</PropertyGroup>

<PropertyGroup>
<OutputPath>../../Bin/$(Configuration)/</OutputPath>
Expand Down
6 changes: 6 additions & 0 deletions Src/ILGPU.Algorithms/Runtime/Cuda/CuBlasException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public CuBlasException(string message, Exception innerException)
}

/// <summary cref="Exception(SerializationInfo, StreamingContext)"/>
#if NET8_0_OR_GREATER
[Obsolete("SYSLIB0050: Formatter-based serialization is obsolete")]
#endif
private CuBlasException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -76,6 +79,9 @@ private CuBlasException(SerializationInfo info, StreamingContext context)
#region Methods

/// <summary cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
#if NET8_0_OR_GREATER
[Obsolete("SYSLIB0050: Formatter-based serialization is obsolete")]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
6 changes: 6 additions & 0 deletions Src/ILGPU.Algorithms/Runtime/Cuda/CuFFTException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public CuFFTException(string message, Exception innerException)
}

/// <summary cref="Exception(SerializationInfo, StreamingContext)"/>
#if NET8_0_OR_GREATER
[Obsolete("SYSLIB0050: Formatter-based serialization is obsolete")]
#endif
private CuFFTException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -76,6 +79,9 @@ private CuFFTException(SerializationInfo info, StreamingContext context)
#region Methods

/// <summary cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
#if NET8_0_OR_GREATER
[Obsolete("SYSLIB0050: Formatter-based serialization is obsolete")]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
6 changes: 6 additions & 0 deletions Src/ILGPU.Algorithms/Runtime/Cuda/CuRandException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public CuRandException(string message, Exception innerException)
}

/// <summary cref="Exception(SerializationInfo, StreamingContext)"/>
#if NET8_0_OR_GREATER
[Obsolete("SYSLIB0050: Formatter-based serialization is obsolete")]
#endif
private CuRandException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -76,6 +79,9 @@ private CuRandException(SerializationInfo info, StreamingContext context)
#region Methods

/// <summary cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
#if NET8_0_OR_GREATER
[Obsolete("SYSLIB0050: Formatter-based serialization is obsolete")]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
6 changes: 6 additions & 0 deletions Src/ILGPU.Algorithms/Runtime/Cuda/NvJpegException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public NvJpegException(string message, Exception innerException)
}

/// <summary cref="Exception(SerializationInfo, StreamingContext)"/>
#if NET8_0_OR_GREATER
[Obsolete("SYSLIB0050: Formatter-based serialization is obsolete")]
#endif
private NvJpegException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -76,6 +79,9 @@ private NvJpegException(SerializationInfo info, StreamingContext context)
#region Methods

/// <summary cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
#if NET8_0_OR_GREATER
[Obsolete("SYSLIB0050: Formatter-based serialization is obsolete")]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
6 changes: 6 additions & 0 deletions Src/ILGPU.Algorithms/Runtime/Cuda/NvmlException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public NvmlException(string message, Exception innerException)
}

/// <summary cref="Exception(SerializationInfo, StreamingContext)"/>
#if NET8_0_OR_GREATER
[Obsolete("SYSLIB0050: Formatter-based serialization is obsolete")]
#endif
private NvmlException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -76,6 +79,9 @@ private NvmlException(SerializationInfo info, StreamingContext context)
#region Methods

/// <summary cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
#if NET8_0_OR_GREATER
[Obsolete("SYSLIB0050: Formatter-based serialization is obsolete")]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
4 changes: 4 additions & 0 deletions Src/ILGPU.Algorithms/Vectors/VectorTypes.tt
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,11 @@ namespace ILGPU.Algorithms.Vectors
/// </summary>
/// <returns>The readonly span instance.</returns>
public unsafe ReadOnlySpan<<#= type.Type #>> AsSpan() =>
#if NET8_0_OR_GREATER
new(Unsafe.AsPointer(ref Unsafe.AsRef(in this)), <#= vectorLength #>);
#else
new(Unsafe.AsPointer(ref Unsafe.AsRef(this)), <#= vectorLength #>);
#endif

/// <summary>
/// Iterates over all elements by applying the given iterator to each element.
Expand Down
2 changes: 1 addition & 1 deletion Src/ILGPU.Tests/Generic/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static bool CleanTests
var env = Environment.GetEnvironmentVariable(
CleanTestsEnvironmentVariable);
return !string.IsNullOrWhiteSpace(env)
&& env.ToUpperInvariant() != "FALSE"
&& !env.Equals("FALSE", StringComparison.OrdinalIgnoreCase)
&& env != "0";
}
}
Expand Down
6 changes: 5 additions & 1 deletion Src/ILGPU/AssemblyAttributes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using ILGPU;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo(Context.RuntimeAssemblyName)]
// WORKAROUND: There is an issue with net8.0 that causes the compiler to crash.
// https://github.com/dotnet/roslyn/issues/71039

[assembly: InternalsVisibleTo("ILGPURuntime")]
// [assembly: InternalsVisibleTo(Context.RuntimeAssemblyName)]
Loading

0 comments on commit 88e1dd7

Please sign in to comment.