如何通过获取指令类型细分来表征工作负载? [英] How to characterize a workload by obtaining the instruction type breakdown?

查看:21
本文介绍了如何通过获取指令类型细分来表征工作负载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取测试程序中内存读写指令的百分比,最好是动态的.除了计算 gdb asm 转储中的指令(无论如何都是静态的)之外,还有没有更简单的方法来获取它?Valgrind 提供总堆使用量.Perf 有一些不错的功能,但不支持 WSL.Pin 有说明count 功能,但我不确定它是否支持 WSL.

I want to obtain the percentage of memory read-write instructions in a test program, preferably dynamically. Apart from counting instructions in the gdb asm dump, which is static anyway, is there an easier way to obtain it? Valgrind provides total heap usage. Perf has some nice features but does not support WSL. Pin has an instruction count capability but it I am not sure if it supports WSL.

推荐答案

(更新:据报道 PIN 在 WSL 下不起作用.但它不需要性能计数器,因此它在 VM 或其他任何东西中仍然有用.)

(Update: PIN reportedly doesn't work under WSL. But it doesn't require perf counters so it's still useful in VMs or whatever.)

您是否尝试过 PIN 或建立在 PIN 之上的 SDE 并满足您的需求?https://software.intel.com/en-us/文章/英特尔软件开发模拟器
sde64 -mix -- ./my-program 会告诉您 PIN 是否有效,并且可能会自行解决您的问题.SDE 的指令组合是通过助记符 IIRC 进行的,可能不是通过内存目标与 src,但至少您会知道 PIN 在您编写自定义 PIN 工具之前会起作用.

Have you tried PIN, or SDE which is built on top of PIN and does what you want? https://software.intel.com/en-us/articles/intel-software-development-emulator
sde64 -mix -- ./my-program will tell you if PIN works, and might solve your problem all on its own. SDE's instruction mix is by mnemonic IIRC, maybe not by memory destination vs. src, but at least you'll know that PIN will work before you sink any time into writing a custom PIN tool.

PIN 基于动态运行时检测,而不是性能计数器.它甚至可能不会引导 SIGILL(WSL 不会有问题);它必须在 CPU 上模拟 lzcnt,在那里它解码为 rep bsr,以及类似的东西.

PIN is based on dynamic runtime instrumentation, not performance counters. It probably doesn't even cath SIGILL (not that WSL would have a prob. with that); it has to emulate lzcnt on CPUs where it decodes as rep bsr, and stuff like that.

所以我怀疑 PIN 需要很多内核支持,超出了 JIT 的能力(Java 和 Web 浏览器 JS 引擎需要这些东西,而且只是 mmap(PROT_EXEC)).它可能会使用 ptrace,但如果 GDB 在 WSL 下工作,那么希望 PIN 可以.

So I doubt PIN needs much kernel support beyond the ability to JIT (which stuff like Java and web browser JS engines need, and is just mmap(PROT_EXEC)). It might use ptrace, but if GDB works under WSL then hopefully PIN will.

另请参阅计算 x86 汇编中不同类型指令数量以创建动态指令混合表的工具.

相关:如何确定 C 程序中执行的 x86 机器指令的数量? 不是 WSL 特定的,但提到了 sde64 -mix.

Related: How do I determine the number of x86 machine instructions executed in a C program? isn't WSL-specific, but mentions sde64 -mix.

这篇关于如何通过获取指令类型细分来表征工作负载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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