We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4581524 + a1254a8 commit 3fd3e50Copy full SHA for 3fd3e50
paddle/fluid/platform/device_context.h
@@ -11,6 +11,7 @@ limitations under the License. */
11
#pragma once
12
13
#include <memory>
14
+#include <mutex> // NOLINT
15
#include <string>
16
#include <unordered_map>
17
#include <vector>
@@ -100,6 +101,7 @@ class CUDADeviceContext : public DeviceContext {
100
101
102
template <typename Callback>
103
void RecordEvent(cudaEvent_t ev, Callback callback) {
104
+ std::lock_guard<std::mutex> guard(mtx_);
105
callback();
106
PADDLE_ENFORCE(cudaEventRecord(ev, stream_));
107
}
@@ -116,6 +118,8 @@ class CUDADeviceContext : public DeviceContext {
116
118
int compute_capability;
117
119
int multi_process;
120
int max_threads_per_mp;
121
+
122
+ std::mutex mtx_;
123
};
124
125
template <>
0 commit comments