8000 DOC: expand reasoning behind npy_*floatstatus_barrer() by mattip · Pull Request #11073 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: expand reasoning behind npy_*floatstatus_barrer() #11073

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
May 11, 2018
Merged
Show file tree
Hide file tree
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. 8000
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions doc/source/reference/c-api.coremath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,19 @@ Those can be useful for precise floating point comparison.
* NPY_FPE_UNDERFLOW
* NPY_FPE_INVALID

Note that :c:func:`npy_get_floatstatus_barrier` is preferable as it prevents
agressive compiler optimizations reordering the call relative to
the code setting the status, which could lead to incorrect results.

.. versionadded:: 1.9.0

.. c:function:: int npy_get_floatstatus_barrier(char*)

Get floating point status. A pointer to a local variable is passed in to
prevent aggresive compiler optimizations from reodering this function call.
prevent aggresive compiler optimizations from reodering this function call
Copy link
Member

Choose a reason for hiding this comment

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

typo

relative to the code setting the status, which could lead to incorrect
results.

Returns a bitmask with following possible flags:

* NPY_FPE_DIVIDEBYZERO
Expand All @@ -202,9 +209,13 @@ Those can be useful for precise floating point comparison.

Clears the floating point status. Returns the previous status mask.

Note that :c:func:`npy_clear_floatstatus_barrier` is preferable as it
prevents agressive compiler optimizations reordering the call relative to
the code setting the status, which could lead to incorrect results.

.. versionadded:: 1.9.0

.. c:function:: int npy_clear_floatstatus(char*)
.. c:function:: int npy_clear_floatstatus_barrier(char*)

Clears the floating point status. A pointer to a local variable is passed in to
prevent aggresive compiler optimizations from reodering this function call.
Expand Down
5 changes: 4 additions & 1 deletion numpy/core/include/numpy/npy_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,13 @@ int npy_clear_floatstatus_barrier(char*);
int npy_get_floatstatus_barrier(char*);
/*
* use caution with these - clang and gcc8.1 are known to reorder calls
* to this form of the function which can defeat the check
* to this form of the function which can defeat the check. The _barrier
* form of the call is preferable, where the argument is
* (char*)&local_variable
*/
int npy_clear_floatstatus(void);
int npy_get_floatstatus(void);

void npy_set_floatstatus_divbyzero(void);
void npy_set_floatstatus_overflow(void);
void npy_set_floatstatus_underflow(void);
Expand Down
0