Skip to content

Commit

Permalink
fix #35499, inconsistent atomic ops on int vs. float (#35509)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Apr 18, 2020
1 parent e00db7b commit 48cd02a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/atomics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ for op in [:+, :-, :max, :min]
new = $op(old, val)
cmp = old
old = atomic_cas!(var, cmp, new)
reinterpret(IT, old) == reinterpret(IT, cmp) && return new
reinterpret(IT, old) == reinterpret(IT, cmp) && return old
# Temporary solution before we have gc transition support in codegen.
ccall(:jl_gc_safepoint, Cvoid, ())
end
Expand Down
6 changes: 5 additions & 1 deletion test/threads_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function test_atomic_float(varadd::Atomic{T}, varmax::Atomic{T}, varmin::Atomic{
atomic_max!(varmax, T(i))
atomic_min!(varmin, T(i))
end
for T in (Int32, Int64, Float32, Float64)
for T in (Int32, Int64, Float16, Float32, Float64)
varadd = Atomic{T}()
varmax = Atomic{T}()
varmin = Atomic{T}()
Expand All @@ -422,6 +422,10 @@ for T in (Int32, Int64, Float32, Float64)
@test varadd[] === T(sum(1:nloops))
@test varmax[] === T(maximum(1:nloops))
@test varmin[] === T(0)
@test atomic_add!(Atomic{T}(1), T(2)) == 1
@test atomic_sub!(Atomic{T}(2), T(3)) == 2
@test atomic_min!(Atomic{T}(4), T(3)) == 4
@test atomic_max!(Atomic{T}(5), T(6)) == 5
end

using Dates
Expand Down

2 comments on commit 48cd02a

@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)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.