- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当今的大多数处理器都配备了硬件性能计数器。此类计数器可用于对微架构事件进行计数,以便分析目标程序以提高其性能。通常,分析和分析是这些计数器的主要目标。
根据文献中的研究论文,这些计数器缺乏准确性。例如,如果我们想计算给定代码中退役指令的数量,该值可能会从运行更改为另一个扰动问题。已经讨论了几个指南来提高测量的准确性。监视多个事件可以更好地了解正在执行的程序,从而提高测量的准确性。
User-defined events for hardware performance monitoring 的作者已经提出了一种新方法,使用户能够定义自己的事件以供 PAPI (Performance API) 使用,这是一种广泛用于以简单方式访问硬件性能计数器的基础设施。不幸的是,这篇论文没有详细解释我们如何定义用户定义的事件并在我们的程序中使用它们。
例如(基于 PAPI),我试图定义一个涉及 n 个原生/预设事件的新事件,例如(PAPI_TOT_INS、PAPI_BR_TKN 和 PAPI_STR_INS),然后将其用作单个事件我的代码。
编辑:
根据上述论文,我设置了环境变量PAPI USER_EVENTS FILE来指示包含用户定义事件的文件,该文件将通过调用PAPI_library_init函数来初始化和解析。event_file 非常简单(仅用于测试):
#define a 5
tot_ins, PAPI_TOT_CYC|a|*
我的代码是这样的:
#include <stdio.h>
#include <stdlib.h>
#include <papi.h>
int main(int argc, char** argv) {
long_long val[10000];
int EventSet = PAPI_NULL;
long_long values[1];
PAPI_library_init(PAPI_VER_CURRENT);
PAPI_create_eventset(&EventSet);
//tot_ins is the name of the event defined in event-file
int counter_code;
PAPI_event_name_to_code("tot_ins",& counter_code);
printf("code =%x\n",counter_code);
PAPI_add_event(EventSet,counter_code);
int k;
int index=0;
for (k=0; k<5; k++)
{
PAPI_start(EventSet);
int i;
for (i=0; i<100; i++)
{
int x;
int y;
int z;
x=i+2;
y=x+i/15;
z=x/y;
}
PAPI_read(EventSet, values) ;
//printf("test number %d %lld \n",k,values[0]);
printf("%lld\n",values[0]);
PAPI_stop(EventSet, values) ;
printf("\n---------------------------------- \n");
}// end k
}
但是,counting 和 counter_code 的输出似乎都很奇怪
我在一个文本文件中定义了一个简单的事件(在 Linux Ubuntu 操作系统中)并设置了环境变量来指示这个文件。但是在代码中,两者都是
PAPI_event_name_to_code("tot_ins",& counter_code); //(retvalue=-7)
和
PAPI_add_event(EventSet,counter_code); //(retvalue=-10)
返回一个不等于 PAPI_OK 的值。
我们将不胜感激。
最佳答案
如果有人迷路并降落在这里:
我遇到了同样的问题并尝试设置环境变量 PAPI_USER_EVENTS_FILE
但它一开始没有用。然后我发现我设置了错误的 PMU 名称以及如何获得正确的 PMU 名称。我的 IvyBridge CPU 上的最小工作示例,它为 PAPI_DP_OPS
定义了一个别名:
# ivybridge
CPU,ivb
EVENT,USER_DP_OPS,NOT_DERIVED,PAPI_DP_OPS,NOTE,'FLOPS'
错误是我使用了 pmu_name 文件的内容,而不是 PAPI 使用的 pmu 名称:
cat /sys/devices/cpu/caps/pmu_name
ivybridge
您可以使用 papi_component_avail
查询可用的 PMU 名称,如手册页 man PAPI_derived_event_files
中所述。文件 papi_events.csv
(见下文)包含预设事件和 PAPI 使用的所有 PMU 名称。手册页还描述了用户事件文件的语法。 papi_avail
将显示添加的用户事件(如果有效)。
但是,我认为它有问题:例如别名为 dp 操作显示完全不同的数字。我认为应该改进有关此功能的文档,用户定义的派生事件文件的手册页不包含如何指定文件。
PAPI_set_opt
,如引用论文中描述的替代方案,目前 (6.0.0.1) 不支持作为指定用户定义事件文件的方式,并将返回错误编号(错误字符串'null'): (来自papi_preset.c)
- There are three possible sources of input for preset event definitions. The code will first look for the environment variable "PAPI_CSV_EVENT_FILE". If found its value will be used as the pathname of where to get the preset information. If not found, the code will look for a built in table containing preset events. If the built in table was not created during the build of PAPI then the code will build a pathname of the form "PAPI_DATADIR/PAPI_EVENT_FILE". Each of these are build variables, the PAPI_DATADIR variable can be given a value during the configure of PAPI at build time, and the PAPI_EVENT_FILE variable has a hard coded value of "papi_events.csv".
- There is only one way to define user events. The code will look for an environment variable "PAPI_USER_EVENTS_FILE". If found its value will be used as the pathname of a file which contains user event definitions. The events defined in this file will be added to the ones known by PAPI when the call to PAPI_library_init is done.
- TODO:
- Look into restoring the ability to specify a user defined event file with a call to PAPI_set_opt(PAPI_USER_EVENTS_FILE).
- This needs to figure out how to pass a pmu name (could use default pmu from component 0) to this function.
- Currently code elsewhere in PAPI limits the events which preset and user events can depend on to those events which are known to component 0. This possibly could be relaxed to allow events from different components. But since all the events used by any derived event must be added to the same eventset, it will always be a requirement that all events used by a given derived event must be from the same component.
关于assembly - 如何定义一个用户定义的事件来被 PAPI 衡量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55002673/
我正在尝试学习papi api来监控各种CPU事件的性能。首先,我运行了 PAPI 官方文档提到的示例片段之一。下面是代码 #include #include #include "papi.h" #
我正在使用 PAPI 库来调整和分析我的应用程序。 我想知道 (PAPI_REF_CYC : Reference clockcycles ) 实际上是什么意思? 提前致谢, 最佳答案 一些现代 CPU
当今的大多数处理器都配备了硬件性能计数器。此类计数器可用于对微架构事件进行计数,以便分析目标程序以提高其性能。通常,分析和分析是这些计数器的主要目标。 根据文献中的研究论文,这些计数器缺乏准确性。例如
我从网站上下载了 4.4 版本,将其构建在我自己的目录中,并尝试编写一个小主程序,但它一直显示 num_counters 为零。然后我查看了 ctests 并选择了 hwinfo.c,并从中删除了一些
我正在尝试在 Arch Linux x86_64 中构建一些使用 PAPI 5.4.3.0 库的项目。 为了简单起见,我在这两个文件中复制了我不明白的东西: A.cpp #include "strin
是否有可能找到映射到 PAPI 事件的 native 事件集(CPU 计数器寄存器)? 最佳答案 如果你安装了 papi,你可以使用 papi_avail 来获取本地事件。例如, papi_avail
我使用了 cdecl 并将其定义为“将 papi 声明为指向 int 指针的指针的数组 10”所以我这样写我的代码 int i = 10; int *api[10]; api[0] = &i; int
我正在尝试使用 PAPI 读取硬件性能计数器,并且我编写了以下代码: #include #include #include "papi.h" /* This needs to be include
我正在尝试使用 PAPI 读取其中一个硬件计数器。当我尝试从 perf_event 列表中读取事件时,它工作正常。但是现在我需要从 perf_event_uncore 列表中读取一个计数器,它是通过
我正在尝试使用 papi 进行测试,但遇到一些错误,我不明白为什么会发生这些错误。我在网上找不到任何适合他们的东西。代码如下 我正在使用PAPI和C。 #include #include #inc
我正在做一个项目,我只需要使用 clang 生成位码,使用 opt 运行一些优化过程,然后创建一个可执行文件并测量其硬件计数器。 我可以直接使用 clang 链接: clang -g -O0 -w -
我试图在我的桌面上的 ubutu 16.4 上安装 papi。我面临错误,我找不到任何解决方案。也许是因为这是我第一次使用 Papi。我从 http://icl.cs.utk.edu/papi/sof
我正在使用 PAPI 高级 API 检查循环遍历数组的简单程序中的 TLB 未命中,但看到的数字比预期的要大。 在其他简单的测试用例中,结果似乎相当合理,这让我认为结果是真实的,额外的未命中是由于硬件
我正在使用 PAPI 高级 API 检查循环遍历数组的简单程序中的 TLB 未命中,但看到的数字比预期的要大。 在其他简单的测试用例中,结果似乎相当合理,这让我认为结果是真实的,额外的未命中是由于硬件
因此,我们的任务是编译一些代码(我们应该将其视为黑盒),使用不同的英特尔编译器优化标志(-O1 和 -O3)以及矢量化标志(- xhost 和 -no-vec) 并观察以下方面的变化: 执行时间 浮点
我正在开展一个项目,我们必须实现一种理论上证明对缓存友好的算法。简单来说,如果 N 是输入,B 是每次缓存未命中时在缓存和 RAM 之间传输的元素数,算法将需要 O(N/B) 访问 RAM。 我想证明
我是一名优秀的程序员,十分优秀!