c - PAPI(性能应用程序编程)无法正常工作?

标签 c performance performancecounter papi

我从网站上下载了 4.4 版本,将其构建在我自己的目录中,并尝试编写一个小主程序,但它一直显示 num_counters 为零。然后我查看了 ctests 并选择了 hwinfo.c,并从中删除了一些代码(和 teSTLib)并将其放入一个如下所示的小主文件中:

#include <stdio.h>
#include <papi.h>

int main(int argc, char** argv)
{

    int retval, i, j;
    const PAPI_hw_info_t *hwinfo = NULL;
    const PAPI_mh_info_t *mh;


    retval = PAPI_library_init( PAPI_VER_CURRENT );
    if ( retval != PAPI_VER_CURRENT )
        cerr << "Failed at line " << __LINE__ << endl;

    retval =
        papi_print_header
        ( "Test case hwinfo.c: Check output of PAPI_get_hardware_info.\n",
          &hwinfo );
    if ( retval != PAPI_OK )
        cerr << "Failed at line " << __LINE__ << endl;
}

我使用以下内容构建了它:

g++ main.cpp -I/home/pchan/rabbit/papi/include /home/pchan/rabbit/papi/lib/libpapi.a

并运行它:

./a.out

只是为了见证这个输出:

测试用例 hwinfo.c:检查 PAPI_get_hardware_info 的输出。

--------------------------------------------------------------------------------
PAPI Version             : 4.4.0.0
Vendor string and code   :  (0)
Model string and code    :  (0)
CPU Revision             : 0.000000
CPU Megahertz            : 0.000000
CPU Clock Megahertz      : 0
CPUs per Node            : 0
Total CPUs               : 0
Number Hardware Counters : 0
Max Multiplex Counters   : 0
--------------------------------------------------------------------------------

我对正在发生的事情以及为什么这不起作用......这是什么症状以及我可以尝试解决什么问题感到有点迷失?我的处理器是 Intel Xeon X5760,我的 uname -a 说:

Linux chanbox 2.6.18-308.4.1.el5 #1 SMP Wed Mar 28 01:54:56 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

最佳答案

尝试“papi_avail -a”了解您的电脑支持什么。

关于c - PAPI(性能应用程序编程)无法正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11695435/

相关文章:

c - 在 long 中找到最重要的设置位

c - 如何在 GTK 中检查单选按钮是否被选中

php - 提高 php 在本地服务器上的性能

c++ - 从文件中解析原始数据的最快最有效的方法

c - 在 C 头文件中使用定义?

c - 为什么默认情况下不剥离用gcc编译的二进制文件

sqlite 在左连接中使用了错误的索引

c# - 如何使用性能计数器获取进程正在运行的线程数?

performancecounter - perf 脚本输出的含义是什么?

.net - 如何在 IIS 中使用性能计数器和 WCF 服务?