Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Estimation of instruction latency #1

Open
marshallward opened this issue Aug 18, 2017 · 1 comment
Open

Estimation of instruction latency #1

marshallward opened this issue Aug 18, 2017 · 1 comment

Comments

@marshallward
Copy link
Owner

Instruction latency is currently hardcoded in the scalar tests (avx_add, etc). This can vary across architectures, e.g. 3 cycle on Sandy Bridge, 7 cycle on KNL. The latency is used to determine the loop unroll factor in these tests. Values which are too small can cause pipeline stalls and significantly reduce the peak performance.

Additionally, choosing a value that is too large can cause a slowdown. It is usually small, but is nonetheless suboptimal. Very large latency values can also consume registers and indirectly cause large slowdowns.

Agner Fog's tool will dynamically compute the latency of every instruction, albeit with a kernel module. It may be worth looking into this and seeing if we can use a similar method to estimate latency.

@marshallward
Copy link
Owner Author

A potential method for measuring instruction latency has been in the dev/ directory for quite a while now:

https://github.com/marshallward/optiflop/tree/main/dev/latency

Unfortunately, it "mostly" works. When it works, it's really quite impressive. It even captures the latency bounds of very slow instructions like sqrt. But it will occasionally just give a very wrong answer.

I think the idea will be for autoconf to run these test programs and compute the latency, then bang them into the source as define macros.

I feel like this is close, but still not ready to integrate into the codebase. (Which is a shame, but it is surely better than the current hardcoded macros.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant