Skip to content

Commit 3d95e13

Browse files
committed
Check event_count before merging blocks
1 parent 228e1a8 commit 3d95e13

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

THCCachingAllocator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ struct THCCachingAllocator
276276
/** combine previously split blocks */
277277
void try_merge_blocks(Block* dst, Block* src, FreeBlocks& free_blocks)
278278
{
279-
if (!src || src->allocated) {
279+
if (!src || src->allocated || src->event_count > 0) {
280280
return;
281281
}
282282
if (dst->prev == src) {
@@ -386,6 +386,7 @@ struct THCCachingAllocator
386386
if (err != cudaSuccess) return err;
387387

388388
std::set<THCStreamPtr> streams(std::move(block->stream_uses));
389+
THAssert(block->stream_uses.empty());
389390
for (auto it = streams.begin(); it != streams.end(); ++it) {
390391
auto& stream = *it;
391392

0 commit comments

Comments
 (0)