Skip to content

MNT: Update windows-2019 to windows-2022[wheel build] #28955

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

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

abhishek-iitmadras
Copy link
Contributor

@abhishek-iitmadras abhishek-iitmadras commented May 14, 2025

As per info in : actions/runner-images#12045
We need to change window runner.

@abhishek-iitmadras abhishek-iitmadras changed the title Update windows-2019 to windows-latest MNT: Update windows-2019 to windows-latest May 15, 2025
@charris
Copy link
Member

charris commented May 26, 2025

close/reopen

@charris charris closed this May 26, 2025
@charris charris reopened this May 26, 2025
@charris charris added this to the 2.3.0 release milestone May 26, 2025
@charris charris added the triage review Issue/PR to be discussed at the next triage meeting label May 26, 2025
@charris
Copy link
Member

charris commented May 26, 2025

Put a triage label on this, as the deadline is coming up and there are problems.

@charris
Copy link
Member

charris commented May 26, 2025

@h-vetinari Ping, because ISTR that you were involved last time we updated the windows version.

@charris
Copy link
Member

charris commented May 26, 2025

The failures seem to mostly come from test_unary_spurious_fpexception and accuracy in some ufuncs.

@charris
Copy link
Member

charris commented May 26, 2025

The failures seem to mostly come from test_unary_spurious_fpexception and accuracy in some ufuncs.

  • The test_unary_spurious_fpexception seems to come from OpenBLAS
  • The accuracy failures are in the no blas builds.

@h-vetinari
Copy link
Contributor

@h-vetinari Ping, because ISTR that you were involved last time we updated the windows version.

Thanks for the ping. The only place where this really becomes relevant is for linking to npymath.lib. Anyone doing that will most likely need to update to VS2022.

Given that VS2019 is EOL for over a year, and that VS2022 is an ABI-compatible update, this should not be an undue burden. The timing matches well, I've just picked up the proposal to move to VS2022 in conda-forge again.

@mattip
Copy link
Member

mattip commented May 27, 2025

The only place where this really becomes relevant is for linking to npymath.lib

Isn't this snippet meant to make a npymath.lib that can be used by older linkers?

if cc.get_id() == 'msvc'
# Disable voltbl section for vc142 to allow link using mingw-w64; see:
# https://github.com/matthew-brett/dll_investigation/issues/1#issuecomment-1100468171
# Needs to be added to static libraries that are shipped for reuse (i.e.,
# libnpymath and libnpyrandom)
if cc.has_argument('-d2VolatileMetadata-')
staticlib_cflags += '-d2VolatileMetadata-'
endif
endif

@mattip
Copy link
Member

mattip commented May 27, 2025

The test_unary_spurious_fpexception seems to come from OpenBLAS

Maybe related to #29039 which updates OpenBLAS

@h-vetinari
Copy link
Contributor

Isn't this snippet meant to make a npymath.lib that can be used by older linkers?

Not AFAIU. That's about reusing/sharing the objects in the static library between MSVC and mingw, and the comment from the upstream devs at the time was

Mixing static libraries or object files between mingw and msvc is not
supported, and not expected to work, in general. You might have been lucky
and your library might have been simple enough not to hit any problematic
case though.

The virality of the msvc toolset concerns being able to link to something built with VS2022 (which - at least on paper - then also requires VS2022)

@charris
Copy link
Member

charris commented May 28, 2025

Rather than latest, it would be better to explicitly use vs2022.

@charris
Copy link
Member

charris commented May 28, 2025

@seiko2plus The test_unary_spurious_fpexception are in ufunc = <ufunc 'spacing'> for f and d. I see that test is already skipped for e. Should we just skip it for f and d as well? Is there something we should do for SIMD instead?

@rgommers
Copy link
Member

The only place where this really becomes relevant is for linking to npymath.lib. Anyone doing that will most likely need to update to VS2022.

Agreed, which means we need to update to the 2022 image in SciPy first before merging this.

We should probably do that asap and then merge this and backport it to the 2.3.x branch. before releasing 2.3.0. Otherwise it'll become a potentially risky change in 2.3.1 or 2.3.2.

@abhishek-iitmadras abhishek-iitmadras changed the title MNT: Update windows-2019 to windows-latest MNT: Update windows-2019 to windows-2022 May 31, 2025
@abhishek-iitmadras
Copy link
Contributor Author

Look like i need to skip spacing test for window

@charris
Copy link
Member

charris commented Jun 1, 2025

vs2022 changes: https://devblogs.microsoft.com/cppblog/the-fpcontract-flag-and-changes-to-fp-modes-in-vs2022/

@abhishek-iitmadras
Copy link
Contributor Author

abhishek-iitmadras commented Jun 1, 2025

vs2022 changes: https://devblogs.microsoft.com/cppblog/the-fpcontract-flag-and-changes-to-fp-modes-in-vs2022/

Windows Server 2019: Uses older MSVC that generates FMA contractions by default
Windows Server 2022: Uses VS2022's MSVC which does NOT generate FMA contractions by default

This change significantly affects floating-point precision, especially for transcendental functions

So we need to add the /fp:contract flag to MSVC builds.

@charris
Copy link
Member

charris commented Jun 2, 2025

Windows Server 2022: Uses VS2022's MSVC which does NOT generate FMA contractions by default

Note that meson shows FMA3 enabled, but evidently a flag is required for msvc in vs2022. I'm not clear on whether meson should handle that or not. Unfortunately, the /fp:contract flag is new. Maybe disable FMA3 if the flag is missing for recent msvc? @rgommers Thoughts?

@@ -119,7 +119,7 @@ jobs:

- name: Build and install
run: |
python -m pip install . -v -Ccompile-args="-j2" -Csetup-args="-Dallow-noblas=true"
python -m pip install . -v -Ccompile-args="-j2" -Csetup-args="-Dallow-noblas=true" -Csetup-args="-Dc_args=/fp:contract" -Csetup-args="-Dcpp_args=/fp:contract"
Copy link
Member

Choose a reason for hiding this comment

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

This would read better with a line continuation \ to break the line. Probably for the previous use as well.

Copy link
Member

Choose a reason for hiding this comment

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

This should be part of the meson flags when building SIMD code. I suggest moving it here:

FMA3.update(args: {'val': '/arch:AVX2', 'match': clear_arch})

# Add compiler flags for 32-bit builds
if ("${{ matrix.buildplat[1] }}" -eq "win32") {
echo 'CIBW_CONFIG_SETTINGS=setup-args=-Dc_args="/fp:contract" setup-args=-Dcpp_args="/fp:contract"' >> $env:GITHUB_ENV
}
Copy link
Member

Choose a reason for hiding this comment

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

The extra flags should not be required after updating meson_cpu.

@charris
Copy link
Member

charris commented Jun 2, 2025

You need to do the update this way:

  FMA3.update(args: {'val': '/arch:AVX2', 'match': clear_arch})
  FMA3.update(args: {'val': '/fp:contract'})

@abhishek-iitmadras
Copy link
Contributor Author

abhishek-iitmadras commented Jun 2, 2025

You need to do the update this way:

  FMA3.update(args: {'val': '/arch:AVX2', 'match': clear_arch})
  FMA3.update(args: {'val': '/fp:contract'})

isn't it overriding the args for FMA3 ?Correct me if i am wrong

@abhishek-iitmadras
Copy link
Contributor Author

abhishek-iitmadras commented Jun 2, 2025

Hi @charris @r-devulap

  1. Now floating-point contract flag for 32-bit MSVC builds only is added to meson build .
  2. Skip spacing tests with NaN on Windows MSVC (all dtypes) only.

Please have a review to this patch.
Thanks


# Add floating-point contract flag for 32-bit builds
# Fixes transcendental function accuracy on Windows Server 2022
if cpu_family == 'x86'
Copy link
Member

Choose a reason for hiding this comment

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

This file is already under meson_cpu/x86/meson.build, you don't need the if condition here.

Copy link
Member

Choose a reason for hiding this comment

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

Don't we need the flag for 64-bit as well?

Copy link
Member

Choose a reason for hiding this comment

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

Don't we need the flag for 64-bit as well?

It doesn't seem required by us, but we probably do want it.

@charris
Copy link
Member

charris commented Jun 2, 2025

#29116 is working now. There is a bogus circleci failure that can be ignored. I'm curious if @r-devulap suggestion of putting the args in a list works.

@charris
Copy link
Member

charris commented Jun 2, 2025

The PyPy failure can be ignored.

@charris charris removed the triage review Issue/PR to be discussed at the next triage meeting label Jun 2, 2025
@charris charris modified the milestones: 2.3.0 release, 2.4.0 release Jun 2, 2025
@abhishek-iitmadras abhishek-iitmadras force-pushed the abhishek_window branch 6 times, most recently from 3a5335f to 4490065 Compare June 3, 2025 11:14
@abhishek-iitmadras
Copy link
Contributor Author

@rgommers @charris @r-devulap
This patch seems ok, please have a review and merge.


# Add floating-point contract flag for 32-bit builds
# Fixes transcendental function accuracy on Windows Server 2022
add_project_arguments('/fp:contract', language: ['c', 'cpp'])
Copy link
Member

Choose a reason for hiding this comment

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

This should depend on the existence of FMA. Note that add_project_arguments is not used elsewhere in cpu specific contexts.

@abhishek-iitmadras abhishek-iitmadras force-pushed the abhishek_window branch 3 times, most recently from 8f2916c to 16a8390 Compare June 3, 2025 16:03
@@ -211,7 +211,8 @@ if compiler_id == 'msvc'
fet.update(args: '')
endif
endforeach
FMA3.update(args: {'val': '/arch:AVX2', 'match': clear_arch})
# Add floating-point contract flag to fixes transcendental function accuracy on Windows Server 2022
FMA3.update(args: [{'val': '/arch:AVX2', 'match': clear_arch},{'val': '/fp:contract', 'match': clear_arch}])
Copy link
Member

Choose a reason for hiding this comment

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

Lets stick to the same way @charris fixed it in #29116:

Suggested change
FMA3.update(args: [{'val': '/arch:AVX2', 'match': clear_arch},{'val': '/fp:contract', 'match': clear_arch}])
FMA3.update(args: {'val': '/arch:AVX2', 'match': clear_arch})
FMA3.update(args: {'val': '/fp:contract'})

Tried it locally and confirmed that it picks up the flag correctly:

    "command": "\"cl\" \"-Inumpy\\_core\\libloops_trigonometric.dispatch.h_AVX2.a.p\" \"-Inumpy\\_core\" \"-I..\\numpy\\_core\" \"-Inumpy\\_core\\include\" \"-I..\\numpy\\_core\\include\" \"-I..\\numpy\\_core\\src\\common\" \"-I..\\numpy\\_core\\src\\multiarray\" \"-I..\\numpy\\_core\\src\\npymath\" \"-I..\\numpy\\_core\\src\\umath\" \"-I..\\numpy\\_core\\src\\highway\" \"-IC:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\\Include\" \"-IC:\\Users\\RDEVULAP\\source\\repos\\numpy\\build\\meson_cpu\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/Zc:__cplusplus\" \"/W2\" \"/EHsc\" \"/std:c++17\" \"/permissive-\" \"/O2\" \"/Zi\" \"-DMS_WIN64=\" \"-DNPY_INTERNAL_BUILD\" \"-DHAVE_NPY_CONFIG_H\" \"-D_FILE_OFFSET_BITS=64\" \"-D_LARGEFILE_SOURCE=1\" \"-D_LARGEFILE64_SOURCE=1\" \"/O2\" \"-DNPY_HAVE_SSE2\" \"-DNPY_HAVE_SSE\" \"-DNPY_HAVE_SSE3\" \"-DNPY_HAVE_SSSE3\" \"-DNPY_HAVE_SSE41\" \"-DNPY_HAVE_POPCNT\" \"-DNPY_HAVE_SSE42\" \"-DNPY_HAVE_AVX\" \"-DNPY_HAVE_F16C\" \"-DNPY_HAVE_FMA3\" \"-DNPY_HAVE_AVX2\" \"/fp:contract\" \"/arch:AVX2\" \"-DNPY_MTARGETS_CURRENT=AVX2\" \"/Fdnumpy\\_core\\libloops_trigonometric.dispatch.h_AVX2.a.p\\src_umath_loops_trigonometric.dispatch.cpp.pdb\" /Fonumpy/_core/libloops_trigonometric.dispatch.h_AVX2.a.p/src_umath_loops_trigonometric.dispatch.cpp.obj \"/c\" ../numpy/_core/src/umath/loops_trigonometric.dispatch.cpp",

Copy link
Contributor Author

@abhishek-iitmadras abhishek-iitmadras Jun 3, 2025

Choose a reason for hiding this comment

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

Thanks @r-devulap for confirmation .

Co-authored-by: Charles Harris <charlesr.harris@gmail.com>
Copy link
Member

@r-devulap r-devulap left a comment

Choose a reason for hiding this comment

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

LGTM.

@charris charris merged commit ff1d6cc into numpy:main Jun 3, 2025
140 checks passed
@charris
Copy link
Member

charris commented Jun 3, 2025

Thanks @abhishek-iitmadras .

@abhishek-iitmadras abhishek-iitmadras deleted the abhishek_window branch June 3, 2025 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy