File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -96,8 +96,8 @@ struct CacheKey {
96
96
template <bool write>
97
97
CacheKey& EndUse () {
98
98
::cuda::std::atomic_ref ref (reference_count_);
99
- // The EndUse operation needs to synchronize with InUse and BeingWritten
100
- // operations. So we have an release-acquire ordering here .
99
+ // The EndUse operation needs to synchronize with the InUse operation. So we
100
+ // have an release-acquire ordering between the two .
101
101
// https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering
102
102
if constexpr (write ) {
103
103
ref.fetch_add (1 , ::cuda::std::memory_order_release);
@@ -116,9 +116,10 @@ struct CacheKey {
116
116
117
117
bool BeingWritten () const {
118
118
::cuda::std::atomic_ref ref (reference_count_);
119
- // The operations after a call to this function need to happen after the
120
- // load operation. Hence the acquire order.
121
- return ref.load (::cuda::std::memory_order_acquire) < 0 ;
119
+ // The only operation coming after this op is the StartRead operation. Since
120
+ // StartRead is a refcount increment operation, it is fine if we don't
121
+ // synchronize with EndUse ops.
122
+ return ref.load (::cuda::std::memory_order_relaxed) < 0 ;
122
123
}
123
124
124
125
friend std::ostream& operator <<(std::ostream& os, const CacheKey& key_ref) {
You can’t perform that action at this time.
0 commit comments