Skip to content

gpuvis_trace_utils: Prefer C++11 thread_local vs. __thread #22

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

Merged
merged 1 commit into from
Apr 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sample/gpuvis_trace_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@

#ifdef __cplusplus
#define GPUVIS_EXTERN extern "C"
#if __cplusplus>=201103L
#define THREAD_LOCAL thread_local
#else
#define THREAD_LOCAL __thread
#endif
#else
#define GPUVIS_EXTERN extern
#endif
Expand Down Expand Up @@ -351,7 +356,7 @@ static void flush_hot_func_calls()

GPUVIS_EXTERN void gpuvis_count_hot_func_calls_internal_( const char *func )
{
static __thread pid_t s_tid = gpuvis_gettid();
static THREAD_LOCAL pid_t s_tid = gpuvis_gettid();

uint64_t t0 = gpuvis_gettime_u64();
auto &x = g_hotfuncs[ s_tid ];
Expand Down