Skip to content

Commit 2098b42

Browse files
committed
review fixes (Teamcity fails)
test=develop
1 parent 741cb33 commit 2098b42

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

paddle/fluid/inference/tests/api/tester_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ void TestMultiThreadPrediction(
139139
}
140140
for (int tid = 0; tid < num_threads; ++tid) {
141141
threads.emplace_back([&, tid]() {
142+
#ifdef PADDLE_WITH_MKLDNN
142143
platform::set_cur_thread_id(static_cast<int>(tid) + 1);
144+
#endif
143145
// Each thread should have local inputs and outputs.
144146
// The inputs of each thread are all the same.
145147
std::vector<std::vector<PaddleTensor>> inputs_tid = inputs;

paddle/fluid/platform/device_context.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ namespace platform {
2525

2626
DeviceContextPool* DeviceContextPool::pool = nullptr;
2727

28-
namespace {
29-
// Current thread's id.
30-
thread_local int cur_thread_id = 0;
31-
}
32-
33-
void set_cur_thread_id(int tid) { cur_thread_id = tid; }
34-
int get_cur_thread_id(void) { return cur_thread_id; }
35-
3628
platform::DeviceContext* DeviceContextPool::Get(const platform::Place& place) {
3729
auto it = device_contexts_.find(place);
3830
if (it == device_contexts_.end()) {
@@ -309,6 +301,14 @@ MKLDNNDeviceContext::MKLDNNDeviceContext(CPUPlace place)
309301
p_mutex_.reset(new std::mutex());
310302
}
311303

304+
namespace {
305+
// Current thread's id.
306+
thread_local int cur_thread_id = 0;
307+
}
308+
309+
void set_cur_thread_id(int tid) { cur_thread_id = tid; }
310+
int get_cur_thread_id(void) { return cur_thread_id; }
311+
312312
void MKLDNNDeviceContext::SetBlob(const std::string& name,
313313
std::shared_ptr<void> data) const {
314314
BlobMap* pMap = p_blobmap_.get();

paddle/fluid/platform/device_context.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ limitations under the License. */
3939
namespace paddle {
4040
namespace platform {
4141

42-
using KeyBlob = std::unordered_map<std::string, std::shared_ptr<void>>;
43-
using BlobMap = std::unordered_map<int, std::shared_ptr<KeyBlob>>;
44-
45-
void set_cur_thread_id(int);
46-
int get_cur_thread_id(void);
47-
4842
class DeviceContext {
4943
public:
5044
virtual ~DeviceContext() {}
@@ -182,6 +176,12 @@ struct DefaultDeviceContextType<platform::CUDAPinnedPlace> {
182176
#endif
183177

184178
#ifdef PADDLE_WITH_MKLDNN
179+
using KeyBlob = std::unordered_map<std::string, std::shared_ptr<void>>;
180+
using BlobMap = std::unordered_map<int, std::shared_ptr<KeyBlob>>;
181+
182+
void set_cur_thread_id(int);
183+
int get_cur_thread_id(void);
184+
185185
class MKLDNNDeviceContext : public CPUDeviceContext {
186186
public:
187187
explicit MKLDNNDeviceContext(CPUPlace place);

0 commit comments

Comments
 (0)