Skip to content

Commit

Permalink
Added fixed-precision numbers using Int32 and Int64 base types. (#1162)
Browse files Browse the repository at this point in the history
* Added new fixed precision computation types based on int and long types.
* Added FixedIntConfig.ttinclude to control fixed precision type generation.
* Added new generator template to ILGPU.Algorithms.csproj and adjusted ignore file.
* Extended VectorTypes.tt to generate vector types for fixed precision int types.
* Integrated fixed precision types with RandomRanges.tt.

Co-authored-by: Julian Gross <[email protected]>
  • Loading branch information
m4rs-mt and dfki-jugr authored Feb 23, 2024
1 parent 3c455a4 commit 18ed8ee
Show file tree
Hide file tree
Showing 7 changed files with 1,009 additions and 15 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ Src/ILGPU/Util/PrimitiveDataBlocks.cs
Src/ILGPU.Algorithms/AlgorithmContextMappings.cs
Src/ILGPU.Algorithms/CL/CLContext.Generated.cs
Src/ILGPU.Algorithms/ComparisonOperations.cs
Src/ILGPU.Algorithms/FixedPrecision/FixedInts.cs
Src/ILGPU.Algorithms/HistogramLaunchers.cs
Src/ILGPU.Algorithms/HistogramOperations.cs
Src/ILGPU.Algorithms/IL/ILContext.Generated.cs
Src/ILGPU.Algorithms/PTX/PTXContext.Generated.cs
Src/ILGPU.Algorithms/RadixSortOperations.cs
Src/ILGPU.Algorithms/Vectors/VectorTypes.cs
Src/ILGPU.Algorithms/Random/RandomRanges.cs
Src/ILGPU.Algorithms/Runtime/Cuda/API/CuBlasNativeMethods.cs
Src/ILGPU.Algorithms/Runtime/Cuda/API/CuFFTAPI.Generated.cs
Expand All @@ -314,10 +314,11 @@ Src/ILGPU.Algorithms/Runtime/Cuda/CuFFTWPlan.cs
Src/ILGPU.Algorithms/ScanReduceOperations.cs
Src/ILGPU.Algorithms/Sequencers.cs
Src/ILGPU.Algorithms/UniqueLaunchers.cs
Src/ILGPU.Algorithms/XMath/Cordic.cs
Src/ILGPU.Algorithms/Vectors/VectorTypes.cs
Src/ILGPU.Algorithms/XMath/Cordic.Log.cs
Src/ILGPU.Algorithms/XMath/Cordic.Pow.cs
Src/ILGPU.Algorithms/XMath/Cordic.Trig.cs
Src/ILGPU.Algorithms/XMath/Cordic.cs
Src/ILGPU.Algorithms/XMath/RoundingModes.cs

# Generated test source files
Expand Down
59 changes: 59 additions & 0 deletions Src/ILGPU.Algorithms/FixedPrecision/FixedIntConfig.ttinclude
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// ---------------------------------------------------------------------------------------
// ILGPU Algorithms
// Copyright (c) 2023-2024 ILGPU Project
// www.ilgpu.net
//
// File: FixedIntConfig.ttinclude
//
// This file is part of ILGPU and is distributed under the University of Illinois Open
// Source License. See LICENSE.txt for details.
// ---------------------------------------------------------------------------------------

<#+
private readonly struct FixedIntConfig
{
public FixedIntConfig(
int bits,
string baseName,
string typeName,
string calcTypeName,
int[] variants)
{
Bits = bits;
BaseName = baseName;
TypeName = typeName;
CalcTypeName = calcTypeName;
Variants = variants;
}

public int Bits { get; }
public string BaseName { get; }
public string TypeName { get; }
public string CalcTypeName { get; }
public int[] Variants { get; }

public string GetName(int variant) => $"Fixed{BaseName}{variant}DP";

public TypeInformation ToBasicTypeInformation(int variant) => new TypeInformation(
GetName(variant),
GetName(variant),
TypeInformationKind.SignedInt,
prefix: "(int)");

public IEnumerable<TypeInformation> ToBasicTypeInformation() =>
Variants.Select(ToBasicTypeInformation);
}

private static FixedIntConfig[] FixedPrecisionIntTypes =
{
new FixedIntConfig(32, "Int", "int", "long", new int[]
{
2, 4, 6
}),
new FixedIntConfig(64, "Long", "long", "long", new int[]
{
2, 4, 6, 8
})
};

#>
Loading

0 comments on commit 18ed8ee

Please sign in to comment.