Skip to content

Commit

Permalink
nvidia-gpu: Hack NvAPI_GPU_GetGPUInfo together
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Feb 13, 2024
1 parent 0951afb commit 01f1700
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/nvapi_gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,41 @@ extern "C" {
return Ok(n);
}

NvAPI_Status __cdecl NvAPI_GPU_GetGPUInfo(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_INFO* pGpuInfo) {
constexpr auto n = __func__;

if (nvapiAdapterRegistry == nullptr)
return ApiNotInitialized(n);

if (pGpuInfo == nullptr)
return InvalidArgument(n);

if (pGpuInfo->version != NV_GPU_INFO_VER1 && pGpuInfo->version != NV_GPU_INFO_VER2)
return IncompatibleStructVersion(n);

auto adapter = reinterpret_cast<NvapiAdapter*>(hPhysicalGpu);
if (!nvapiAdapterRegistry->IsAdapter(adapter))
return ExpectedPhysicalGpuHandle(n);

switch (pGpuInfo->version) {
case NV_GPU_INFO_VER1: {
auto pGpuInfoV1 = reinterpret_cast<NV_GPU_INFO_V1*>(pGpuInfo);
*pGpuInfoV1 = {};
break;
}
case NV_GPU_INFO_VER2:
*pGpuInfo = {};
// Values are taken from RTX3090
pGpuInfo->rayTracingCores = 82;
pGpuInfo->tensorCores = 10496;
break;
default:
return IncompatibleStructVersion(n);
}

return Ok(n);
}

NvAPI_Status __cdecl NvAPI_GPU_GetVbiosVersionString(NvPhysicalGpuHandle hPhysicalGpu, NvAPI_ShortString szBiosRevision) {
constexpr auto n = __func__;

Expand Down
1 change: 1 addition & 0 deletions src/nvapi_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ extern "C" {
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetLogicalGpuInfo)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetArchInfo)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_CudaEnumComputeCapableGpus)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetGPUInfo)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetDynamicPstatesInfoEx)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetThermalSettings)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetVbiosVersionString)
Expand Down

0 comments on commit 01f1700

Please sign in to comment.