GetCachedTID() caches the thread ID in thread-local storage (which is a userspace construct) to avoid unnecessary system calls. Without this caching, it can take roughly 98ns, while it takes roughly 1ns with this caching.
| 83 | // userspace construct) to avoid unnecessary system calls. Without this caching, |
| 84 | // it can take roughly 98ns, while it takes roughly 1ns with this caching. |
| 85 | pid_t GetCachedTID() { |
| 86 | static thread_local pid_t current_thread_id = |
| 87 | Env::Default()->GetCurrentThreadId(); |
| 88 | return current_thread_id; |
| 89 | } |
| 90 | |
| 91 | size_t Bytes2D(const CUDA_MEMCPY2D *p) { return p->Height * p->WidthInBytes; } |
| 92 |
no test coverage detected