Skip to content

Commit

Permalink
fix(compiler): [GPU runtime] prevent early deallocation of on-device …
Browse files Browse the repository at this point in the history
…data when multiple processes use the same input.
  • Loading branch information
antoniupop committed Jul 23, 2024
1 parent cf32638 commit 2d5d15f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compilers/concrete-compiler/compiler/lib/Runtime/GPUDFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ struct Stream {
bool ct_stream;
bool pt_stream;
size_t generation;
std::atomic<size_t> uses = {0};
const char *name;
Stream(stream_type t, const char *sname = nullptr)
: dep(nullptr), type(t), producer(nullptr), dfg(nullptr),
Expand Down Expand Up @@ -527,6 +528,7 @@ struct Stream {
dep = d;
}
dep->stream_generation = generation;
uses = 0;
}
// For a given dependence, traverse the DFG backwards to extract the lattice
// of kernels required to execute to produce this data
Expand Down Expand Up @@ -835,7 +837,8 @@ struct Stream {
}
}
for (auto i : inputs)
i->dep->free_chunk_device_data(c, dfg);
if (++i->uses == i->consumers.size())
i->dep->free_chunk_device_data(c, dfg);
for (auto iv : intermediate_values)
iv->dep->free_chunk_device_data(c, dfg);
for (auto o : outputs)
Expand Down

0 comments on commit 2d5d15f

Please sign in to comment.