23 #include <processthreadsapi.h>
25 #include <sys/syscall.h>
29 #include <boost/filesystem/path.hpp>
33 namespace nvtx_helpers {
39 #define NUM_CATEGORIES 4u
46 #define SET_OMNISCI_EVENT_CATEGORY 0
52 auto create_category = [](
Category c,
const char*
name, uint32_t color) {
53 auto category_index =
static_cast<uint32_t
>(c);
79 auto category_index =
static_cast<uint32_t
>(c);
82 nvtxEventAttributes_t event_attrib = {};
83 event_attrib.version = NVTX_VERSION;
84 event_attrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
85 event_attrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
86 event_attrib.message.ascii =
name;
87 if (info.color != 0) {
88 event_attrib.colorType = NVTX_COLOR_ARGB;
89 event_attrib.color = info.color;
91 #if SET_OMNISCI_EVENT_CATEGORY
92 event_attrib.category = info.category;
99 return boost::filesystem::path(path).filename().string();
106 std::stringstream ss;
149 uint32_t
thread_id = GetCurrentThreadId();
152 uint32_t thread_id =
static_cast<uint32_t
>(syscall(SYS_gettid));
154 #error "SYS_gettid unavailable on this system"
157 nvtxNameOsThreadA(thread_id, name);
const nvtxDomainHandle_t get_omnisci_domain()
void omnisci_range_end(nvtxRangeId_t r)
void omnisci_range_push(Category c, const char *name, const char *file)
static std::array< CategoryInfo, NUM_CATEGORIES > g_category_infos
static nvtxDomainHandle_t g_omnisci_domain
void name_current_thread(const char *name)
void omnisci_set_mark(Category c, const char *name)
std::string filename(char const *path)
nvtxEventAttributes_t make_omnisci_event(Category c, const char *name)
nvtxRangeId_t omnisci_range_start(Category c, const char *name)
void * nvtxDomainHandle_t