-
Notifications
You must be signed in to change notification settings - Fork 3
Fix: atomic ordering #46
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46 +/- ##
==========================================
+ Coverage 97.48% 97.75% +0.27%
==========================================
Files 11 11
Lines 635 624 -11
==========================================
- Hits 619 610 -9
+ Misses 16 14 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@vtjnash I'd like to get this correct but I have troubles mapping the concepts of Is this the correct use to form an acquire-release pair? module Example
mutable struct Ex{T}
@atomic val::T
Ex{T}() where T = new{T}()
end
function val(e::Ex{T}) where T
if !isdefined(e, :val, :acquire)
val = compute_val(T)
# throws ConcurrencyViolationError("invalid atomic ordering")
# @atomiconce :release e.val = val
@atomiconce :release :acquire e.val = val
end
return e.val
end
compute_val(::Type{<:Integer}) = 42
end
e = Example.Ex{BigInt}()
Example.val(e)In particular in code for e.g. function Base.copy(p::Perm)
imgs = copy(p.images)
q = typeof(p)(imgs; check = false)
if isdefined(p, :inv, :acquire)
inv_imgs = copy(p.inv.images)
q⁻¹ = typeof(p)(inv_imgs; check = false)
@atomic q⁻¹.inv = q
@atomiconce :release :acquire q.inv = q⁻¹
end
return q
endWhere I want to make sure that the What should be the ordering for Any clarifications would be much appreciated! |
|
The release creates a happens-before, such that all prior writes will have happened if any other thread acquires that new value by reading (no write can finish after the release, no read can start before the acquire, even on other memory) |
0baf655 to
83bd0a1
Compare
|
I hope I'm not being obnoxious, but it would great for me of this could get merged; I want to add PermutationGroups as a dependency of my package Ket, but I won't do if it means dropping support for 1.12 I looks like the problem is only on 1.10, perhaps support for that could be dropped? I'm afraid I can't be of technical help, as I don't understand any of this multi-threading stuff. |
|
@araujoms This fails on lts since there's no If you want to move this forward PRs are welcome! |
|
Why not just add a switch to use the current code for 1.10 and |
|
Can you write the switch you have in mind in code? Note that macros are evaluated before any code is evaluated, all at parse time. |
use @atomiconce only for 1.11+
|
Now I managed to understand why CI is happy on 1.12 but on my machine the tests fail: the failing test is the Schreier-Sims benchmark, which you've disabled running in CI with |
|
@oscardssmith @vtjnash I hope I'm not abusing your goodwill, but perhaps would you know what is going wrong? After the fixes the code works fine on 1.11, but still crashes on 1.12 and 1.13. |
|
GC error (probable corruption) from CI in this case seems like probably a Julia bug. We'd noticed some issues in the past where |
|
The crashes have been fixed by JuliaLang/julia#59991, but now there's a test failure: the test |
|
since the crash happens on nightly only and also was observed in #49 I think it's unrelated; It will need to be investigated though, something I have very little time for right now... |
thanks for the remark @vtjnash
#45 (comment)