-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fixed-precision numbers using Int32 and Int64 base types. (#1162)
* 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
Showing
7 changed files
with
1,009 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
Src/ILGPU.Algorithms/FixedPrecision/FixedIntConfig.ttinclude
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) | ||
}; | ||
|
||
#> |
Oops, something went wrong.