Skip to content

Commit

Permalink
Removed obsolete pre-processor code. (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoFtZ committed Sep 1, 2023
1 parent 89929e8 commit 220af93
Show file tree
Hide file tree
Showing 26 changed files with 11 additions and 168 deletions.
10 changes: 0 additions & 10 deletions Samples/AlgorithmsSparseMatrix/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

namespace AlgorithmsSparseMatrix
{
#if NET6_0_OR_GREATER
class Program
{
/// <summary>
Expand Down Expand Up @@ -181,15 +180,6 @@ static void Main()
}
}
}
#else
class Program
{
static void Main()
{
Console.WriteLine("Cannot use this sample on frameworks prior to .Net6.0");
}
}
#endif
}

#pragma warning restore CA5394
4 changes: 1 addition & 3 deletions Samples/Mandelbrot/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU Samples
// Copyright (c) 2021 ILGPU Project
// Copyright (c) 2021-2023 ILGPU Project
// www.ilgpu.net
//
// File: Program.cs
Expand All @@ -22,9 +22,7 @@ static class Program
[STAThread]
static void Main()
{
#if !NETFRAMEWORK
Application.SetHighDpiMode(HighDpiMode.SystemAware);
#endif
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
#pragma warning disable CA2000 // Dispose objects before losing scope
Expand Down
4 changes: 0 additions & 4 deletions Samples/PinnedMemoryCopy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ static void PerformPinnedCopyUsingGCHandle(Accelerator accelerator, int dataSize
}
}

#if NET5_0_OR_GREATER
/// <summary>
/// Uses System.GC.AllocateArray to allocate pinned chunks of memory in CPU host memory.
/// </summary>
Expand All @@ -76,7 +75,6 @@ static void PerformPinnedCopyUsingGCAllocateArray(Accelerator accelerator, int d
// Wait for the copy operation to finish
stream.Synchronize();
}
#endif

/// <summary>
/// Uses Accelerator.AllocatePageLockedArray1D to allocate pinned chunks of memory in CPU host memory.
Expand Down Expand Up @@ -129,9 +127,7 @@ static void Main()
Console.WriteLine($"Performing operations on {accelerator}");

PerformPinnedCopyUsingGCHandle(accelerator, DataSize);
#if NET5_0_OR_GREATER
PerformPinnedCopyUsingGCAllocateArray(accelerator, DataSize);
#endif
PerformPinnedCopyUsingAllocatePageLockedArray(accelerator, DataSize);
}
}
Expand Down
4 changes: 0 additions & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/API/CuBlasAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ public static CuBlasAPI Create(CuBlasAPIVersion? version) =>
private static CuBlasAPI CreateLatest()
{
Exception? firstException = null;
#if NET5_0_OR_GREATER
var versions = Enum.GetValues<CuBlasAPIVersion>();
#else
var versions = (CuBlasAPIVersion[])Enum.GetValues(typeof(CuBlasAPIVersion));
#endif
for (var i = versions.Length - 1; i >= 0; i--)
{
var version = versions[i];
Expand Down
4 changes: 0 additions & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/API/CuFFTAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ public static CuFFTAPI Create(CuFFTAPIVersion? version) =>
private static CuFFTAPI CreateLatest()
{
Exception? firstException = null;
#if NET5_0_OR_GREATER
var versions = Enum.GetValues<CuFFTAPIVersion>();
#else
var versions = (CuFFTAPIVersion[])Enum.GetValues(typeof(CuFFTAPIVersion));
#endif
for (var i = versions.Length - 1; i >= 0; i--)
{
var version = versions[i];
Expand Down
4 changes: 0 additions & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/API/CuFFTWAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ public static CuFFTWAPI Create(CuFFTWAPIVersion? version) =>
private static CuFFTWAPI CreateLatest()
{
Exception? firstException = null;
#if NET5_0_OR_GREATER
var versions = Enum.GetValues<CuFFTWAPIVersion>();
#else
var versions = (CuFFTWAPIVersion[])Enum.GetValues(typeof(CuFFTWAPIVersion));
#endif
for (var i = versions.Length - 1; i >= 0; i--)
{
var version = versions[i];
Expand Down
4 changes: 0 additions & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/API/CuRandAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ public static CuRandAPI Create(CuRandAPIVersion? version) =>
private static CuRandAPI CreateLatest()
{
Exception? firstException = null;
#if NET5_0_OR_GREATER
var versions = Enum.GetValues<CuRandAPIVersion>();
#else
var versions = (CuRandAPIVersion[])Enum.GetValues(typeof(CuRandAPIVersion));
#endif
for (var i = versions.Length - 1; i >= 0; i--)
{
var version = versions[i];
Expand Down
4 changes: 0 additions & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/API/NvJpegAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ public static NvJpegAPI Create(NvJpegAPIVersion? version) =>
private static NvJpegAPI CreateLatest()
{
Exception? firstException = null;
#if NET5_0_OR_GREATER
var versions = Enum.GetValues<NvJpegAPIVersion>();
#else
var versions = (NvJpegAPIVersion[])Enum.GetValues(typeof(NvJpegAPIVersion));
#endif
for (var i = versions.Length - 1; i >= 0; i--)
{
var version = versions[i];
Expand Down
4 changes: 0 additions & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/API/NvmlAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ public static NvmlAPI Create(NvmlAPIVersion? version) =>
private static NvmlAPI CreateLatest()
{
Exception? firstException = null;
#if NET5_0_OR_GREATER
var versions = Enum.GetValues<NvmlAPIVersion>();
#else
var versions = (NvmlAPIVersion[])Enum.GetValues(typeof(NvmlAPIVersion));
#endif
for (var i = versions.Length - 1; i >= 0; i--)
{
var version = versions[i];
Expand Down
5 changes: 1 addition & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/CuBlasException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU Algorithms
// Copyright (c) 2020-2021 ILGPU Project
// Copyright (c) 2020-2023 ILGPU Project
// www.ilgpu.net
//
// File: CuBlasException.cs
Expand Down Expand Up @@ -76,9 +76,6 @@ private CuBlasException(SerializationInfo info, StreamingContext context)
#region Methods

/// <summary cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
#if !NET5_0_OR_GREATER
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
5 changes: 1 addition & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/CuFFTException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU Algorithms
// Copyright (c) 2021 ILGPU Project
// Copyright (c) 2021-2023 ILGPU Project
// www.ilgpu.net
//
// File: CuFFTException.cs
Expand Down Expand Up @@ -76,9 +76,6 @@ private CuFFTException(SerializationInfo info, StreamingContext context)
#region Methods

/// <summary cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
#if !NET5_0_OR_GREATER
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
5 changes: 1 addition & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/CuRandException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU Algorithms
// Copyright (c) 2021 ILGPU Project
// Copyright (c) 2021-2023 ILGPU Project
// www.ilgpu.net
//
// File: CuRandException.cs
Expand Down Expand Up @@ -76,9 +76,6 @@ private CuRandException(SerializationInfo info, StreamingContext context)
#region Methods

/// <summary cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
#if !NET5_0_OR_GREATER
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
5 changes: 1 addition & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/NvJpegException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU Algorithms
// Copyright (c) 2021 ILGPU Project
// Copyright (c) 2021-2023 ILGPU Project
// www.ilgpu.net
//
// File: NvJpegException.cs
Expand Down Expand Up @@ -76,9 +76,6 @@ private NvJpegException(SerializationInfo info, StreamingContext context)
#region Methods

/// <summary cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
#if !NET5_0_OR_GREATER
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
5 changes: 1 addition & 4 deletions Src/ILGPU.Algorithms/Runtime/Cuda/NvmlException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU Algorithms
// Copyright (c) 2021 ILGPU Project
// Copyright (c) 2021-2023 ILGPU Project
// www.ilgpu.net
//
// File: NvmlException.cs
Expand Down Expand Up @@ -76,9 +76,6 @@ private NvmlException(SerializationInfo info, StreamingContext context)
#region Methods

/// <summary cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
#if !NET5_0_OR_GREATER
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
6 changes: 1 addition & 5 deletions Src/ILGPU.Algorithms/XMath/Rem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU Algorithms
// Copyright (c) 2019-2021 ILGPU Project
// Copyright (c) 2019-2023 ILGPU Project
// www.ilgpu.net
//
// File: Rem.cs
Expand Down Expand Up @@ -57,10 +57,6 @@ public static double IEEERemainder(double x, double y) =>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[IntrinsicImplementation]
public static float IEEERemainder(float x, float y) =>
#if !NETFRAMEWORK
MathF.IEEERemainder(x, y);
#else
(float)Math.IEEERemainder(x, y);
#endif
}
}
4 changes: 1 addition & 3 deletions Src/ILGPU.Tests/PageLockedMemory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2021 ILGPU Project
// Copyright (c) 2021-2023 ILGPU Project
// www.ilgpu.net
//
// File: PageLockedMemory.cs
Expand Down Expand Up @@ -72,7 +72,6 @@ public unsafe void PinnedUsingGCHandle()
}
}

#if NET5_0_OR_GREATER
[Fact]
[KernelMethod(nameof(PinnedMemoryKernel))]
public void PinnedUsingGCAllocateArray()
Expand All @@ -89,7 +88,6 @@ public void PinnedUsingGCAllocateArray()
Accelerator.Synchronize();
Verify1D(array, expected);
}
#endif

internal static void CopyKernel(
Index1D index,
Expand Down
7 changes: 0 additions & 7 deletions Src/ILGPU.Tests/UnaryFloatOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,7 @@ internal static void IsPredicateF32Kernel(
ArrayView1D<int, Stride1D.Dense> data,
float value)
{
#if NETFRAMEWORK
data[index + 0] =
Bitwise.And(!float.IsNaN(value), !float.IsInfinity(value))
? 1
: 0;
#else
data[index + 0] = float.IsFinite(value) ? 1 : 0;
#endif
data[index + 1] = float.IsInfinity(value) ? 1 : 0;
data[index + 2] = float.IsPositiveInfinity(value) ? 1 : 0;
data[index + 3] = float.IsNegativeInfinity(value) ? 1 : 0;
Expand Down
4 changes: 0 additions & 4 deletions Src/ILGPU/Backends/Backend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,7 @@ protected delegate void CreateTransformersHandler(
Architecture.X64 => TargetPlatform.Platform64Bit,
Architecture.Arm => TargetPlatform.Platform32Bit,
Architecture.Arm64 => TargetPlatform.Platform64Bit,
#if NET5_0_OR_GREATER
Architecture.Wasm => TargetPlatform.Platform64Bit,
#endif
_ => throw new NotSupportedException(),
};

Expand All @@ -410,9 +408,7 @@ protected delegate void CreateTransformersHandler(
Architecture.X64 => TargetPlatform.Platform64Bit,
Architecture.Arm => TargetPlatform.Platform32Bit,
Architecture.Arm64 => TargetPlatform.Platform64Bit,
#if NET5_0_OR_GREATER
Architecture.Wasm => TargetPlatform.Platform64Bit,
#endif
_ => throw new NotSupportedException(),
};

Expand Down
5 changes: 0 additions & 5 deletions Src/ILGPU/Backends/PhiBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,8 @@ internal readonly struct BlockInfo
/// </param>
public BlockInfo(int capacity)
{
#if NET5_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
LHSPhis = new HashSet<PhiValue>(capacity);
IntermediatePhis = new HashSet<PhiValue>(capacity);
#else
LHSPhis = new HashSet<PhiValue>();
IntermediatePhis = new HashSet<PhiValue>();
#endif
Bindings = new List<(PhiValue, Value)>(capacity);
}

Expand Down
6 changes: 1 addition & 5 deletions Src/ILGPU/Frontend/Intrinsic/LanguageIntrinsics.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2021-2022 ILGPU Project
// Copyright (c) 2021-2023 ILGPU Project
// www.ilgpu.net
//
// File: LanguageIntrinsics.cs
Expand Down Expand Up @@ -233,11 +233,7 @@ public static bool TryParse(
else if (part.StartsWith("%", StringComparison.Ordinal))
{
// Check whether the argument can be resolved to an integer.
#if NETFRAMEWORK
if (int.TryParse(part.Substring(1), out int argument))
#else
if (int.TryParse(part[1..], out int argument))
#endif
{
result.Add(new FormatExpression(argument));
}
Expand Down
6 changes: 1 addition & 5 deletions Src/ILGPU/Runtime/ArrayViewExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2021-2022 ILGPU Project
// Copyright (c) 2021-2023 ILGPU Project
// www.ilgpu.net
//
// File: ArrayViewExtensions.cs
Expand Down Expand Up @@ -1675,13 +1675,9 @@ public static PageLockedArray1D<T> GetAsPageLocked<T>(
if (view.HasNoData())
return PageLockedArray1D<T>.Empty;
var accelerator = view.GetAccelerator();
#if NET5_0_OR_GREATER
var result = accelerator.AllocatePageLocked1D<T>(
view.Length,
uninitialized: true);
#else
var result = accelerator.AllocatePageLocked1D<T>(view.Length);
#endif
view.CopyToPageLockedAsync(stream, result);
stream.Synchronize();
return result;
Expand Down
3 changes: 0 additions & 3 deletions Src/ILGPU/Runtime/Cuda/CudaException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ private CudaException(SerializationInfo info, StreamingContext context)

/// <summary cref="Exception.GetObjectData(
/// SerializationInfo, StreamingContext)"/>
#if !NET5_0_OR_GREATER
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
public override void GetObjectData(
SerializationInfo info,
StreamingContext context)
Expand Down
5 changes: 0 additions & 5 deletions Src/ILGPU/Runtime/Cuda/NvvmAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
#if NET5_0_OR_GREATER
using NativeLibrary = System.Runtime.InteropServices.NativeLibrary;
#else
using NativeLibrary = ILGPU.Util.NativeLibrary;
#endif

#pragma warning disable CA2216 // Disposable types should declare finalizer

Expand Down
Loading

0 comments on commit 220af93

Please sign in to comment.