Skip to content

Commit 67cdc55

Browse files
authored
add thread-safety warnings to global rounding and precision docs (#32426)
closes #27139
1 parent d2e7d05 commit 67cdc55

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

base/mpfr.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,12 @@ precision(::Type{BigFloat}) = Int(DEFAULT_PRECISION[]) # precision of the type B
816816
setprecision([T=BigFloat,] precision::Int)
817817
818818
Set the precision (in bits) to be used for `T` arithmetic.
819+
820+
!!! warning
821+
822+
This function is not thread-safe. It will affect code running on all threads, but
823+
its behavior is undefined if called concurrently with computations that use the
824+
setting.
819825
"""
820826
function setprecision(::Type{BigFloat}, precision::Integer)
821827
if precision < 2

base/rounding.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ functions may give incorrect or invalid values when using rounding modes other t
131131
default [`RoundNearest`](@ref).
132132
133133
Note that this is currently only supported for `T == BigFloat`.
134+
135+
!!! warning
136+
137+
This function is not thread-safe. It will affect code running on all threads, but
138+
its behavior is undefined if called concurrently with computations that use the
139+
setting.
134140
"""
135141
setrounding(T::Type, mode)
136142

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

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

0 commit comments

Comments
 (0)