最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

assembly - How to obtain raw perf events for my host arch to use in libpfm4? - Stack Overflow

programmeradmin0浏览0评论

I can not find any instructions on how to compile a list of human readable event mappings that libpfm4's pfm_get_os_event_encoding() will map to the corresponding values that i can pass to rdpmc. Every time i try anything but cycles or instructions from e.g the output of perf list libpfm4 can't find it.

EDIT/SOLUTION: There is example code hidden in the docs to list available events for every PMU:

void list_pmu_events(pfm_pmu_t pmu)
{
   pfm_event_info_t info;
   pfm_pmu_info_t pinfo;
   int i, ret;

   memset(&info, 0, sizeof(info));
   memset(&pinfo, 0, sizeof(pinfo));

   info.size = sizeof(info);
   pinfo.size = sizeof(pinfo);

   ret = pfm_get_pmu_info(pmu, &pinfo);
   if (ret != PFM_SUCCESS)
    return;
      errx(1, "cannot get pmu info");

   for (i = pinfo.first_event; i != -1; i = pfm_get_event_next(i)) {
      ret = pfm_get_event_info(i, PFM_OS_PERF_EVENT_EXT, &info);
      if (ret != PFM_SUCCESS)
        errx(1, "cannot get event info");

        if (pfm_find_event(info.name) && pinfo.is_present) {
            printf("Event: %s::%s\n",
                    pinfo.name, info.name);
        }
  }
}
发布评论

评论列表(0)

  1. 暂无评论