sách gpt4 ai đã đi

Valgrind có thể sử dụng nhiều bộ xử lý không?

In lại 作者:可可西里 更新时间:2023-11-01 15:05:06 29 4
mua khóa gpt4 Nike

有没有办法让 valgrind 使用多个处理器?

我正在使用 valgrind 的 callgrind 进行一些瓶颈分析,并注意到我的应用程序中的资源使用行为与在 valgrind/callgrind 之外运行时明显不同。

在 valgrind 外部运行时,它会占用多个处理器,但在 valgrind 内部运行时只使用一个。这让我担心我的瓶颈会出现在不同的地方,从而使我的分析无效。

1 Câu trả lời

根据 Valgrind 文档,它们不支持多处理器:

The main thing to point out with respect to threaded programs is that your program will use the native threading library, but Valgrind serialises execution so that only one (kernel) thread is running at a time. This approach avoids the horrible implementation problems of implementing a truly multithreaded version of Valgrind, but it does mean that threaded apps run only on one CPU, even if you have a multiprocessor or multicore machine.

Valgrind doesn't schedule the threads itself. It merely ensures that only one thread runs at once, using a simple locking scheme. The actual thread scheduling remains under control of the OS kernel. What this does mean, though, is that your program will see very different scheduling when run on Valgrind than it does when running normally. This is both because Valgrind is serialising the threads, and because the code runs so much slower than normal.

This difference in scheduling may cause your program to behave differently, if you have some kind of concurrency, critical race, locking, or similar, bugs. In that case you might consider using the tools Helgrind and/or DRD to track them down.

关于c++ - Valgrind 是否/可以使用多个处理器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5410001/

29 4 0
可可西里
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com