Removes default visibility in debug mode and updates unit tests for alt_rsmi impl (#2091)

* Update unit tests for alt_rsmi impl

- Create distinct test executable for alt_rsmi testing
- Updated alt_rsmi tests to use public methods
- Compiles alt_rsmi.cc with ARSMI_TEST_BUILD
- Enables external linkage of internal variables
- Only for AltRsmiTests.cpp that manipulates internals
- Clean separation for test behavior

* Address review comments

* restore hidden symbol visibility
Dieser Commit ist enthalten in:
Atul Kulkarni
2025-12-17 10:27:00 -08:00
committet von GitHub
Ursprung 2e193aed68
Commit 74690ea705
4 geänderte Dateien mit 1313 neuen und 15 gelöschten Zeilen
+16 -5
Datei anzeigen
@@ -48,18 +48,29 @@ struct ARSMI_systemNode {
std::string s_card;
};
static const char *kKFDNodesPathRoot = "/sys/class/kfd/kfd/topology/nodes";
// Internal implementation details
// When compiled into the test binary (ARSMI_TEST_BUILD defined), these have external linkage
// so AltRsmiTestUtils.cpp can access them via extern declarations.
// When compiled into the production library (ARSMI_TEST_BUILD not defined), these are static.
#ifdef ARSMI_TEST_BUILD
// Test build: external linkage for cross-TU access
#define ARSMI_LOCAL thread_local
#else
// Production build: static/internal linkage
#define ARSMI_LOCAL static thread_local
#endif
ARSMI_LOCAL const char *kKFDNodesPathRoot = "/sys/class/kfd/kfd/topology/nodes";
static const uint32_t kAmdGpuId = 0x1002;
// Vector containing data about each node, ordered by bdf ID
static thread_local std::vector<ARSMI_systemNode> ARSMI_orderedNodes;
ARSMI_LOCAL std::vector<ARSMI_systemNode> ARSMI_orderedNodes;
// 2-D matrix with link information between each pair of nodes.
static thread_local std::vector<std::vector<ARSMI_linkInfo>> ARSMI_orderedLinks;
ARSMI_LOCAL std::vector<std::vector<ARSMI_linkInfo>> ARSMI_orderedLinks;
// Number of devices recognized
static thread_local int ARSMI_num_devices=-1;
ARSMI_LOCAL int ARSMI_num_devices=-1;
// Public API functions
int ARSMI_init(void)