void operator() (const char * event, T func, long int bytes_read = 0, long int ops = 0, long int bytes_written = 0) { #ifdef CYCLE_PROFILING if (currentevent==maxevents) { func(); } else { const auto countfd = thread_counter_fds.get_counter_fd(); start_counter(countfd); func(); long long cycs = stop_counter(countfd); // Store the profiling data std::lock_guard<std::mutex> lock_events(event_lock); events[currentevent++] = { get_event_id(event), bytes_read, ops, bytes_written, cycs }; } #else (void) event; (void) bytes_read; (void) ops; (void) bytes_written; func(); #endif // CYCLE_PROFILING }
VALUE rb_tracearg_event(rb_trace_arg_t *trace_arg) { return ID2SYM(get_event_id(trace_arg->event)); }
static void enable_sys_exit(void) { update_event("sys_exit", Enable); Sys_exit = get_event_id("sys_exit"); }
/** * @brief Reads monitoring event data from given core * * @param p pointer to monitoring structure * * @return Operation status * @retval PQOS_RETVAL_OK on success */ static int pqos_core_poll(struct pqos_mon_data *p) { struct pqos_event_values *pv = &p->values; int retval = PQOS_RETVAL_OK; unsigned i; if (p->event & PQOS_MON_EVENT_L3_OCCUP) { uint64_t total = 0; for (i = 0; i < p->num_poll_ctx; i++) { uint64_t tmp = 0; int ret; ret = mon_read(p->poll_ctx[i].lcore, p->poll_ctx[i].rmid, get_event_id(PQOS_MON_EVENT_L3_OCCUP), &tmp); if (ret != PQOS_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } total += tmp; } pv->llc = total; } if (p->event & (PQOS_MON_EVENT_LMEM_BW | PQOS_MON_EVENT_RMEM_BW)) { uint64_t total = 0, old_value = pv->mbm_local; for (i = 0; i < p->num_poll_ctx; i++) { uint64_t tmp = 0; int ret; ret = mon_read(p->poll_ctx[i].lcore, p->poll_ctx[i].rmid, get_event_id(PQOS_MON_EVENT_LMEM_BW), &tmp); if (ret != PQOS_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } total += tmp; } pv->mbm_local = total; pv->mbm_local_delta = get_delta(old_value, pv->mbm_local); } if (p->event & (PQOS_MON_EVENT_TMEM_BW | PQOS_MON_EVENT_RMEM_BW)) { uint64_t total = 0, old_value = pv->mbm_total; for (i = 0; i < p->num_poll_ctx; i++) { uint64_t tmp = 0; int ret; ret = mon_read(p->poll_ctx[i].lcore, p->poll_ctx[i].rmid, get_event_id(PQOS_MON_EVENT_TMEM_BW), &tmp); if (ret != PQOS_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } total += tmp; } pv->mbm_total = total; pv->mbm_total_delta = get_delta(old_value, pv->mbm_total); } if (p->event & PQOS_MON_EVENT_RMEM_BW) { pv->mbm_remote = 0; if (pv->mbm_total > pv->mbm_local) pv->mbm_remote = pv->mbm_total - pv->mbm_local; pv->mbm_remote_delta = 0; if (pv->mbm_total_delta > pv->mbm_local_delta) pv->mbm_remote_delta = pv->mbm_total_delta - pv->mbm_local_delta; } if (p->event & PQOS_PERF_EVENT_IPC) { /** * If multiple cores monitored in one group * then we have to accumulate the values in the group. */ uint64_t unhalted = 0, retired = 0; unsigned n; for (n = 0; n < p->num_cores; n++) { uint64_t tmp = 0; int ret = msr_read(p->cores[n], IA32_MSR_INST_RETIRED_ANY, &tmp); if (ret != MACHINE_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } retired += tmp; ret = msr_read(p->cores[n], IA32_MSR_CPU_UNHALTED_THREAD, &tmp); if (ret != MACHINE_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } unhalted += tmp; } pv->ipc_unhalted_delta = unhalted - pv->ipc_unhalted; pv->ipc_retired_delta = retired - pv->ipc_retired; pv->ipc_unhalted = unhalted; pv->ipc_retired = retired; if (pv->ipc_unhalted_delta == 0) pv->ipc = 0.0; else pv->ipc = (double) pv->ipc_retired_delta / (double) pv->ipc_unhalted_delta; } if (p->event & PQOS_PERF_EVENT_LLC_MISS) { /** * If multiple cores monitored in one group * then we have to accumulate the values in the group. */ uint64_t missed = 0; unsigned n; for (n = 0; n < p->num_cores; n++) { uint64_t tmp = 0; int ret = msr_read(p->cores[n], IA32_MSR_PMC0, &tmp); if (ret != MACHINE_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } missed += tmp; } pv->llc_misses_delta = missed - pv->llc_misses; pv->llc_misses = missed; } pqos_core_poll__exit: return retval; }
static void enable_sys_enter(void) { update_event("sys_enter", Enable); Sys_enter = get_event_id("sys_enter"); }