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

Commit 384691d

Browse files
committed
Fix review comments related to comment block
1 parent cba0390 commit 384691d

File tree

5 files changed

+46
-60
lines changed

5 files changed

+46
-60
lines changed

src/System.Numerics.Vectors/src/System/Numerics/GenerationConfig.ttinclude

+39-1
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,42 @@
144144
string keyword = (type == allTypes.ToArray()[0]) ? "if" : "else if";
145145
return string.Format("{0} (typeof(T) == typeof({1}))", keyword, type.Name);
146146
}
147-
#>
147+
148+
public void GenerateUsagePattern()
149+
{
150+
#>/* Note: The following patterns are used throughout the code here and are described here
151+
*
152+
* PATTERN:
153+
* if (typeof(T) == typeof(Int32)) { ... }
154+
* else if (typeof(T) == typeof(Single)) { ... }
155+
* EXPLANATION:
156+
* At runtime, each instantiation of Vector<T> will be type-specific, and each of these typeof blocks will be eliminated,
157+
* as typeof(T) is a (JIT) compile-time constant for each instantiation. This design was chosen to eliminate any overhead from
158+
* delegates and other patterns.
159+
*
160+
* PATTERN:
161+
* if (Vector.IsHardwareAccelerated) { ... }
162+
* else { ... }
163+
* EXPLANATION
164+
* This pattern solves two problems:
165+
* 1. Allows us to unroll loops when we know the size (when no hardware acceleration is present)
166+
* 2. Allows reflection to work:
167+
* - If a method is called via reflection, it will not be "intrinsified", which would cause issues if we did
168+
* not provide an implementation for that case (i.e. if it only included a case which assumed 16-byte registers)
169+
* (NOTE: It is assumed that Vector.IsHardwareAccelerated will be a compile-time constant, eliminating these checks
170+
* from the JIT'd code.)
171+
*
172+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
173+
<#+
174+
}
175+
176+
public void GenerateVectorSummary()
177+
{
178+
#>/// <summary>
179+
/// A structure that represents a single Vector. The count of this Vector is fixed but CPU register dependent.
180+
/// This struct only supports numerical types. This type is intended to be used as a building block for vectorizing
181+
/// large algorithms. This type is immutable, individual elements cannot be modified.
182+
/// </summary>
183+
<#+
184+
}
185+
#>

src/System.Numerics.Vectors/src/System/Numerics/Vector.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace System.Numerics
3232
* from the JIT'd code.)
3333
*
3434
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
35-
35+
3636
/// <summary>
3737
/// A structure that represents a single Vector. The count of this Vector is fixed but CPU register dependent.
3838
/// This struct only supports numerical types. This type is intended to be used as a building block for vectorizing

src/System.Numerics.Vectors/src/System/Numerics/Vector.netcoreapp.cs

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

src/System.Numerics.Vectors/src/System/Numerics/Vector.netcoreapp.tt

+2-28
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,9 @@
99

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

36-
/// <summary>
37-
/// A structure that represents a single Vector. The count of this Vector is fixed but CPU register dependent.
38-
/// This struct only supports numerical types. This type is intended to be used as a building block for vectorizing
39-
/// large algorithms. This type is immutable, individual elements cannot be modified.
40-
/// </summary>
14+
<# GenerateVectorSummary(); #>
4115
public partial struct Vector<T> : IEquatable<Vector<T>>, IFormattable where T : struct
4216
{
4317
#region Constructors

src/System.Numerics.Vectors/src/System/Numerics/Vector.tt

+3-29
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,9 @@ using System.Text;
1414

1515
namespace System.Numerics
1616
{
17-
/* Note: The following patterns are used throughout the code here and are described here
18-
*
19-
* PATTERN:
20-
* if (typeof(T) == typeof(Int32)) { ... }
21-
* else if (typeof(T) == typeof(Single)) { ... }
22-
* EXPLANATION:
23-
* At runtime, each instantiation of Vector<T> will be type-specific, and each of these typeof blocks will be eliminated,
24-
* as typeof(T) is a (JIT) compile-time constant for each instantiation. This design was chosen to eliminate any overhead from
25-
* delegates and other patterns.
26-
*
27-
* PATTERN:
28-
* if (Vector.IsHardwareAccelerated) { ... }
29-
* else { ... }
30-
* EXPLANATION
31-
* This pattern solves two problems:
32-
* 1. Allows us to unroll loops when we know the size (when no hardware acceleration is present)
33-
* 2. Allows reflection to work:
34-
* - If a method is called via reflection, it will not be "intrinsified", which would cause issues if we did
35-
* not provide an implementation for that case (i.e. if it only included a case which assumed 16-byte registers)
36-
* (NOTE: It is assumed that Vector.IsHardwareAccelerated will be a compile-time constant, eliminating these checks
37-
* from the JIT'd code.)
38-
*
39-
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
40-
41-
/// <summary>
42-
/// A structure that represents a single Vector. The count of this Vector is fixed but CPU register dependent.
43-
/// This struct only supports numerical types. This type is intended to be used as a building block for vectorizing
44-
/// large algorithms. This type is immutable, individual elements cannot be modified.
45-
/// </summary>
17+
<# GenerateUsagePattern(); #>
18+
19+
<# GenerateVectorSummary(); #>
4620
public partial struct Vector<T> : IEquatable<Vector<T>>, IFormattable where T : struct
4721
{
4822
#region Fields

0 commit comments

Comments
 (0)