Skip to content

Commit

Permalink
add thread-safety warnings to global rounding and precision docs (#32426
Browse files Browse the repository at this point in the history
)

closes #27139
  • Loading branch information
JeffBezanson authored Jun 27, 2019
1 parent d2e7d05 commit 67cdc55
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions base/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,12 @@ precision(::Type{BigFloat}) = Int(DEFAULT_PRECISION[]) # precision of the type B
setprecision([T=BigFloat,] precision::Int)
Set the precision (in bits) to be used for `T` arithmetic.
!!! warning
This function is not thread-safe. It will affect code running on all threads, but
its behavior is undefined if called concurrently with computations that use the
setting.
"""
function setprecision(::Type{BigFloat}, precision::Integer)
if precision < 2
Expand Down
14 changes: 14 additions & 0 deletions base/rounding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ functions may give incorrect or invalid values when using rounding modes other t
default [`RoundNearest`](@ref).
Note that this is currently only supported for `T == BigFloat`.
!!! warning
This function is not thread-safe. It will affect code running on all threads, but
its behavior is undefined if called concurrently with computations that use the
setting.
"""
setrounding(T::Type, mode)

Expand Down Expand Up @@ -221,6 +227,10 @@ not required) to convert subnormal inputs or outputs to zero. Returns `true` unl
`set_zero_subnormals(true)` can speed up some computations on some hardware. However, it can
break identities such as `(x-y==0) == (x==y)`.
!!! warning
This function only affects the current thread.
"""
set_zero_subnormals(yes::Bool) = ccall(:jl_set_zero_subnormals,Int32,(Int8,),yes)==0

Expand All @@ -229,6 +239,10 @@ set_zero_subnormals(yes::Bool) = ccall(:jl_set_zero_subnormals,Int32,(Int8,),yes
Return `false` if operations on subnormal floating-point values ("denormals") obey rules
for IEEE arithmetic, and `true` if they might be converted to zeros.
!!! warning
This function only affects the current thread.
"""
get_zero_subnormals() = ccall(:jl_get_zero_subnormals,Int32,())!=0

Expand Down

1 comment on commit 67cdc55

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

Please sign in to comment.