Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Fix review comments related to comment block
Browse files Browse the repository at this point in the history
  • Loading branch information
WinCPP committed Jan 27, 2018
1 parent cba0390 commit 384691d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,42 @@
string keyword = (type == allTypes.ToArray()[0]) ? "if" : "else if";
return string.Format("{0} (typeof(T) == typeof({1}))", keyword, type.Name);
}
#>

public void GenerateUsagePattern()
{
#>/* Note: The following patterns are used throughout the code here and are described here
*
* PATTERN:
* if (typeof(T) == typeof(Int32)) { ... }
* else if (typeof(T) == typeof(Single)) { ... }
* EXPLANATION:
* At runtime, each instantiation of Vector<T> will be type-specific, and each of these typeof blocks will be eliminated,
* as typeof(T) is a (JIT) compile-time constant for each instantiation. This design was chosen to eliminate any overhead from
* delegates and other patterns.
*
* PATTERN:
* if (Vector.IsHardwareAccelerated) { ... }
* else { ... }
* EXPLANATION
* This pattern solves two problems:
* 1. Allows us to unroll loops when we know the size (when no hardware acceleration is present)
* 2. Allows reflection to work:
* - If a method is called via reflection, it will not be "intrinsified", which would cause issues if we did
* not provide an implementation for that case (i.e. if it only included a case which assumed 16-byte registers)
* (NOTE: It is assumed that Vector.IsHardwareAccelerated will be a compile-time constant, eliminating these checks
* from the JIT'd code.)
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
<#+
}

public void GenerateVectorSummary()
{
#>/// <summary>
/// A structure that represents a single Vector. The count of this Vector is fixed but CPU register dependent.
/// This struct only supports numerical types. This type is intended to be used as a building block for vectorizing
/// large algorithms. This type is immutable, individual elements cannot be modified.
/// </summary>
<#+
}
#>
2 changes: 1 addition & 1 deletion src/System.Numerics.Vectors/src/System/Numerics/Vector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace System.Numerics
* from the JIT'd code.)
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/// <summary>
/// A structure that represents a single Vector. The count of this Vector is fixed but CPU register dependent.
/// This struct only supports numerical types. This type is intended to be used as a building block for vectorizing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace System.Numerics
* from the JIT'd code.)
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/// <summary>
/// A structure that represents a single Vector. The count of this Vector is fixed but CPU register dependent.
/// This struct only supports numerical types. This type is intended to be used as a building block for vectorizing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,9 @@

namespace System.Numerics
{
/* Note: The following patterns are used throughout the code here and are described here
*
* PATTERN:
* if (typeof(T) == typeof(Int32)) { ... }
* else if (typeof(T) == typeof(Single)) { ... }
* EXPLANATION:
* At runtime, each instantiation of Vector<T> will be type-specific, and each of these typeof blocks will be eliminated,
* as typeof(T) is a (JIT) compile-time constant for each instantiation. This design was chosen to eliminate any overhead from
* delegates and other patterns.
*
* PATTERN:
* if (Vector.IsHardwareAccelerated) { ... }
* else { ... }
* EXPLANATION
* This pattern solves two problems:
* 1. Allows us to unroll loops when we know the size (when no hardware acceleration is present)
* 2. Allows reflection to work:
* - If a method is called via reflection, it will not be "intrinsified", which would cause issues if we did
* not provide an implementation for that case (i.e. if it only included a case which assumed 16-byte registers)
* (NOTE: It is assumed that Vector.IsHardwareAccelerated will be a compile-time constant, eliminating these checks
* from the JIT'd code.)
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
<# GenerateUsagePattern(); #>

/// <summary>
/// A structure that represents a single Vector. The count of this Vector is fixed but CPU register dependent.
/// This struct only supports numerical types. This type is intended to be used as a building block for vectorizing
/// large algorithms. This type is immutable, individual elements cannot be modified.
/// </summary>
<# GenerateVectorSummary(); #>
public partial struct Vector<T> : IEquatable<Vector<T>>, IFormattable where T : struct
{
#region Constructors
Expand Down
32 changes: 3 additions & 29 deletions src/System.Numerics.Vectors/src/System/Numerics/Vector.tt
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,9 @@ using System.Text;

namespace System.Numerics
{
/* Note: The following patterns are used throughout the code here and are described here
*
* PATTERN:
* if (typeof(T) == typeof(Int32)) { ... }
* else if (typeof(T) == typeof(Single)) { ... }
* EXPLANATION:
* At runtime, each instantiation of Vector<T> will be type-specific, and each of these typeof blocks will be eliminated,
* as typeof(T) is a (JIT) compile-time constant for each instantiation. This design was chosen to eliminate any overhead from
* delegates and other patterns.
*
* PATTERN:
* if (Vector.IsHardwareAccelerated) { ... }
* else { ... }
* EXPLANATION
* This pattern solves two problems:
* 1. Allows us to unroll loops when we know the size (when no hardware acceleration is present)
* 2. Allows reflection to work:
* - If a method is called via reflection, it will not be "intrinsified", which would cause issues if we did
* not provide an implementation for that case (i.e. if it only included a case which assumed 16-byte registers)
* (NOTE: It is assumed that Vector.IsHardwareAccelerated will be a compile-time constant, eliminating these checks
* from the JIT'd code.)
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/// <summary>
/// A structure that represents a single Vector. The count of this Vector is fixed but CPU register dependent.
/// This struct only supports numerical types. This type is intended to be used as a building block for vectorizing
/// large algorithms. This type is immutable, individual elements cannot be modified.
/// </summary>
<# GenerateUsagePattern(); #>

<# GenerateVectorSummary(); #>
public partial struct Vector<T> : IEquatable<Vector<T>>, IFormattable where T : struct
{
#region Fields
Expand Down

0 comments on commit 384691d

Please sign in to comment.