Skip to content

Commit

Permalink
declare the stream::Priority as enum class, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Shixiaowei02 committed Apr 22, 2020
1 parent 8cf6932 commit 2b0e12b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion paddle/fluid/platform/device_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,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));
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/platform/device_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -281,11 +281,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<std::mutex> guard(ctx_mtx_);
thread_ctx_[this].reset(new CUDAContext(place_, priority));
}
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/stream/cuda_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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."));
Expand Down
7 changes: 3 additions & 4 deletions paddle/fluid/platform/stream/cuda_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename Callback>
void AddCallback(Callback&& callback) const {
Expand Down

0 comments on commit 2b0e12b

Please sign in to comment.