From 34d7d6aef09aa368508814b5095b3bf2d9d47c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E6=99=93=E4=BC=9F?= <39303645+Shixiaowei02@users.noreply.github.com> Date: Thu, 23 Apr 2020 17:02:54 +0800 Subject: [PATCH] declare the stream::Priority as enum class, test=develop (#24013) --- paddle/fluid/platform/device_context.cc | 2 +- paddle/fluid/platform/device_context.h | 6 +++--- paddle/fluid/platform/stream/cuda_stream.cc | 2 +- paddle/fluid/platform/stream/cuda_stream.h | 7 +++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/paddle/fluid/platform/device_context.cc b/paddle/fluid/platform/device_context.cc index a94714ef82..46013f5767 100644 --- a/paddle/fluid/platform/device_context.cc +++ b/paddle/fluid/platform/device_context.cc @@ -234,7 +234,7 @@ void CUDAContext::InitEigenContext() { } CUDAContext::CUDAContext(const CUDAPlace& place, - const enum stream::Priority& priority) { + const stream::Priority& priority) { place_ = place; CUDADeviceGuard guard(place_.device); stream_.reset(new stream::CUDAStream(place, priority)); diff --git a/paddle/fluid/platform/device_context.h b/paddle/fluid/platform/device_context.h index 529992b47e..7615a0b7ea 100644 --- a/paddle/fluid/platform/device_context.h +++ b/paddle/fluid/platform/device_context.h @@ -85,7 +85,7 @@ class CUDAContext { CUDAContext() = default; explicit CUDAContext( const CUDAPlace& place, - const enum stream::Priority& priority = stream::Priority::kNormal); + const stream::Priority& priority = stream::Priority::kNormal); ~CUDAContext(); @@ -274,11 +274,11 @@ class CUDADeviceContext : public DeviceContext { return context()->Stream()->WaitCallback(); } - void ResetDefaultContext(const enum stream::Priority& priority) { + void ResetDefaultContext(const stream::Priority& priority) { default_ctx_.reset(new CUDAContext(place_, priority)); } - void ResetThreadContext(const enum stream::Priority& priority) { + void ResetThreadContext(const stream::Priority& priority) { std::lock_guard guard(ctx_mtx_); thread_ctx_[this].reset(new CUDAContext(place_, priority)); } diff --git a/paddle/fluid/platform/stream/cuda_stream.cc b/paddle/fluid/platform/stream/cuda_stream.cc index 7a090ff7e5..6d3b065037 100644 --- a/paddle/fluid/platform/stream/cuda_stream.cc +++ b/paddle/fluid/platform/stream/cuda_stream.cc @@ -22,7 +22,7 @@ namespace stream { 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, platform::errors::InvalidArgument( "Cuda stream must be created using cuda place.")); diff --git a/paddle/fluid/platform/stream/cuda_stream.h b/paddle/fluid/platform/stream/cuda_stream.h index 57e763d527..4272d5fd0b 100644 --- a/paddle/fluid/platform/stream/cuda_stream.h +++ b/paddle/fluid/platform/stream/cuda_stream.h @@ -36,14 +36,13 @@ enum class Priority : uint8_t { class CUDAStream final { public: CUDAStream() = default; - CUDAStream(const Place& place, - const enum Priority& priority = Priority::kNormal) { + explicit CUDAStream(const Place& place, + const Priority& priority = Priority::kNormal) { Init(place, priority); } virtual ~CUDAStream() { Destroy(); } - bool Init(const Place& place, - const enum Priority& priority = Priority::kNormal); + bool Init(const Place& place, const Priority& priority = Priority::kNormal); template void AddCallback(Callback&& callback) const { -- GitLab