Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing the Vector*_Intrinsics.cs file, regions from the numerics code, and normalizing the member order #41898

Merged
merged 2 commits into from
Sep 11, 2020

Conversation

tannergooding
Copy link
Member

This does some cleanup on the System.Numerics code to make it more maintainable and hopefully simplify diffs for some upcoming changes to intrinsify more of the code.

Namely, it merges the Vector*_Intrinsics.cs file back into the Vector*.cs file as this separation doesn't strictly make sense anymore.
The _Intrinsic.cs file used to contain just methods which were intrinsic or delegated to intrinsic methods, however, with the current JIT codebase that line isn't very clearly drawn.

It also removes the use of #region throughout the code. We don't typically use regions elsewhere in the runtime repo and so this normalizes the convention.

Finally, it normalizes the member order so that rather than having members somewhat randomly, they are ordered as fields, constructors, properties, operators, static methods, methods; which is roughly the general order many other files in the runtime repo follow.
Members within a particular group; barring fields; are alphabetically ordered.

This should contain no functional changes modulo a couple locations where, for example, static Matrix4x4 Add() was changed to forward to operator +, rather than simply duplicating the logic.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 4, 2020
@tannergooding
Copy link
Member Author

CC. @eerhardt, @pgovind

/// A structure encapsulating a four-dimensional vector (x,y,z,w),
/// which is used to efficiently rotate an object about the (x,y,z) vector by the angle theta, where w = cos(theta/2).
/// </summary>
/// <summary>A structure encapsulating a four-dimensional vector (x,y,z,w), which is used to efficiently rotate an object about the (x,y,z) vector by the angle theta, where w = cos(theta/2).</summary>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is more readable since now the reader has to horizontally scroll to read the whole thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't consistently cap line length anywhere else and these docs are hardly used. I don't even think they match what shows in current IntelliSense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and they definitely don't match what we show in the docs: https://docs.microsoft.com/en-us/dotnet/api/system.numerics.quaternion?view=netcore-3.1)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make it worse? At least before this change a reader didn't need to scroll. This change provides negative value IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it makes it better as these docs aren't relevant and it involves less scrolling to get to the bits you actually care about, the code.

It might be nice to either remove these docs (as they are massively out of date now anyways) or actually fix them to match what we have in the docs repo.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerhardt, would you have a concern if I just removed the docs as part of this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the docs are wrong or don't add value, then I wouldn't have any concern removing them.

However, in this case I think this summary is adding value, as most people (myself included) don't know what a Quaternion is off the top of their head.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the summary to Represents a vector that is used to encode three-dimensional physical rotations., which matches the current docs and is shorter so the scrolling shouldn't be a concern.

public readonly bool IsIdentity
{
get
{
return M11 == 1f && M22 == 1f && // Check diagonal element first for early out.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the checking of the diagonal elements first no longer an important optimization?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operator == is itself doing a diagonal element first check.

The eventual vectorized version will just do two comparisons anyways and so at that point it won't matter.

@tannergooding
Copy link
Member Author

@eerhardt, do you have any other feedback.
@pgovind, when you get the chance, could you give this a pass as well?

Copy link

@pgovind pgovind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Like you said, doesn't really contain any significant changes

@tannergooding tannergooding merged commit e64bc54 into dotnet:master Sep 11, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants