提交 c2967938 编写于 作者: S Sing_chan 提交者: GitHub

Revert "Do not reset default stream for StreamSafeCUDAAllocator (#42149)"

This reverts commit 6553a9d7.
上级 37580838
...@@ -415,23 +415,6 @@ class AllocatorFacadePrivate { ...@@ -415,23 +415,6 @@ class AllocatorFacadePrivate {
void SetDefaultStream(const platform::CUDAPlace& place, gpuStream_t stream) { void SetDefaultStream(const platform::CUDAPlace& place, gpuStream_t stream) {
const std::shared_ptr<StreamSafeCUDAAllocator>& allocator = const std::shared_ptr<StreamSafeCUDAAllocator>& allocator =
GetDefaultStreamSafeCUDAAllocator(place); GetDefaultStreamSafeCUDAAllocator(place);
// NOTE(Ruibiao): The default stream will be set when the CUDADeviceContext
// created. Normally, the DeviceContextPool is a global singleton and one
// Place only correspond to one DeviceContext. However, to support
// multi-stream scheduling, standalone executor creates two extra
// DeviceContextPools for H2D and D2H stream in StreamAnalyzer, which make
// one Place correspond to multiple DeviceContext and unexpectedly reset the
// default stream in runtime. To avoid this behavior, we do not allow
// changing default stream after initially setting.
if (allocator->GetDefaultStream() != nullptr) {
VLOG(5) << "The default stream for StreamSafeCUDAAllocator("
<< allocator.get() << ") in " << place << " has been set to "
<< allocator->GetDefaultStream()
<< " before, not allow to change now.";
return;
}
allocator->SetDefaultStream(stream); allocator->SetDefaultStream(stream);
VLOG(8) << "Set default stream to " << stream VLOG(8) << "Set default stream to " << stream
<< " for StreamSafeCUDAAllocator(" << allocator.get() << ") in " << " for StreamSafeCUDAAllocator(" << allocator.get() << ") in "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册