Skip to content

Making floating-point calculations consistent across platforms - Round 1#1668

Merged
cameronwhite merged 4 commits into
PintaProject:masterfrom
Lehonti:improvement/consistent_floating_point_calculations
Aug 15, 2025
Merged

Making floating-point calculations consistent across platforms - Round 1#1668
cameronwhite merged 4 commits into
PintaProject:masterfrom
Lehonti:improvement/consistent_floating_point_calculations

Conversation

@Lehonti

@Lehonti Lehonti commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

A Mandelbrot test is annotated with Ignore because the generated image is slightly different across platforms "for unknown reasons". Could it just be that "native" floating-point operations give different results depending on the processor architecture, and it could be fixed by making them consistent, even if the calculations are less optimized?

I don't currently have any way to test Pinta locally on an ARM processor, so I will open this pull request and do the following:

  • In the first commit, I will remove the Ignore attribute. I would expect the tests (running as part of the build) to fail
  • Then, in the second commit, I will add a configuration file for the runtime, turning off certain optimizations, and see how the build goes. Best-case scenario, the tests will succeed.
  • If the tests for the second commit fail, I will update the tests and try again. After this, I would expect the tests to succeed, because the output would have changed, but it would be consistent across platforms (?)

@Lehonti Lehonti marked this pull request as draft August 13, 2025 23:36
@Lehonti

Lehonti commented Aug 13, 2025

Copy link
Copy Markdown
Contributor Author

When I removed the Ignore attribute, tests failed on all platforms (except Ubuntu 9.0, which was not run), so I wonder what happens if the tests run on the updated output, without the configuration file. I will remove it and see how it goes.

@Lehonti

Lehonti commented Aug 14, 2025

Copy link
Copy Markdown
Contributor Author

Just by replacing the Mandelbrot1 image, the tests succeeded in all platforms, even without the configuration file. I think the wrong image was being used for the tests. But how was the previous image generated in the first place?

Anyway, this mergeable progress is a byproduct of our discovery. For that reason I will now rename this pull request to specify that it is "Round 1" and I will open it for review.

In the next 'round' I will address the following:
In #1665 I had to Ignore a test because the effect seemingly produces different results in different platforms. So if/when it gets merged I would like to see if I can make the results consistent across platforms.

@Lehonti Lehonti changed the title Making floating-point calculations consistent across platforms Making floating-point calculations consistent across platforms - Round 1 Aug 14, 2025
@Lehonti Lehonti marked this pull request as ready for review August 14, 2025 01:04
@cameronwhite

Copy link
Copy Markdown
Member

Thanks for investigating! The output file probably hadn't been updated in a while since the test was ignored (or maybe it was generated incorrectly originally), so it's possible that the differences were fixed / avoided by some changes in the meantime

@cameronwhite cameronwhite merged commit 37ec0d1 into PintaProject:master Aug 15, 2025
6 checks passed
@Lehonti Lehonti deleted the improvement/consistent_floating_point_calculations branch August 15, 2025 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants