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

Fix CircleInConvex test #68475

Merged
merged 1 commit into from
Apr 25, 2022
Merged

Fix CircleInConvex test #68475

merged 1 commit into from
Apr 25, 2022

Conversation

hez2010
Copy link
Contributor

@hez2010 hez2010 commented Apr 25, 2022

Cherry-picked from #68436.

The original cmp function in CircleInConvex test is malformed:

static int cmp(Point a, Point b)
{
    if (a.X < b.X || a.X == b.X && a.Y < b.Y)
        return 1;
    else
        return 0;
}

The above cmp function results in indeterminate behavior, which is strongly coupled with introsort behavior (code really shouldn't assume Array.Sort having a introsort implementation).

Note that If I switch to sort algorithm other than intersort such as heap sort, insertion sort and etc, or even keep the introsort but sort it twice, the CircleInConvex will also fail without this change.

Also, the original expRes was incorrect. The new expRes is verified using a convex-hull algorithm locally:

Convex-hull points:

X Y
-1.7994474E+09 -1.2456694E-05
-14.506294 2.1465364E+09
1.3253972E+09 6.081364E-10
0.37576595 -1.6159191E+09

Origin: (-146892800, 117045950)
Radius: 1.191233E+09

/cc: @jkotas

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Apr 25, 2022
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Apr 25, 2022
@ghost
Copy link

ghost commented Apr 25, 2022

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

Cherry-picked from #68436.

The cmp function in CircleInConvex test is malformed:

static int cmp(Point a, Point b)
{
    if (a.X < b.X || a.X == b.X && a.Y < b.Y)
        return 1;
    else
        return 0;
}

The above cmp function results in indeterminate behavior, which is strongly coupled with introsort behavior (code really shouldn't assume Array.Sort having a introsort implementation).

Note that If I change to any sort algorithm other than intersort such as heap sort, insertion sort and etc, or even keep the introsort but sort it twice, the CircleInConvex will also fail without this change.

Author: hez2010
Assignees: -
Labels:

area-CodeGen-coreclr, community-contribution

Milestone: -

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@jkotas jkotas merged commit a0d8f48 into dotnet:main Apr 25, 2022
@hez2010 hez2010 deleted the testfix branch April 25, 2022 17:09
@ghost ghost locked as resolved and limited conversation to collaborators May 25, 2022
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 community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants