为什么我需要运行一个应用程序作为Papi库工作的根源

Why do I need to run an application as a root for the PAPI library to work?

本文关键字:Papi 工作 应用程序 一个 运行 为什么      更新时间:2023-10-16

我刚刚升级到ubuntu 16.04 lts。在我的C 应用程序中,我使用Papi库,因此我从http://icl.utk.edu/papi/安装了它。但是,由于某种原因,我不必在一开始就不必键入sudo了。

甚至只是在终端上键入papi_avail以查看哪些计数器可用,我得到了:

================================================================================
  PAPI Preset Events
================================================================================
    Name        Code    Avail Deriv Description (Note)
PAPI_L1_DCM  0x80000000  No    No   Level 1 data cache misses
PAPI_L1_ICM  0x80000001  No    No   Level 1 instruction cache misses
PAPI_L2_DCM  0x80000002  No    No   Level 2 data cache misses
PAPI_L2_ICM  0x80000003  No    No   Level 2 instruction cache misses
..........
    Of 108 possible events, 0 are available, of which 0 are derived.
avail.c                                     PASSED

如果我运行sudo papi_avail,我会得到:

--------------------------------------------------------------------------------
Of 108 possible events, 50 are available, of which 17 are derived.
avail.c                                     PASSED

Ubuntu 16.04中发生了什么?

它与此处的答案有关。从理论上讲,执行sudo sysctl -w kernel.perf_event_paranoid=0应该足够。