Skip to content

Commit

Permalink
Add pci function ID to CudaDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
TomTheBear committed Nov 15, 2024
1 parent f1c7420 commit 7ee3196
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions doc/lua-doxygen.md
Original file line number Diff line number Diff line change
Expand Up @@ -3723,6 +3723,10 @@ The option 'n' takes an argument, specified by the ':'. If found the option argu
<TD>\a pciDom</TD>
<TD>PCI domain identifier of the device</TD>
</TR>
<TR>
<TD>\a pciFunc</TD>
<TD>PCI function identifier of the device</TD>
</TR>
<TR>
<TD>\a maxBlockRegs</TD>
<TD>Maximum number of 32-bit registers available to a thread block</TD>
Expand Down
1 change: 1 addition & 0 deletions src/applications/likwid-topology.lua
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ if likwid.nvSupported() then
table.insert(output_csv, string.format("PCI bus:\t\t0x%x", gpu["pciBus"]))
table.insert(output_csv, string.format("PCI domain:\t\t0x%x", gpu["pciDom"]))
table.insert(output_csv, string.format("PCI device:\t\t0x%x", gpu["pciDev"]))
table.insert(output_csv, string.format("PCI function:\t\t0x%x", gpu["pciFunc"]))
end
table.insert(output_csv, likwid.hline)
end
Expand Down
1 change: 1 addition & 0 deletions src/includes/likwid.h
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,7 @@ typedef struct {
int pciDev; /*!< \brief PCI device (also known as slot) identifier of the
device */
int pciDom; /*!< \brief PCI domain identifier of the device */
int pciFunc; /*!< \brief PCI function identifier of the device */
int maxBlockRegs; /*!< \brief Maximum number of 32-bit registers available to
a thread block */
int numMultiProcs; /*!< \brief Number of multiprocessors on the device */
Expand Down
5 changes: 3 additions & 2 deletions src/likwid_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,11 @@ int likwid_device_get_available(LikwidDeviceType type, char ***id_list)
{
#ifdef LIKWID_WITH_NVMON
case DEVICE_TYPE_NVIDIA_GPU:
snprintf(id_str, sizeof(id_str), "GN:%08x:%02x:%02x.0",
snprintf(id_str, sizeof(id_str), "GN:%08x:%02x:%02x.%01x",
cuda_topo->devices[i].pciDom,
cuda_topo->devices[i].pciBus,
cuda_topo->devices[i].pciDev);
cuda_topo->devices[i].pciDev,
cuda_topo->devices[i].pciFunc);
break;
#endif
#ifdef LIKWID_WITH_ROCMON
Expand Down
3 changes: 3 additions & 0 deletions src/luawid.c
Original file line number Diff line number Diff line change
Expand Up @@ -2625,6 +2625,9 @@ static int lua_likwid_getCudaTopology(lua_State *L) {
lua_pushstring(L, "pciDom");
lua_pushinteger(L, (lua_Integer)(gpu->pciDom));
lua_settable(L, -3);
lua_pushstring(L, "pciFunc");
lua_pushinteger(L, (lua_Integer)(gpu->pciFunc));
lua_settable(L, -3);
lua_pushstring(L, "maxBlockRegs");
lua_pushinteger(L, (lua_Integer)(gpu->maxBlockRegs));
lua_settable(L, -3);
Expand Down
2 changes: 2 additions & 0 deletions src/topology_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ topology_cuda_init()
CU_CALL((*cuDeviceGetAttributeTopoPtr)(&cudaTopology.devices[i].pciBus, CU_DEVICE_ATTRIBUTE_PCI_BUS_ID, dev), ret = -ENOMEM; goto topology_gpu_init_error;);
CU_CALL((*cuDeviceGetAttributeTopoPtr)(&cudaTopology.devices[i].pciDev, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, dev), ret = -ENOMEM; goto topology_gpu_init_error;);
CU_CALL((*cuDeviceGetAttributeTopoPtr)(&cudaTopology.devices[i].pciDom, CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, dev), ret = -ENOMEM; goto topology_gpu_init_error;);
// TODO: Get PCI function through nvmlDeviceGetPciInfo_v3, nvmlPciInfo_t->function
cudaTopology.devices[i].pciFunc = 0;
CU_CALL((*cuDeviceGetAttributeTopoPtr)(&cudaTopology.devices[i].maxBlockRegs, CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK, dev), ret = -ENOMEM; goto topology_gpu_init_error;);
CU_CALL((*cuDeviceGetAttributeTopoPtr)(&cudaTopology.devices[i].numMultiProcs, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, dev), ret = -ENOMEM; goto topology_gpu_init_error;);
CU_CALL((*cuDeviceGetAttributeTopoPtr)(&cudaTopology.devices[i].maxThreadPerMultiProc, CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR, dev), ret = -ENOMEM; goto topology_gpu_init_error;);
Expand Down
1 change: 1 addition & 0 deletions test/test-topology-gpu-rocm.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ int main()
printf("pciBus: %d\n", device->pciBus);
printf("pciDev: %d\n", device->pciDev);
printf("pciDom: %d\n", device->pciDom);
printf("pciFunc: %d\n", device->pciFunc);
printf("numMultiProcs: %d\n", device->numMultiProcs);
printf("maxThreadPerMultiProc: %d\n", device->maxThreadPerMultiProc);
printf("memBusWidth: %d\n", device->memBusWidth);
Expand Down

0 comments on commit 7ee3196

Please sign in to comment.