GProf 输出中缺少函数 [英] Missing function from GProf output

查看:61
本文介绍了GProf 输出中缺少函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试分析一些 C 代码,但在 GProf 输出中没有显示最直观的开销函数之一.

I'm trying to profile some C code but one of the most intuitively costly functions isn't showing up in the GProf output.

int main() {
    initialise...
    haloSwap();

    for(...) {
        functions...

        propagate();

        functions...
    }
}

void propagate() {
    for (x)
        for (y)
            for (z)
                grid[xNew][yNew][zNew] = grid[x][y][z];

    haloSwap();
}

void haloSwap() {
    // Horizontal swap
    create buffers...
    MPI_Sendrecv(buffers);
    recreate grid from buffers...

    // Vertical swap
    create buffers...
    MPI_Sendrecv(buffers);
    recreate grid from buffers...
}

希望伪代码能在某种程度上解释设置.haloSwap() 涉及线程之间的大量通信,我觉得这是算法的一个昂贵部分.它在初始化期间被调用,然后在算法循环期间被重复调用.

Hopefully that pseudo-code goes some way to explaining the set up. haloSwap() involves a lot of communication between threads and I feel it's an expensive part of the algorithm. It's called during initialisation and then repeatedly during the loop of the algorithm.

GProf 仅显示对 haloSwap 的 1 次调用(在初始化期间),尽管我知道它从 propagate() 内部被调用了 1000 多次.

GProf shows only 1 call to haloSwap (during init), even though I know it's called 1000+ times from inside propagate().

propagate() 显示为代码中最昂贵的部分,但我想知道它是 xyz 循环还是 MPI 通信.

propagate() is showing as the most expensive part of the code, but I'd like to know whether it's the xyz loop(s) or the MPI comminucation.

有谁知道为什么 propagatehaloSwap 的调用在调用次数和在函数中花费的时间似乎都被忽略了?

Does anyone know why the calls to haloSwap from propagate are seemingly ignored in both the number of calls and the time spent in the function?

haloSwap 定义在另一个 .c 文件中,这可能是一个因素?

haloSwap is defined within another .c file, which may be a factor?

如果我在调用 propagate 之后将 haloSwap 的调用移动到主循环(而不是在主循环中),GProf 仍然只显示 1 次调用.

If I move the call of haloSwap to the main loop after calling propagate (instead of inside it), GProf still only shows 1 call to it.

推荐答案

@Hristo_Iliev 和 @Angelos 是正确的,我正在编译优化,我的问题通过使用 -O0 编译解决.愚蠢的错误,我确定我以前犯过.

@Hristo_Iliev and @Angelos were correct, I was compiling with optimisations and my problem was solved by compiling with -O0. Stupid mistake, I'm sure I've made it before.

这篇关于GProf 输出中缺少函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆