Caffe2 - C++ API
A deep learning, cross platform ML framework
thread_name.cpp
1 #include "c10/util/thread_name.h"
2 
3 #include <algorithm>
4 
5 #if defined(__GLIBC__) && !defined(__APPLE__) && !defined(__ANDROID__)
6 #define C10_HAS_PTHREAD_SETNAME_NP
7 #endif
8 
9 #ifdef C10_HAS_PTHREAD_SETNAME_NP
10 #include <pthread.h>
11 #endif
12 
13 namespace c10 {
14 
15 void setThreadName(std::string name) {
16 #ifdef C10_HAS_PTHREAD_SETNAME_NP
17  constexpr size_t kMaxThreadName = 15;
18  name.resize(std::min(name.size(), kMaxThreadName));
19 
20  pthread_setname_np(pthread_self(), name.c_str());
21 #endif
22 }
23 
24 } // namespace c10
To register your own kernel for an operator, do in one (!) cpp file: C10_REGISTER_KERNEL(OperatorHand...
Definition: alias_info.h:7