Skip to content

Conversation

MialLewis
Copy link
Contributor

@MialLewis MialLewis commented Jul 11, 2025

Description of work

Summary of work

This PR removes the use of Mantid::CurveFitting::EigenMatrix from the Muon library to avoid the linking of two plugin libraries.

We use PartialPivLU decomposition in calculating the inverse, replicating what the Mantid::CurveFitting::EigenMatrix is doing under the hood.

long double is used on arm mac, as it brings precision of eigen matrix multiplication inline (lowers it) with the other operating systems. I'm not sure why, you would expect a greater degree of precision.

Here is a compiler explorer used to interrogate the differences when different types are used with eigen across our compilers: https://godbolt.org/z/51W6KPecb

This illustrates the issue, but doesn't show the same impact on arm64 of switching to long double.

Testing change on arm: https://builds.mantidproject.org/job/build_packages_from_branch/1200/

Fixes #39644

Reviewer

Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.

Code Review

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

Does everything look good? Mark the review as Approve. A member of @mantidproject/gatekeepers will take care of it.

Gatekeeper

If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.

@MialLewis MialLewis marked this pull request as ready for review July 11, 2025 13:06
@thomashampson thomashampson changed the base branch from main to release-next July 11, 2025 13:53
@thomashampson thomashampson changed the base branch from release-next to main July 11, 2025 13:53
@MialLewis MialLewis changed the base branch from main to release-next July 11, 2025 13:55
@MialLewis MialLewis changed the base branch from release-next to main July 11, 2025 13:55
@thomashampson thomashampson added the Patch Candidate Urgent issues that must be included in a patch following a release label Jul 11, 2025
@thomashampson thomashampson added this to the Release 6.13.1 milestone Jul 11, 2025
@MialLewis MialLewis force-pushed the remove_link_between_muon_and_curvefitting_libs branch from 33b17d7 to 011ac0b Compare July 11, 2025 14:27
@MialLewis MialLewis changed the base branch from main to release-next July 11, 2025 14:27
@sf1919 sf1919 moved this to In review in ISIS core workstream v6.14.0 Jul 15, 2025
@sf1919 sf1919 moved this from In review to In Progress in ISIS core workstream v6.14.0 Jul 15, 2025
@cailafinn cailafinn assigned cailafinn and unassigned cailafinn Jul 15, 2025
@jclarkeSTFC
Copy link
Contributor

On Windows (and maybe ARM) a long double is 8 bytes, but is 16 bytes on Linux and macOS, might cause differences, the standard only specifies that it has at least as much precision as a double.

@MialLewis
Copy link
Contributor Author

MialLewis commented Jul 16, 2025

and maybe ARM) a long double is

This is what I'm working with at the moment: https://godbolt.org/z/hf7GhGs77

Results are inconsistent when using double/long double.

private:
MatrixWorkspace_sptr m_loadedData;
IAlgorithm_sptr phaseQuad;
IAlgorithm_sptr m_phaseQuad;
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

const double X = n0[h] * asym * cos(phi);
const double Y = n0[h] * asym * sin(phi);
n0Vectors[h] = CurveFitting::EigenVector({X, Y});
Eigen::Vector<eigenDataType, 2> n0vec;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unused, will push after review.

Copy link
Contributor

@sf1919 sf1919 left a comment

Choose a reason for hiding this comment

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

I have done a functional test on Windows and on Linux (Ubuntu 20.04) and the two Muon GUIs open without any problem.

The code looks sensible.

I am assuming this does not need a release note @thomashampson ?

@thomashampson thomashampson self-assigned this Jul 17, 2025
@thomashampson thomashampson merged commit 0afe4e0 into release-next Jul 17, 2025
10 checks passed
@thomashampson thomashampson deleted the remove_link_between_muon_and_curvefitting_libs branch July 17, 2025 16:15
@github-project-automation github-project-automation bot moved this from In Progress to Done in ISIS core workstream v6.14.0 Jul 17, 2025
@thomashampson
Copy link
Contributor

release notes will be added separately

peterfpeterson pushed a commit to peterfpeterson/mantid that referenced this pull request Jul 17, 2025
This PR removes the use of `Mantid::CurveFitting::EigenMatrix` from the
`Muon` library to avoid the linking of two plugin libraries.

We use `PartialPivLU` decomposition in calculating the inverse,
replicating what the `Mantid::CurveFitting::EigenMatrix` is doing under
the hood.

`long double` is used on arm mac, as it brings precision of eigen matrix
multiplication inline (lowers it) with the other operating systems. I'm
not sure why, you would expect a greater degree of precision.

Here is a compiler explorer used to interrogate the differences when
different types are used with eigen across our compilers:
https://godbolt.org/z/51W6KPecb

This illustrates the issue, but doesn't show the same impact on arm64 of
switching to `long double`.
peterfpeterson added a commit that referenced this pull request Jul 17, 2025
This is a version of #39656 into `ornl-next`

Co-authored-by: MialLewis <95620982+MialLewis@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Patch Candidate Urgent issues that must be included in a patch following a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Muon analysis interface crash on Linux
5 participants