GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #19479 from seberg/fixup-clang-flag-try · numpy/numpy@6388471

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/release/upcoming_changes
    • 19479.compatibility.rst
  • numpy
    • core/src/umath
      • loops_exponent_log.dispatch.c.src
    • distutils
      • ccompiler.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/release/upcoming_changes/19479.compatibility.rst‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Distutils forces strict floating point model on clang
2+
-----------------------------------------------------
3+
NumPy now sets the ``-ftrapping-math`` option on clang to enforce correct
4+
floating point error handling for universal functions.
5+
Clang defaults to non-IEEE and C99 conform behaviour otherwise.
6+
This change (using the equivalent but newer ``-ffp-exception-behavior=strict``)
7+
was attempted in NumPy 1.21, but was effectively never used.
Collapse file

‎numpy/core/src/umath/loops_exponent_log.dispatch.c.src‎

Copy file name to clipboardExpand all lines: numpy/core/src/umath/loops_exponent_log.dispatch.c.src
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ fma_get_exponent(__m256 x)
149149
__m256 normal_mask = _mm256_cmp_ps(x, _mm256_set1_ps(FLT_MIN), _CMP_GE_OQ);
150150

151151
/*
152-
* It is necessary for temp1 to be volatile, a bug in clang optimizes it out which leads
153-
* to an overflow warning in some cases. See https://github.com/numpy/numpy/issues/18005
152+
* The volatile is probably unnecessary now since we compile clang with
153+
* `-ftrapping-math`: https://github.com/numpy/numpy/issues/18005
154154
*/
155155
volatile __m256 temp1 = _mm256_blendv_ps(x, _mm256_set1_ps(0.0f), normal_mask);
156156
__m256 temp = _mm256_mul_ps(temp1, two_power_100);
@@ -180,8 +180,8 @@ fma_get_mantissa(__m256 x)
180180
__m256 normal_mask = _mm256_cmp_ps(x, _mm256_set1_ps(FLT_MIN), _CMP_GE_OQ);
181181

182182
/*
183-
* It is necessary for temp1 to be volatile, a bug in clang optimizes it out which leads
184-
* to an overflow warning in some cases. See https://github.com/numpy/numpy/issues/18005
183+
* The volatile is probably unnecessary now since we compile clang with
184+
* `-ftrapping-math`: https://github.com/numpy/numpy/issues/18005
185185
*/
186186
volatile __m256 temp1 = _mm256_blendv_ps(x, _mm256_set1_ps(0.0f), normal_mask);
187187
__m256 temp = _mm256_mul_ps(temp1, two_power_100);
Collapse file

‎numpy/distutils/ccompiler.py‎

Copy file name to clipboardExpand all lines: numpy/distutils/ccompiler.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ def CCompiler_customize_cmd(self, cmd, ignore=()):
388388
if hasattr(self, 'compiler') and 'clang' in self.compiler[0]:
389389
# clang defaults to a non-strict floating error point model.
390390
# Since NumPy and most Python libs give warnings for these, override:
391-
self.compiler.append('-ffp-exception-behavior=strict')
391+
self.compiler.append('-ftrapping-math')
392+
self.compiler_so.append('-ftrapping-math')
392393

393394
def allow(attr):
394395
return getattr(cmd, attr, None) is not None and attr not in ignore

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.