Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lock to record_event. #11346

Merged

Conversation

reyoung
Copy link
Collaborator

@reyoung reyoung commented Jun 11, 2018

It seems that transformer will still be hang without this lock.

@reyoung reyoung requested a review from chengduoZH June 11, 2018 04:47
@@ -100,6 +101,7 @@ class CUDADeviceContext : public DeviceContext {

template <typename Callback>
void RecordEvent(cudaEvent_t ev, Callback callback) {
std::lock_guard<std::mutex> guard(mtx_);
callback();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about replacing std::mutex with std::recursive_mutex? Because, if the callback() contains another RecordEvent() calling, it will be hang again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This situation should not happen.

Copy link
Contributor

@chengduoZH chengduoZH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent

@reyoung reyoung merged commit 3fd3e50 into PaddlePaddle:develop Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants