Skip to content

Commit 628e7f2

Browse files
committed
Update
[ghstack-poisoned]
2 parents 1c88da1 + 47929dc commit 628e7f2

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

aten/src/ATen/core/CachingHostAllocator.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ struct CachingHostAllocatorImpl {
251251
auto* block = reinterpret_cast<B*>(ctx);
252252

253253
std::optional<std::vector<E>> events;
254-
ska::flat_hash_set<S> streams;
255254
{
256255
std::lock_guard<std::mutex> g(block->mutex_);
257256
block->allocated_ = false;
@@ -260,19 +259,14 @@ struct CachingHostAllocatorImpl {
260259
} else {
261260
events = std::vector<E>();
262261
events->reserve(block->streams_.size());
263-
block->event_count_ += block->streams_.size();
264-
// Move out streams to avoid holding the mutex during event recording
265-
streams = std::move(block->streams_);
262+
for (auto stream : block->streams_) {
263+
record_stream(events, stream);
264+
}
265+
block->event_count_ += events->size();
266266
block->streams_.clear();
267267
}
268268
}
269269

270-
// Event recording must be done outside the mutex to avoid potential
271-
// deadlocks (e.g., when Python GIL is involved)
272-
for (auto stream : streams) {
273-
record_stream(events, stream);
274-
}
275-
276270
if (!events) {
277271
auto index = size_index(block->size_);
278272
std::lock_guard<std::mutex> g(free_list_[index].mutex_);

0 commit comments

Comments
 (0)