提交 d3e55fde 编写于 作者: Y Yu Yang

Guard devctx

上级 a5ba704d
...@@ -159,6 +159,7 @@ CUDADeviceContext::~CUDADeviceContext() { ...@@ -159,6 +159,7 @@ CUDADeviceContext::~CUDADeviceContext() {
Place CUDADeviceContext::GetPlace() const { return place_; } Place CUDADeviceContext::GetPlace() const { return place_; }
void CUDADeviceContext::Wait() const { void CUDADeviceContext::Wait() const {
std::lock_guard<std::mutex> guard(this->mutex_);
PADDLE_ENFORCE(cudaStreamSynchronize(stream_)); PADDLE_ENFORCE(cudaStreamSynchronize(stream_));
PADDLE_ENFORCE(cudaGetLastError()); PADDLE_ENFORCE(cudaGetLastError());
} }
......
...@@ -110,6 +110,7 @@ class CUDADeviceContext : public DeviceContext { ...@@ -110,6 +110,7 @@ class CUDADeviceContext : public DeviceContext {
int compute_capability; int compute_capability;
int multi_process; int multi_process;
int max_threads_per_mp; int max_threads_per_mp;
mutable std::mutex mutex_;
}; };
template <> template <>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册