Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/coreclr/jit/fgprofilesynthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,12 +1411,19 @@ void ProfileSynthesis::GaussSeidelSolver()
countVector[block->bbNum] = newWeight;

// Remember max absolute and relative change
// (note rel residual will be infinite at times, that's ok)
// (note rel residual will be as large as 1e9 at times, that's ok)
//
// Note we are using a "point" bound here ("infinity norm") rather than say
// computing the L2-norm of the entire residual vector.
//
weight_t const blockRelResidual = change / oldWeight;
weight_t const smallFractionOfChange = 1e-9 * change;
weight_t relDivisor = oldWeight;
if (relDivisor < smallFractionOfChange)
{
relDivisor = smallFractionOfChange;
}

weight_t const blockRelResidual = change / relDivisor;
Comment on lines +1419 to +1426
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering can't it just be something like weight_t const blockRelResidual = change / (oldWeight + 1e-10)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that would have worked too.

Copy link
Member Author

@AndyAyersMS AndyAyersMS Apr 23, 2025

Choose a reason for hiding this comment

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

Turns out @hez2010 had a better fix. If change is zero we will end up with 0.0 / 0.0 which causes an "invalid FP operation" exception.


if ((relResidualBlock == nullptr) || (blockRelResidual > relResidual))
{
Expand Down
Loading