未验证 提交 34d7d6ae 编写于 作者: 石晓伟 提交者: GitHub

declare the stream::Priority as enum class, test=develop (#24013)

上级 96491e43
...@@ -234,7 +234,7 @@ void CUDAContext::InitEigenContext() { ...@@ -234,7 +234,7 @@ void CUDAContext::InitEigenContext() {
} }
CUDAContext::CUDAContext(const CUDAPlace& place, CUDAContext::CUDAContext(const CUDAPlace& place,
const enum stream::Priority& priority) { const stream::Priority& priority) {
place_ = place; place_ = place;
CUDADeviceGuard guard(place_.device); CUDADeviceGuard guard(place_.device);
stream_.reset(new stream::CUDAStream(place, priority)); stream_.reset(new stream::CUDAStream(place, priority));
......
...@@ -85,7 +85,7 @@ class CUDAContext { ...@@ -85,7 +85,7 @@ class CUDAContext {
CUDAContext() = default; CUDAContext() = default;
explicit CUDAContext( explicit CUDAContext(
const CUDAPlace& place, const CUDAPlace& place,
const enum stream::Priority& priority = stream::Priority::kNormal); const stream::Priority& priority = stream::Priority::kNormal);
~CUDAContext(); ~CUDAContext();
...@@ -274,11 +274,11 @@ class CUDADeviceContext : public DeviceContext { ...@@ -274,11 +274,11 @@ class CUDADeviceContext : public DeviceContext {
return context()->Stream()->WaitCallback(); return context()->Stream()->WaitCallback();
} }
void ResetDefaultContext(const enum stream::Priority& priority) { void ResetDefaultContext(const stream::Priority& priority) {
default_ctx_.reset(new CUDAContext(place_, priority)); default_ctx_.reset(new CUDAContext(place_, priority));
} }
void ResetThreadContext(const enum stream::Priority& priority) { void ResetThreadContext(const stream::Priority& priority) {
std::lock_guard<std::mutex> guard(ctx_mtx_); std::lock_guard<std::mutex> guard(ctx_mtx_);
thread_ctx_[this].reset(new CUDAContext(place_, priority)); thread_ctx_[this].reset(new CUDAContext(place_, priority));
} }
......
...@@ -22,7 +22,7 @@ namespace stream { ...@@ -22,7 +22,7 @@ namespace stream {
constexpr unsigned int kDefaultFlag = cudaStreamDefault; constexpr unsigned int kDefaultFlag = cudaStreamDefault;
bool CUDAStream::Init(const Place& place, const enum Priority& priority) { bool CUDAStream::Init(const Place& place, const Priority& priority) {
PADDLE_ENFORCE_EQ(is_gpu_place(place), true, PADDLE_ENFORCE_EQ(is_gpu_place(place), true,
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"Cuda stream must be created using cuda place.")); "Cuda stream must be created using cuda place."));
......
...@@ -36,14 +36,13 @@ enum class Priority : uint8_t { ...@@ -36,14 +36,13 @@ enum class Priority : uint8_t {
class CUDAStream final { class CUDAStream final {
public: public:
CUDAStream() = default; CUDAStream() = default;
CUDAStream(const Place& place, explicit CUDAStream(const Place& place,
const enum Priority& priority = Priority::kNormal) { const Priority& priority = Priority::kNormal) {
Init(place, priority); Init(place, priority);
} }
virtual ~CUDAStream() { Destroy(); } virtual ~CUDAStream() { Destroy(); }
bool Init(const Place& place, bool Init(const Place& place, const Priority& priority = Priority::kNormal);
const enum Priority& priority = Priority::kNormal);
template <typename Callback> template <typename Callback>
void AddCallback(Callback&& callback) const { void AddCallback(Callback&& callback) const {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册