Skip to content

Commit

Permalink
Removed CLS compliance. (#1057)
Browse files Browse the repository at this point in the history
* Removed CLSCompliance attribute from ILGPU.
* Removed CLSCompliance attribute from ILGPU.Algorithms.
* Removed CLSCompliance attribute from Tests.
  • Loading branch information
m4rs-mt committed Aug 29, 2023
1 parent 976f621 commit 9ddca0b
Show file tree
Hide file tree
Showing 63 changed files with 60 additions and 293 deletions.
1 change: 0 additions & 1 deletion Src/ILGPU.Algorithms/AssemblyAttributes.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.CompilerServices;

[assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo(ILGPU.Context.RuntimeAssemblyName)]
5 changes: 1 addition & 4 deletions Src/ILGPU.Algorithms/ComparisonOperations.tt
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: ComparisonOperations.tt/ComparisonOperations.cs
Expand All @@ -27,9 +27,6 @@ namespace ILGPU.Algorithms.ComparisonOperations
/// <summary>
/// Represents an comparison between two elements of type <#= type.Type #>.
/// </summary>
<# if (!type.IsCLSCompliant) { #>
[CLSCompliant(false)]
<# } #>
public readonly struct Comparison<#= type.Name #>
: IComparisonOperation<<#= type.Type #>>
{
Expand Down
3 changes: 0 additions & 3 deletions Src/ILGPU.Algorithms/HistogramLaunchers.tt
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ namespace ILGPU.Algorithms
/// <param name="histogramOverflow">
/// Single-element view that indicates whether the histogram has overflowed.
/// </param>
<# if (!type.IsCLSCompliant) { #>
[CLSCompliant(false)]
<# } #>
public static void Histogram<T, TStride, TLocator>(
this Accelerator accelerator,
AcceleratorStream stream,
Expand Down
5 changes: 1 addition & 4 deletions Src/ILGPU.Algorithms/HistogramOperations.tt
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: HistogramOperations.tt/HistogramOperations.cs
Expand All @@ -27,9 +27,6 @@ namespace ILGPU.Algorithms.HistogramOperations
/// <summary>
/// Represents atomically incrementing a histogram bin of type <#= type.Type #>.
/// </summary>
<# if (!type.IsCLSCompliant) { #>
[CLSCompliant(false)]
<# } #>
public readonly struct HistogramIncrement<#= type.Name #> :
IIncrementOperation<<#= type.Type #>>
{
Expand Down
17 changes: 8 additions & 9 deletions Src/ILGPU.Algorithms/Optimization/Optimizers/PSO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public static class PSO
/// A common choice for Omega.
/// </summary>
public const float Omega = 0.8f;

/// <summary>
/// A common choice for PhiG.
/// </summary>
public const float PhiG = 1.5f;

/// <summary>
/// A common choice for PhiP.
/// </summary>
Expand All @@ -52,7 +52,7 @@ public static class PSO
/// </summary>
public static ReadOnlySpan<float> DefaultFloatParameters => FloatParameters;
}

/// <summary>
/// Represents a particle-swap optimization engine (PSO) that uses a PSO algorithm
/// to solve n-dimensional optimization problems.
Expand All @@ -61,7 +61,6 @@ public static class PSO
/// <typeparam name="TElementType">The element type of a numeric type.</typeparam>
/// <typeparam name="TEvalType">The evaluation data type.</typeparam>
/// <typeparam name="TRandomProvider">The RNG type.</typeparam>
[CLSCompliant(false)]
public sealed class PSO<TNumericType, TElementType, TEvalType, TRandomProvider>
: OptimizationEngine<TNumericType, TElementType, TEvalType>
where TNumericType : unmanaged, IVectorType<TNumericType, TElementType>
Expand All @@ -73,10 +72,10 @@ public sealed class PSO<TNumericType, TElementType, TEvalType, TRandomProvider>
private const int ParameterOmega = 0;
private const int ParameterPhiP = 1;
private const int ParameterPhiG = 2;

private readonly MemoryBuffer2D<TNumericType, Stride2D.DenseY> velocities;
private readonly MemoryBuffer2D<TNumericType, Stride2D.DenseY> bestPositions;

/// <summary>
/// Creates a new PS engine.
/// </summary>
Expand Down Expand Up @@ -108,7 +107,7 @@ public PSO(
bestPositions.View,
EvaluationsView);
}

/// <summary>
/// Returns a PSO-specific data view.
/// </summary>
Expand All @@ -122,7 +121,7 @@ public TElementType Omega
get => GetParameter(ParameterOmega);
set => GetParameter(ParameterOmega) = value;
}

/// <summary>
/// Gets or sets the phi p velocity parameter.
/// </summary>
Expand All @@ -131,7 +130,7 @@ public TElementType PhiP
get => GetParameter(ParameterPhiP);
set => GetParameter(ParameterPhiP) = value;
}

/// <summary>
/// Gets or sets the phi g velocity parameter.
/// </summary>
Expand Down
8 changes: 1 addition & 7 deletions Src/ILGPU.Algorithms/RadixSortOperations.tt
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: RadixSortOperations.tt/RadixSortOperations.cs
Expand All @@ -27,9 +27,6 @@ namespace ILGPU.Algorithms.RadixSortOperations
/// <summary>
/// Represents an ascending radix sort operation of type <#= type.Type #>.
/// </summary>
<# if (!type.IsCLSCompliant) { #>
[CLSCompliant(false)]
<# } #>
public readonly struct Ascending<#=type.Name #> :
IRadixSortOperation<<#= type.Type #>>
{
Expand Down Expand Up @@ -100,9 +97,6 @@ namespace ILGPU.Algorithms.RadixSortOperations
/// <summary>
/// Represents a descending radix sort operation of type <#= type.Type #>.
/// </summary>
<# if (!type.IsCLSCompliant) { #>
[CLSCompliant(false)]
<# } #>
public readonly struct Descending<#= type.Name #> :
IRadixSortOperation<<#= type.Type #>>
{
Expand Down
1 change: 0 additions & 1 deletion Src/ILGPU.Algorithms/Random/IRandomProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public interface IRandomProvider
/// An abstract RNG provider that supports period shifts.
/// </summary>
/// <typeparam name="TProvider">The implementing provider type.</typeparam>
[CLSCompliant(false)]
public interface IRandomProvider<TProvider> : IRandomProvider
where TProvider : struct, IRandomProvider<TProvider>
{
Expand Down
4 changes: 0 additions & 4 deletions Src/ILGPU.Algorithms/Random/RNG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public abstract class RNG : AcceleratorObject
/// <typeparam name="TRandomProvider">The random provider type.</typeparam>
/// <param name="accelerator">The current accelerator.</param>
/// <param name="random">The parent RNG provider.</param>
[CLSCompliant(false)]
public static RNG<TRandomProvider> Create<TRandomProvider>(
Accelerator accelerator,
System.Random random)
Expand All @@ -47,7 +46,6 @@ public static RNG<TRandomProvider> Create<TRandomProvider>(
/// <param name="maxNumParallelWarps">
/// The maximum number of parallel warps.
/// </param>
[CLSCompliant(false)]
public static RNG<TRandomProvider> Create<TRandomProvider>(
Accelerator accelerator,
System.Random random,
Expand Down Expand Up @@ -148,7 +146,6 @@ public abstract void FillUniform(
/// is stored within an underlying memory buffer.
/// </summary>
/// <typeparam name="TRandomProvider">The random provider type.</typeparam>
[CLSCompliant(false)]
public readonly struct RNGView<TRandomProvider> : IRandomProvider
where TRandomProvider : unmanaged, IRandomProvider<TRandomProvider>
{
Expand Down Expand Up @@ -259,7 +256,6 @@ public readonly double NextDouble() =>
/// </summary>
/// <typeparam name="TRandomProvider">The random provider type.</typeparam>
/// <remarks>Members of this class are not thread safe.</remarks>
[CLSCompliant(false)]
public class RNG<TRandomProvider> : RNG
where TRandomProvider : unmanaged, IRandomProvider<TRandomProvider>
{
Expand Down
5 changes: 1 addition & 4 deletions Src/ILGPU.Algorithms/Random/RandomExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ public static long Next<TRandomProvider>(
/// <typeparam name="TRandomProvider">The random provider type.</typeparam>
/// <param name="accelerator">The current accelerator.</param>
/// <param name="random">The parent RNG provider.</param>
[CLSCompliant(false)]
public static RNG<TRandomProvider> CreateRNG<TRandomProvider>(
this Accelerator accelerator,
System.Random random)
Expand All @@ -196,7 +195,6 @@ public static RNG<TRandomProvider> CreateRNG<TRandomProvider>(
/// <param name="maxNumParallelWarps">
/// The maximum number of parallel warps.
/// </param>
[CLSCompliant(false)]
public static RNG<TRandomProvider> CreateRNG<TRandomProvider>(
this Accelerator accelerator,
System.Random random,
Expand All @@ -220,7 +218,7 @@ internal static void InitializeRNGKernel<TRandomProvider>(
{
randomProvider[i] = default(TRandomProvider).CreateProvider(ref provider);
}

// Update provider state for future iterations
sourceProviders[index] = provider;
}
Expand All @@ -236,7 +234,6 @@ internal static void InitializeRNGKernel<TRandomProvider>(
/// <param name="rngView">The view to fill.</param>
/// <param name="random">The source RNG provider.</param>
/// <param name="numInitializers">The number of CPU initializers to use.</param>
[CLSCompliant(false)]
public static void InitRNGView<TRandomProvider>(
this Accelerator accelerator,
AcceleratorStream stream,
Expand Down
11 changes: 5 additions & 6 deletions Src/ILGPU.Algorithms/Random/ThreadWiseRNG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ namespace ILGPU.Algorithms.Random
/// Represents a single RNG instance per thread stored separately in a memory buffer.
/// </summary>
/// <typeparam name="TRandomProvider">The underlying RNG provider type.</typeparam>
[CLSCompliant(false)]
public class ThreadWiseRNG<TRandomProvider> : DisposeBase
where TRandomProvider : unmanaged, IRandomProvider<TRandomProvider>
{
#region Instance

/// <summary>
/// Stores a single RNG instance per thread.
/// </summary>
private readonly MemoryBuffer1D<TRandomProvider, Stride1D.Dense> randomProviders;

/// <summary>
/// Constructs an RNG using the given provider instance.
/// </summary>
Expand All @@ -54,9 +53,9 @@ public ThreadWiseRNG(
randomProviders = accelerator.Allocate1D<TRandomProvider>(maxNumThreads);
accelerator.InitRNGView(stream, RNGView, random, numInitializers);
}

#endregion

#region Methods

/// <summary>
Expand All @@ -65,7 +64,7 @@ public ThreadWiseRNG(
public ArrayView<TRandomProvider> RNGView => randomProviders.View;

#endregion

#region IDisposable

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion Src/ILGPU.Algorithms/Random/XorShift128.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace ILGPU.Algorithms.Random
/// Implements a simple and fast xor-shift rng.
/// </summary>
/// <remarks>https://en.wikipedia.org/wiki/Xorshift</remarks>
[CLSCompliant(false)]
public struct XorShift128 : IEquatable<XorShift128>, IRandomProvider<XorShift128>
{
#region Static
Expand Down
1 change: 0 additions & 1 deletion Src/ILGPU.Algorithms/Random/XorShift128Plus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace ILGPU.Algorithms.Random
/// Implements a simple and fast xor-shift rng.
/// </summary>
/// <remarks>https://en.wikipedia.org/wiki/Xorshift</remarks>
[CLSCompliant(false)]
public struct XorShift128Plus :
IEquatable<XorShift128Plus>,
IRandomProvider<XorShift128Plus>
Expand Down
1 change: 0 additions & 1 deletion Src/ILGPU.Algorithms/Random/XorShift32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace ILGPU.Algorithms.Random
/// Implements a simple and fast xor-shift rng.
/// </summary>
/// <remarks>https://en.wikipedia.org/wiki/Xorshift</remarks>
[CLSCompliant(false)]
public struct XorShift32 : IEquatable<XorShift32>, IRandomProvider<XorShift32>
{
#region Static
Expand Down
1 change: 0 additions & 1 deletion Src/ILGPU.Algorithms/Random/XorShift64Star.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace ILGPU.Algorithms.Random
/// Implements a simple and fast xor-shift rng.
/// </summary>
/// <remarks>https://en.wikipedia.org/wiki/Xorshift</remarks>
[CLSCompliant(false)]
public struct XorShift64Star :
IEquatable<XorShift64Star>,
IRandomProvider<XorShift64Star>
Expand Down
1 change: 0 additions & 1 deletion Src/ILGPU.Algorithms/Runtime/Cuda/API/CuFFTAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace ILGPU.Runtime.Cuda.API
/// <summary>
/// An implementation of the cuFFT API.
/// </summary>
[CLSCompliant(false)]
public abstract partial class CuFFTAPI
{
#region Static
Expand Down
1 change: 0 additions & 1 deletion Src/ILGPU.Algorithms/Runtime/Cuda/API/CuFFTWAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace ILGPU.Runtime.Cuda.API
/// <summary>
/// An implementation of the cuFFT API.
/// </summary>
[CLSCompliant(false)]
public abstract partial class CuFFTWAPI
{
#region Static
Expand Down
1 change: 0 additions & 1 deletion Src/ILGPU.Algorithms/Runtime/Cuda/API/NvJpegAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace ILGPU.Runtime.Cuda.API
/// <summary>
/// An implementation of the nvJpeg API.
/// </summary>
[CLSCompliant(false)]
public abstract partial class NvJpegAPI
{
#region Static
Expand Down
2 changes: 0 additions & 2 deletions Src/ILGPU.Algorithms/Runtime/Cuda/API/NvmlAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace ILGPU.Runtime.Cuda.API
/// <summary>
/// An implementation of the NVML API.
/// </summary>
[CLSCompliant(false)]
public abstract partial class NvmlAPI
{
#region Static
Expand Down Expand Up @@ -281,7 +280,6 @@ public unsafe NvmlReturn DeviceGetBoardPartNumber(
/// Provides access to <see cref="DeviceGetBridgeChipInfo_Interop"/>
/// without using raw pointers.
/// </summary>
[CLSCompliant(false)]
public unsafe NvmlReturn DeviceGetBridgeChipInfo(
IntPtr device,
out NvmlBridgeChipHierarchy bridgeHierarchy)
Expand Down
1 change: 0 additions & 1 deletion Src/ILGPU.Algorithms/Runtime/Cuda/CuFFT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace ILGPU.Runtime.Cuda
/// <summary>
/// Wrapper over cuFFT to simplify integration with ILGPU.
/// </summary>
[CLSCompliant(false)]
public sealed class CuFFT
{
/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions Src/ILGPU.Algorithms/Runtime/Cuda/CuFFTPlan.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: CuFFTPlan.cs
Expand All @@ -18,7 +18,6 @@ namespace ILGPU.Runtime.Cuda
/// <summary>
/// Represents a cuFFT plan.
/// </summary>
[CLSCompliant(false)]
public sealed partial class CuFFTPlan : DisposeBase
{
/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions Src/ILGPU.Algorithms/Runtime/Cuda/CuFFTW.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: CuFFTW.cs
Expand All @@ -17,7 +17,6 @@ namespace ILGPU.Runtime.Cuda
/// <summary>
/// Wrapper over cuFFTW to simplify integration with ILGPU.
/// </summary>
[CLSCompliant(false)]
public sealed partial class CuFFTW
{
/// <summary>
Expand Down
Loading

0 comments on commit 9ddca0b

Please sign in to comment.