MCPcopy Create free account
hub / github.com/SpecialKO/SpecialK / SK_GPUPollingThread

Function SK_GPUPollingThread

src/performance/gpu_monitor.cpp:75–1099  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73 > __nv_gpus;
74
75DWORD
76__stdcall
77SK_GPUPollingThread (LPVOID user)
78{
79 auto nv_gpus =
80 __nv_gpus.getPtr ();
81
82 SK_GPU_InitSensorData ();
83
84 std::ignore = user;
85
86 const HANDLE hEvents [2] = {
87 hPollEvent.get (),
88 hShutdownEvent.get ()
89 };
90
91 SetCurrentThreadDescription (L"[SK] GPU Performance Monitor");
92 SK_Thread_SetCurrentPriority (THREAD_PRIORITY_BELOW_NORMAL);
93 SetThreadPriorityBoost (GetCurrentThread (), FALSE);
94
95
96 auto SwitchToThreadMinPageFaults = [](void) ->
97 void
98 {
99 static int iters = 0;
100
101 if ((iters++ % 13) == 0)
102 SK_Sleep (2);
103
104 else if ((iters % 9) != 0)
105 SwitchToThread ();
106 };
107
108
109 NvPhysicalGpuHandle gpus [NVAPI_MAX_PHYSICAL_GPUS] = { };
110 NvU32 gpu_count = 0;
111
112
113 if (nvapi_init)
114 {
115#ifdef _DEBUG
116 SK_RunOnce (assert (NvAPI_GetGPUIDFromPhysicalGPU != nullptr));
117 SK_RunOnce (assert (NvAPI_GetPhysicalGPUFromGPUID != nullptr));
118#endif
119
120 NvAPI_EnumPhysicalGPUs (gpus, &gpu_count);
121 }
122
123 while (true)
124 {
125 static DWORD dwLastPoll =
126 SK_timeGetTime ();
127
128 DWORD dwNow =
129 SK_timeGetTime (),
130 dwWait =
131 WaitForMultipleObjectsEx ( 2, hEvents, FALSE,
132 INFINITE, FALSE );

Callers

nothing calls this directly

Calls 15

SK_GPU_InitSensorDataFunction · 0.85
SK_SleepFunction · 0.85
SK_RunOnceFunction · 0.85
SK_timeGetTimeFunction · 0.85
SK_SetThreadDescriptionFunction · 0.85
make_pairFunction · 0.85
SK_ADL_CountActiveGPUsFunction · 0.85
SK_ADL_GetActiveAdapterFunction · 0.85
SK_UTF8ToWideCharFunction · 0.85

Tested by

no test coverage detected