Author Topic: Cache watch in Visual Studio?  (Read 429 times)

Ralphy

  • Regular Member
  • *
  • Posts: 3
Cache watch in Visual Studio?
« on: February 15, 2022, 06:37:00 AM »
Hello, noob here with a question. How can I see the contents of a CPU core cache (data and code) during debugging? Is this possible with Visual Studio? I'm curious to see proof of effective use or fencing, alignment and non-temporal movs to find opportunities for optimization.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 9353
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Cache watch in Visual Studio?
« Reply #1 on: February 17, 2022, 08:54:49 AM »
Ralphy,

I think the clock is your friend here, its tedious but constructing test pieces and accurately timing them is probably the best you can do here.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Ralphy

  • Regular Member
  • *
  • Posts: 3
Re: Cache watch in Visual Studio?
« Reply #2 on: February 17, 2022, 12:26:00 PM »
Hi hutch,

  There must be a way :). We can prefetch data into a line, maybe there's an op in level 0 to read lines as well. Hard to believe kernel and driver devs don't sneak a peak. Timing is tricky now, CPUs use the same accountant that's calculating current inflation numbers for the fed. There must be a way..

johnsa

  • Member
  • ****
  • Posts: 868
    • Uasm
Re: Cache watch in Visual Studio?
« Reply #3 on: April 03, 2022, 02:01:46 AM »
I think you'll find that the only way to interrogate this sort of information would be through model specific MSR registers. Access to these would be privileged, and their contents mostly irrelevant in a multi-tasking OS.
Really the best way to determine if code changes such as non temporal stores etc are having a performance impact is to measure time taken. You can get very accurate timing with high resolution timers and RDTSC etc.