Add buffer cacheline size metric (#4228)
Summary:
Pull Request resolved: https://github.com/pytorch/executorch/pull/4228
This diff introduces a metric to GPUInfo that calculates the cacheline size of the buffer data pathway. In this experiment, all threads read from the cache with a varying stride. Reading two values from the same cacheline is cheap because the whole line is fetched as a block, regardless of which data we actually want. By varying the separation between the addresses of these two values, there will be a point where the shader will be forced to fetch two separate cachelines, which will have an effect in latency that we can detect.
[This article](https://igoro.com/archive/gallery-of-processor-cache-effects/) has more information on the topic.
Each run of the shader fetches the two values from different points in memory. The shader also has a seemingly redundant variable `zero` that will force the compiler to avoid optimizing the for loop.
The experiment will look like this:
{F1754670481}
Some useful concept definitions:
NITER: The number of iterations that would take the lowest stride to run in 1000 microseconds. All experiments will then run this number of times. This is to have a timing baseline and avoid timing errors.
PITCH: A number of bytes of separation between cache lines that ensures that all concurrent groups are being used, and therefore a fetch from two different cache lines is sure to have a latency increase.
STRIDE: The actual size of the cache line that will be obtained experimentally. Increasing this until it reaches the cache line size should show a latency increase, giving us the result we look for.
Reviewed By: jorgep31415
Differential Revision: D59649561
fbshipit-source-id: 2e82250d55929868982d17d1f405270897dcf9f4 E
Esteban Padilla Cerdio committed
6903715b199024d1a8aff057e656ebe98f4ccd07
Parent: dd7fa6a
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 7/15/2024, 4:59:57 PM