How to programatically get NPU utilization using C/C++/C#

comor 5 Reputation points
2024-06-06T08:39:18.8033333+00:00

如果一台PC有NPU,那么在Windows 11任务管理器中,“性能”页面就会显示NPU的信息(包括使用率),一般来说,这个页面显示的信息从“性能计数器(PDH)”中获取,但是我并没有找到对应的计数器。有谁知道这个NPU使用率从哪儿获取吗?

If a PC has an NPU, then in the Windows 11 Task Manager, the "Performance" page will display the information of the NPU (including the usage rate). Generally speaking, the information displayed on this page is obtained from the "Performance Counter (PDH)", but I have not found the corresponding counter. Does anyone know where this NPU usage rate is obtained from?

User's image

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,647 questions
Windows Performance Toolkit
Windows Performance Toolkit
A collection of Microsoft performance monitoring tools that produce in-depth performance profiles of Windows operating systems and applications.
105 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Tong Xu - MSFT 2,471 Reputation points Microsoft Vendor
    2024-06-07T02:32:45.0933333+00:00

    Hello,

    Welcome to Microsoft Q&A!

    It gets the perf counter data, and get perf counter then using the physical ID to classify the running time data and do the math. Here is a sample: https://gist.github.com/fecf/2103a82afc76b5c88829c4383944a5aa

    Digging a little deeper, the adapter for the NPU engine here is taken via the DXCore enumeration adapter and then collected and displayed by creating a query and adding counters to it.
    https://learn.microsoft.com/en-us/windows/win32/dxcore/dxcore-enum-adapters


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.