| 73 | > __nv_gpus; |
| 74 | |
| 75 | DWORD |
| 76 | __stdcall |
| 77 | SK_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 ); |
nothing calls this directly
no test coverage detected