Пример #1
0
int test_perfmonsetup()
{
    CpuInfo_t cpuinfo;
    int group1, group2;
    int cpu = 0;
    topology_init();
    cpuinfo = get_cpuInfo();
    if (cpuinfo->isIntel == 0)
    {
        topology_finalize();
        return 1;
    }
    int ret = perfmon_init(1, &cpu);
    if (ret != 0)
        goto fail;
    if (perfmon_getNumberOfGroups() != 0)
        goto fail;
    if (perfmon_getNumberOfThreads() != 1)
        goto fail;
    ret = perfmon_addEventSet(eventset_ok);
    if (ret != 0)
        goto fail;
    group1 = ret;
    if (perfmon_getNumberOfGroups() != 1)
        goto fail;
    if (perfmon_getNumberOfEvents(group1) != 3)
        goto fail;
    ret = perfmon_setupCounters(group1);
    if (ret != 0)
        goto fail;
    if (perfmon_getIdOfActiveGroup() != group1)
        goto fail;
    ret = perfmon_addEventSet(eventset_option);
    if (ret != 1)
        goto fail;
    group2 = ret;
    if (perfmon_getIdOfActiveGroup() != group1)
        goto fail;
    if (perfmon_getNumberOfGroups() != 2)
        goto fail;
    if (perfmon_getNumberOfEvents(group1) != 3)
        goto fail;
    if (perfmon_getNumberOfEvents(group2) != 3)
        goto fail;
    perfmon_finalize();
    topology_finalize();
    return 1;
fail:
    perfmon_finalize();
    topology_finalize();
    return 0;
}
Пример #2
0
static int lua_likwid_getIdOfActiveGroup(lua_State* L)
{
    int number;
    if (perfmon_isInitialized == 0)
    {
        return 0;
    }
    number = perfmon_getIdOfActiveGroup();
    lua_pushnumber(L,number+1);
    return 1;
}
Пример #3
0
static int lua_likwid_switchGroup(lua_State* L)
{
    int ret = -1;
    int newgroup = lua_tonumber(L,1)-1;
    if (perfmon_isInitialized == 0)
    {
        return 0;
    }
    if (newgroup >= perfmon_getNumberOfGroups())
    {
        newgroup = 0;
    }
    if (newgroup == perfmon_getIdOfActiveGroup())
    {
        lua_pushinteger(L, ret);
        return 1;
    }
    ret = perfmon_switchActiveGroup(newgroup);
    lua_pushinteger(L, ret);
    return 1;
}
Пример #4
0
int test_perfmonaddeventset()
{
    char eventset_fail1[] = "INSTR_RETIRED.ANY:FIXC0";
    char eventset_fail2[] = "INSTR_RETIRED-ANY:FIXC0";
    CpuInfo_t cpuinfo;
    int cpu = 0;
    topology_init();
    cpuinfo = get_cpuInfo();
    if (cpuinfo->isIntel == 0)
    {
        topology_finalize();
        return 1;
    }
    int ret = perfmon_init(1, &cpu);
    if (ret != 0) {
        printf("Perfmon init failed\n");
        goto fail;
    }
    if (perfmon_getNumberOfGroups() != 0) {
        printf("Perfmon number of groups != 0\n");
        goto fail;
    }
    if (perfmon_getNumberOfThreads() != 1) {
        printf("Perfmon number of threads != 1\n");
        goto fail;
    }
    if (perfmon_getIdOfActiveGroup() != -1) {
        printf("Perfmon id of active group != -1\n");
        goto fail;
    }
    ret = perfmon_addEventSet(eventset_ok);
    if (ret != 0) {
        printf("Perfmon addEventSet(ok) failed\n");
        goto fail;
    }
    if (perfmon_getNumberOfGroups() != 1) {
        printf("Perfmon number of groups != 1\n");
        goto fail;
    }
    if (perfmon_getNumberOfEvents(ret) != 3) {
        printf("Perfmon number of events != 3\n");
        goto fail;
    }
    if (perfmon_getIdOfActiveGroup() != -1) {
        printf("Perfmon id of active group != -1\n");
        goto fail;
    }
    ret = perfmon_addEventSet(eventset_option);
    if (ret != 1) {
        printf("Perfmon addEventSet(options) failed\n");
        goto fail;
    }
    if (perfmon_getNumberOfGroups() != 2) {
        printf("Perfmon number of groups != 2\n");
        goto fail;
    }
    if (perfmon_getNumberOfEvents(ret) != 3) {
        printf("Perfmon number of events != 3\n");
        goto fail;
    }
    if (perfmon_getIdOfActiveGroup() != -1) {
        printf("Perfmon id of active group != -1\n");
        goto fail;
    }
    ret = perfmon_addEventSet(eventset_fail1);
    if (ret >= 0) {
        printf("Perfmon addEventSet(fail1) failed\n");
        goto fail;
    }
    if (perfmon_getNumberOfGroups() != 2) {
        printf("Perfmon number of groups != 2\n");
        goto fail;
    }
    ret = perfmon_addEventSet(eventset_fail2);
    if (ret >= 0) {
        printf("Perfmon addEventSet(fail2) failed\n");
        goto fail;
    }
    if (perfmon_getNumberOfGroups() != 2) {
        printf("Perfmon number of groups != 2\n");
        goto fail;
    }
    if (perfmon_getIdOfActiveGroup() != -1) {
        printf("Perfmon id of active group != -1\n");
        goto fail;
    }
    perfmon_finalize();
    affinity_finalize();
    topology_finalize();
    return 1;
fail:
    perfmon_finalize();
    affinity_finalize();
    topology_finalize();
    return 0;
}