diff --git a/projects/rocr-runtime/include/hsakmttypes.h b/projects/rocr-runtime/include/hsakmttypes.h index efff03d912..bbe24d286b 100644 --- a/projects/rocr-runtime/include/hsakmttypes.h +++ b/projects/rocr-runtime/include/hsakmttypes.h @@ -312,7 +312,10 @@ typedef struct _HsaNodeProperties HSAuint32 Domain; // PCI domain of the GPU HSAuint64 UniqueID; // Globally unique immutable id - HSAuint8 Reserved[20]; + + HSAuint32 VGPRSizePerCU; // VGPR size in bytes per CU + HSAuint32 SGPRSizePerCU; // SGPR size in bytes per CU + HSAuint8 Reserved[12]; } HsaNodeProperties; diff --git a/projects/rocr-runtime/src/libhsakmt.h b/projects/rocr-runtime/src/libhsakmt.h index 6be639261b..f248c0eaee 100644 --- a/projects/rocr-runtime/src/libhsakmt.h +++ b/projects/rocr-runtime/src/libhsakmt.h @@ -212,4 +212,9 @@ void clear_process_doorbells(void); uint32_t get_num_sysfs_nodes(void); bool is_forked_child(void); + +/* Calculate VGPR and SGPR register file size per CU */ +#define VGPR_SIZE_PER_CU(asic_family) ((asic_family == CHIP_ARCTURUS || \ + asic_family == CHIP_ALDEBARAN) ? 0x80000 : 0x40000) +#define SGPR_SIZE_PER_CU 0x4000 #endif diff --git a/projects/rocr-runtime/src/queues.c b/projects/rocr-runtime/src/queues.c index 1e4188382a..2cd48af5f3 100644 --- a/projects/rocr-runtime/src/queues.c +++ b/projects/rocr-runtime/src/queues.c @@ -42,9 +42,6 @@ #define DOORBELL_SIZE_GFX9 8 #define DOORBELLS_PAGE_SIZE(ds) (1024 * (ds)) -#define VGPR_SIZE_PER_CU(asic_family) ((asic_family == CHIP_ARCTURUS || \ - asic_family == CHIP_ALDEBARAN) ? 0x80000 : 0x40000) -#define SGPR_SIZE_PER_CU 0x4000 #define LDS_SIZE_PER_CU 0x10000 #define HWREG_SIZE_PER_CU 0x1000 #define WG_CONTEXT_DATA_SIZE_PER_CU(asic_family) (VGPR_SIZE_PER_CU(asic_family) + SGPR_SIZE_PER_CU + LDS_SIZE_PER_CU + HWREG_SIZE_PER_CU) diff --git a/projects/rocr-runtime/src/topology.c b/projects/rocr-runtime/src/topology.c index 0a0131e9b1..8f1712102f 100644 --- a/projects/rocr-runtime/src/topology.c +++ b/projects/rocr-runtime/src/topology.c @@ -1103,6 +1103,11 @@ HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id, props->MarketingName[i] = name[i]; props->MarketingName[i] = '\0'; } + + /* Get VGPR/SGPR size in byte per CU */ + props->VGPRSizePerCU = VGPR_SIZE_PER_CU(hsa_gfxip->asic_family); + props->SGPRSizePerCU = SGPR_SIZE_PER_CU; + } else if (props->DeviceId) /* still return success */ pr_err("device ID 0x%x is not supported in libhsakmt\n", diff --git a/projects/rocr-runtime/tests/kfdtest/src/KFDTopologyTest.cpp b/projects/rocr-runtime/tests/kfdtest/src/KFDTopologyTest.cpp index 05a57fb411..bad2533d49 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/KFDTopologyTest.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/KFDTopologyTest.cpp @@ -59,6 +59,13 @@ TEST_F(KFDTopologyTest , BasicTest) { EXPECT_GE(pNodeProperties->EngineId.ui32.Major, 7) << "Major Version is less than 7"; EXPECT_LT(pNodeProperties->EngineId.ui32.Minor, 10) << "Minor Version is greater than 9"; EXPECT_GT(pNodeProperties->uCodeEngineVersions.uCodeSDMA, 0) << "sDMA firmware version is 0"; + HSAuint32 VGPRSize = (FamilyIdFromNode(pNodeProperties) == FAMILY_AR || + FamilyIdFromNode(pNodeProperties) == FAMILY_AL) ? + 0x80000 : 0x40000; + EXPECT_EQ(pNodeProperties->VGPRSizePerCU, VGPRSize) << "VGPR Size Per CU is not correct"; + EXPECT_EQ(pNodeProperties->SGPRSizePerCU, 0x4000) << "SGPR Size Per CU is not correct"; + LOG() << "VGPR Size is " << pNodeProperties->VGPRSizePerCU << + " SGPR Size is " << pNodeProperties->SGPRSizePerCU << std::endl; } EXPECT_GT(pNodeProperties->NumMemoryBanks, HSAuint32(0)) << "Node index: " << node << "No MemoryBanks."; EXPECT_GT(pNodeProperties->NumCaches, HSAuint32(0)) << "Node index: " << node << "No Caches.";