libhsakmt: Prefix global symbols with hsakmt

To support fully-static library ROCm builds, ensure that all global
symbols are prefixed with something meaningful to avoid collisions with
other libraries

A script was made using" objdump -C -t" to get a list of symbols,
then checking if the global symbols have a meaningful prefix (for thunk:
hsakmt or kmt in various cases)

Change-Id: Ifd353f64a3344eb60d1f6c4e041aa20967b38a59
Signed-off-by: Kent Russell <kent.russell@amd.com>
This commit is contained in:
Kent Russell
2024-08-23 14:15:16 -04:00
parent a676d8639c
commit 3da42a0847
37 changed files with 484 additions and 484 deletions
+3 -3
View File
@@ -169,14 +169,14 @@ void Dispatch::BuildIb() {
const unsigned int COMPUTE_PGM_VALUES_GFX8[] = {
static_cast<uint32_t>(shiftedIsaAddr), // PGM_LO
static_cast<uint32_t>(shiftedIsaAddr >> 32) // PGM_HI
| (is_dgpu() ? 0 : (1<<8)) // including PGM_ATC=?
| (hsakmt_is_dgpu() ? 0 : (1<<8)) // including PGM_ATC=?
};
// Starts at COMPUTE_PGM_LO
const unsigned int COMPUTE_PGM_VALUES_GFX9[] = {
static_cast<uint32_t>(shiftedIsaAddr), // PGM_LO
static_cast<uint32_t>(shiftedIsaAddr >> 32) // PGM_HI
| (is_dgpu() ? 0 : (1<<8)), // including PGM_ATC=?
| (hsakmt_is_dgpu() ? 0 : (1<<8)), // including PGM_ATC=?
0,
0,
static_cast<uint32_t>(m_scratch_base >> 8), // compute_dispatch_scratch_base
@@ -222,7 +222,7 @@ void Dispatch::BuildIb() {
0, // COMPUTE_USER_DATA_15 - - unused
};
const unsigned int DISPATCH_INIT_VALUE = 0x00000021 | (is_dgpu() ? 0 : 0x1000) |
const unsigned int DISPATCH_INIT_VALUE = 0x00000021 | (hsakmt_is_dgpu() ? 0 : 0x1000) |
((m_FamilyId >= FAMILY_NV) ? 0x8000 : 0);
// {COMPUTE_SHADER_EN=1, PARTIAL_TG_EN=0, FORCE_START_AT_000=0, ORDERED_APPEND_ENBL=0,
// ORDERED_APPEND_MODE=0, USE_THREAD_DIMENSIONS=1, ORDER_MODE=0, DISPATCH_CACHE_CNTL=0,
+2 -2
View File
@@ -75,7 +75,7 @@ void KFDEvictTest::AllocBuffers(HSAuint32 defaultGPUNode, HSAuint32 count, HSAui
for (HSAuint32 i = 0; i < count; ) {
ret = hsaKmtAllocMemory(defaultGPUNode, vramBufSize, m_Flags, &m_pBuf);
if (ret == HSAKMT_STATUS_SUCCESS) {
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
if (hsaKmtMapMemoryToGPUNodes(m_pBuf, vramBufSize, NULL,
mapFlags, 1, reinterpret_cast<HSAuint32 *>(&defaultGPUNode)) == HSAKMT_STATUS_ERROR) {
EXPECT_SUCCESS(hsaKmtFreeMemory(m_pBuf, vramBufSize));
@@ -103,7 +103,7 @@ void KFDEvictTest::FreeBuffers(std::vector<void *> &pBuffers, HSAuint64 vramBufS
for (HSAuint32 i = 0; i < pBuffers.size(); i++) {
m_pBuf = pBuffers[i];
if (m_pBuf != NULL) {
if (is_dgpu())
if (hsakmt_is_dgpu())
EXPECT_SUCCESS(hsaKmtUnmapMemoryToGPU(m_pBuf));
EXPECT_SUCCESS(hsaKmtFreeMemory(m_pBuf, vramBufSize));
}
@@ -197,7 +197,7 @@ TEST_F(KFDExceptionTest, AddressFault) {
int childStatus;
waitpid(m_ChildPid, &childStatus, 0);
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
EXPECT_EQ(WIFEXITED(childStatus), true);
EXPECT_EQ(WEXITSTATUS(childStatus), HSAKMT_STATUS_SUCCESS);
} else {
@@ -242,7 +242,7 @@ TEST_F(KFDExceptionTest, PermissionFault) {
int childStatus;
waitpid(m_ChildPid, &childStatus, 0);
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
EXPECT_EQ(WIFEXITED(childStatus), true);
EXPECT_EQ(WEXITSTATUS(childStatus), HSAKMT_STATUS_SUCCESS);
} else {
@@ -289,7 +289,7 @@ TEST_F(KFDExceptionTest, PermissionFaultUserPointer) {
int childStatus;
waitpid(m_ChildPid, &childStatus, 0);
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
EXPECT_EQ(WIFEXITED(childStatus), true);
EXPECT_EQ(WEXITSTATUS(childStatus), HSAKMT_STATUS_SUCCESS);
} else {
@@ -328,7 +328,7 @@ TEST_F(KFDExceptionTest, FaultStorm) {
int childStatus;
waitpid(m_ChildPid, &childStatus, 0);
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
EXPECT_EQ(WIFEXITED(childStatus), true);
EXPECT_EQ(WEXITSTATUS(childStatus), HSAKMT_STATUS_SUCCESS);
} else {
@@ -379,7 +379,7 @@ TEST_F(KFDExceptionTest, SdmaQueueException) {
int childStatus;
waitpid(m_ChildPid, &childStatus, 0);
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
EXPECT_EQ(WIFEXITED(childStatus), true);
EXPECT_EQ(WEXITSTATUS(childStatus), HSAKMT_STATUS_SUCCESS);
} else {
@@ -149,7 +149,7 @@ TEST_F(KFDGraphicsInterop, RegisterGraphicsHandle) {
TEST_F(KFDGraphicsInterop, RegisterForeignDeviceMem) {
TEST_START(TESTPROFILE_RUNALL)
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: Only supported on multi-dGPU system." << std::endl;
return;
}
@@ -51,7 +51,7 @@ TEST_F(KFDLocalMemoryTest, AccessLocalMem) {
ASSERT_GE(defaultGPUNode, 0) << "failed to get default GPU Node";
/* Skip test if not on dGPU path, which the test depends on */
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Not dGPU path, skipping the test" << std::endl;
return;
}
@@ -163,7 +163,7 @@ TEST_F(KFDLocalMemoryTest, VerifyContentsAfterUnmapAndMap) {
ASSERT_SUCCESS(queue.Create(defaultGPUNode));
queue.SetSkipWaitConsump(0);
if (!is_dgpu())
if (!hsakmt_is_dgpu())
ASSERT_SUCCESS(hsaKmtMapMemoryToGPUNodes(LocalBuffer.As<void*>(), LocalBuffer.Size(), &AlternateVAGPU,
mapFlags, 1, reinterpret_cast<HSAuint32 *>(&defaultGPUNode)));
@@ -183,7 +183,7 @@ TEST_F(KFDLocalMemoryTest, VerifyContentsAfterUnmapAndMap) {
EXPECT_SUCCESS(queue.Destroy());
EXPECT_EQ(SysBufferB.As<unsigned int*>()[0], 0x01010101);
if (!is_dgpu())
if (!hsakmt_is_dgpu())
EXPECT_SUCCESS(hsaKmtUnmapMemoryToGPU(LocalBuffer.As<void*>()));
TEST_END
@@ -285,7 +285,7 @@ TEST_F(KFDLocalMemoryTest, Fragmentation) {
* workaround. Also nicely matches the 8x bigger GPUVM address
* space on AMDGPU compared to RADEON.
*/
unsigned pageSize = is_dgpu() ? PAGE_SIZE*8 : PAGE_SIZE;
unsigned pageSize = hsakmt_is_dgpu() ? PAGE_SIZE*8 : PAGE_SIZE;
fbSize /= pageSize;
unsigned maxOrder = 0;
// Limit maxOrder up to 14 so this test doesn't run longer than 10 mins
+11 -11
View File
@@ -72,7 +72,7 @@ TEST_F(KFDMemoryTest, MMapLarge) {
TEST_REQUIRE_ENV_CAPABILITIES(ENVCAPS_64BITLINUX);
TEST_START(TESTPROFILE_RUNALL)
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: Test not supported on APU." << std::endl;
return;
}
@@ -298,7 +298,7 @@ TEST_F(KFDMemoryTest, AccessPPRMem) {
int defaultGPUNode = m_NodeInfo.HsaDefaultGPUNode();
ASSERT_GE(defaultGPUNode, 0) << "failed to get default GPU Node";
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
LOG() << "Skipping test: Test requires APU." << std::endl;
return;
}
@@ -440,7 +440,7 @@ TEST_F(KFDMemoryTest, MemoryRegister) {
}
TEST_F(KFDMemoryTest, MemoryRegisterSamePtr) {
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: Will run on APU once APU+dGPU supported." << std::endl;
return;
}
@@ -709,7 +709,7 @@ void KFDMemoryTest::SearchLargestBuffer(int allocNode, const HsaMemFlags &memFla
* the onerous memory swap operation. So we limit the buffer size that way.
*/
TEST_F(KFDMemoryTest, LargestSysBufferTest) {
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: Running on APU fails and locks the system." << std::endl;
return;
}
@@ -737,7 +737,7 @@ TEST_F(KFDMemoryTest, LargestSysBufferTest) {
}
TEST_F(KFDMemoryTest, LargestVramBufferTest) {
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: Running on APU fails and locks the system." << std::endl;
return;
}
@@ -783,7 +783,7 @@ TEST_F(KFDMemoryTest, LargestVramBufferTest) {
* performed on each buffer.
*/
TEST_F(KFDMemoryTest, BigSysBufferStressTest) {
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: Running on APU fails and locks the system." << std::endl;
return;
}
@@ -1103,7 +1103,7 @@ TEST_F(KFDMemoryTest, QueryPointerInfo) {
EXPECT_EQ(ptrInfo.GPUAddress, (HSAuint64)hostBuffer.As<void*>());
EXPECT_EQ(ptrInfo.SizeInBytes, (HSAuint64)hostBuffer.Size());
EXPECT_EQ(ptrInfo.MemFlags.ui32.CoarseGrain, 0);
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
EXPECT_EQ((HSAuint64)ptrInfo.NMappedNodes, nGPU);
// Check NMappedNodes again after unmapping the memory
hsaKmtUnmapMemoryToGPU(hostBuffer.As<void*>());
@@ -1137,7 +1137,7 @@ TEST_F(KFDMemoryTest, QueryPointerInfo) {
* User pointers registered with SVM API, does not create vm_object_t.
* Therefore, pointer info can not be queried.
*/
if (is_dgpu() && mem != hsaBuffer.As<void*>()) {
if (hsakmt_is_dgpu() && mem != hsaBuffer.As<void*>()) {
EXPECT_SUCCESS(hsaKmtQueryPointerInfo((void *)(&mem[0]), &ptrInfo));
EXPECT_EQ(ptrInfo.Type, HSA_POINTER_REGISTERED_USER);
EXPECT_EQ(ptrInfo.CPUAddress, &mem[0]);
@@ -1164,7 +1164,7 @@ TEST_F(KFDMemoryTest, QueryPointerInfo) {
EXPECT_SUCCESS(hsaKmtQueryPointerInfo(reinterpret_cast<void *>(address), &ptrInfo));
EXPECT_EQ(ptrInfo.Type, HSA_POINTER_ALLOCATED);
EXPECT_EQ(ptrInfo.CPUAddress, hostBuffer.As<void*>());
if (is_dgpu() && &mem[1] != hsaBuffer.As<HSAuint32 *>() + 1) {
if (hsakmt_is_dgpu() && &mem[1] != hsaBuffer.As<HSAuint32 *>() + 1) {
EXPECT_SUCCESS(hsaKmtQueryPointerInfo((void *)(&mem[1]), &ptrInfo));
EXPECT_EQ(ptrInfo.Type, HSA_POINTER_REGISTERED_USER);
EXPECT_EQ(ptrInfo.CPUAddress, &mem[0]);
@@ -1329,7 +1329,7 @@ TEST_F(KFDMemoryTest, PtraceAccess) {
TEST_F(KFDMemoryTest, PtraceAccessInvisibleVram) {
char *hsaDebug = getenv("HSA_DEBUG");
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: There is no VRAM on APU." << std::endl;
return;
}
@@ -1476,7 +1476,7 @@ void CatchSignal(int IntrSignal) {
TEST_F(KFDMemoryTest, SignalHandling) {
TEST_START(TESTPROFILE_RUNALL)
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: Test not supported on APU." << std::endl;
return;
}
@@ -139,7 +139,7 @@ testNodeToNodes(HSAuint32 n1, const HSAuint32 *const n2Array, int n, P2PDirectio
TEST_F(KFDPerformanceTest, P2PBandWidthTest) {
TEST_START(TESTPROFILE_RUNALL);
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: Can't have 2 APUs on the same system." << std::endl;
return;
}
@@ -321,7 +321,7 @@ exit:
TEST_F(KFDPerformanceTest, P2POverheadTest) {
TEST_START(TESTPROFILE_RUNALL);
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: Can't have 2 APUs on the same system." << std::endl;
return;
}
+2 -2
View File
@@ -399,7 +399,7 @@ TEST_F(KFDQMTest, SdmaConcurrentCopies) {
#define NPACKETS 1
#define COPY_SIZE (BUFFER_SIZE / NPACKETS)
HsaMemoryBuffer srcBuf(BUFFER_SIZE, 0, true);
HsaMemoryBuffer dstBuf(BUFFER_SIZE, defaultGPUNode, false, is_dgpu() ? true : false);
HsaMemoryBuffer dstBuf(BUFFER_SIZE, defaultGPUNode, false, hsakmt_is_dgpu() ? true : false);
SDMAQueue queue;
@@ -1493,7 +1493,7 @@ sdma_fill(HSAint32 node, void *dst, unsigned int data, HSAuint64 size) {
TEST_F(KFDQMTest, P2PTest) {
TEST_START(TESTPROFILE_RUNALL);
if (!is_dgpu()) {
if (!hsakmt_is_dgpu()) {
LOG() << "Skipping test: Two GPUs are required, but no dGPUs are present." << std::endl;
return;
}
@@ -57,7 +57,7 @@ void KFDSVMEvictTest::TearDown() {
}
HSAint32 KFDSVMEvictTest::GetBufferCounter(HSAuint64 vramSize, HSAuint64 vramBufSize) {
HSAuint64 vramBufSizeInPages = vramBufSize >> PAGE_SHIFT;
HSAuint64 vramBufSizeInPages = vramBufSize >> HSAKMT_PAGE_SHIFT;
HSAuint64 sysMemSize = GetSysMemSize();
HSAuint64 size, sizeInPages;
HSAuint32 count;
@@ -79,7 +79,7 @@ HSAint32 KFDSVMEvictTest::GetBufferCounter(HSAuint64 vramSize, HSAuint64 vramBuf
if (!xnack_enable && size > (sysMemSize - (sysMemSize >> 4)))
return 0;
sizeInPages = size >> PAGE_SHIFT;
sizeInPages = size >> HSAKMT_PAGE_SHIFT;
count = sizeInPages / (vramBufSizeInPages * N_PROCESSES);
return count;
@@ -105,10 +105,10 @@ HSAint64 KFDSVMEvictTest::GetBufferSize(HSAuint64 vramSize, HSAuint32 count,
if (!xnack_enable && size > (sysMemSize - (sysMemSize >> 4)))
return 0;
sizeInPages = size >> PAGE_SHIFT;
sizeInPages = size >> HSAKMT_PAGE_SHIFT;
vramBufSizeInPages = sizeInPages / (count * N_PROCESSES);
return vramBufSizeInPages << PAGE_SHIFT;
return vramBufSizeInPages << HSAKMT_PAGE_SHIFT;
}
void KFDSVMEvictTest::AllocBuffers(HSAuint32 defaultGPUNode, HSAuint32 count, HSAuint64 vramBufSize,
@@ -1321,7 +1321,7 @@ TEST_P(KFDSVMRangeTest, ReadOnlyRangeTest) {
int childStatus;
waitpid(pid, &childStatus, 0);
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
EXPECT_EQ(true, WIFEXITED(childStatus));
EXPECT_EQ(0, WEXITSTATUS(childStatus));
} else {
@@ -1447,8 +1447,8 @@ unsigned int ReadSMIEventThread(void* p) {
EXPECT_EQ(sscanf(msg, "%x %ld -%d @%lx(%d) %d->%x %x:%d %d\n", &event_id, &timestamp, &pid,
&addr, &size, &unused, &unused, &unused, &unused, &trigger), 10);
EXPECT_EQ(event_id, HSA_SMI_EVENT_MIGRATE_START);
EXPECT_EQ((HSAuint64 *)(addr << PAGE_SHIFT), pArgs->pBuf);
EXPECT_EQ(size << PAGE_SHIFT, pArgs->BufSize);
EXPECT_EQ((HSAuint64 *)(addr << HSAKMT_PAGE_SHIFT), pArgs->pBuf);
EXPECT_EQ(size << HSAKMT_PAGE_SHIFT, pArgs->BufSize);
EXPECT_EQ(pid, getpid());
EXPECT_EQ(trigger, HSA_MIGRATE_TRIGGER_PREFETCH);
close(fd);
+7 -7
View File
@@ -130,10 +130,10 @@ HSAKMT_STATUS CreateQueueTypeEvent(
return hsaKmtCreateEvent(&Descriptor, ManualReset, IsSignaled, Event);
}
static bool is_dgpu_dev = false;
static bool hsakmt_is_dgpu_dev = false;
bool is_dgpu() {
return is_dgpu_dev;
bool hsakmt_is_dgpu() {
return hsakmt_is_dgpu_dev;
}
bool hasPciAtomicsSupport(int node) {
@@ -213,9 +213,9 @@ unsigned int FamilyIdFromNode(const HsaNodeProperties *props) {
}
if (props->NumCPUCores && props->NumFComputeCores)
is_dgpu_dev = false;
hsakmt_is_dgpu_dev = false;
else
is_dgpu_dev = true;
hsakmt_is_dgpu_dev = true;
return familyId;
}
@@ -302,7 +302,7 @@ HsaMemoryBuffer::HsaMemoryBuffer(HSAuint64 size, unsigned int node, bool zero, b
EXPECT_EQ(m_Flags.ui32.HostAccess, 1);
EXPECT_SUCCESS(hsaKmtAllocMemory(m_Node, m_Size, m_Flags, &m_pBuf));
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
if (map_specific_gpu)
EXPECT_SUCCESS(hsaKmtMapMemoryToGPUNodes(m_pBuf, m_Size, NULL, mapFlags, 1, &m_Node));
else
@@ -531,7 +531,7 @@ HsaMemoryBuffer::~HsaMemoryBuffer() {
hsaKmtUnmapMemoryToGPU(m_pUser);
hsaKmtDeregisterMemory(m_pUser);
} else if (m_pBuf != NULL) {
if (is_dgpu()) {
if (hsakmt_is_dgpu()) {
if (m_MappedNodes) {
hsaKmtUnmapMemoryToGPU(m_pBuf);
}
+2 -2
View File
@@ -33,7 +33,7 @@
class BaseQueue;
#define ARRAY_SIZE(_x) (sizeof(_x)/sizeof(_x[0]))
#define ALIGN_UP(x, align) (((uint64_t)(x) + (align) - 1) & ~(uint64_t)((align)-1))
#define CounterToNanoSec(x) ((x) * 1000 / (is_dgpu() ? 27 : 100))
#define CounterToNanoSec(x) ((x) * 1000 / (hsakmt_is_dgpu() ? 27 : 100))
void WaitUntilInput();
HSAKMT_STATUS fscanf_dec(const char *file, uint32_t *num);
@@ -50,7 +50,7 @@ bool GetHwCapabilityHWS();
HSAKMT_STATUS CreateQueueTypeEvent(bool ManualReset, bool IsSignaled, unsigned int NodeId, HsaEvent** Event);
bool is_dgpu();
bool hsakmt_is_dgpu();
bool isTonga(const HsaNodeProperties *props);
bool hasPciAtomicsSupport(int node);
unsigned int FamilyIdFromNode(const HsaNodeProperties *props);
@@ -126,7 +126,7 @@ TEST_F(KFDTopologyTest, GpuvmApertureValidate) {
for (unsigned i = 0; i < GpuNodes.size(); i++) {
pNodeProperties = m_NodeInfo.GetNodeProperties(GpuNodes.at(i));
if (pNodeProperties != NULL) {
if (!is_dgpu() && !(FamilyIdFromNode(pNodeProperties) == FAMILY_KV)) {
if (!hsakmt_is_dgpu() && !(FamilyIdFromNode(pNodeProperties) == FAMILY_KV)) {
LOG() << "Skipping test: GPUVM framebuffer heap not exposed on APU except Kaveri." << std::endl;
return;
}
+1 -1
View File
@@ -33,7 +33,7 @@
#ifndef PAGE_SIZE
#define PAGE_SIZE (1<<12)
#define PAGE_SHIFT (12)
#define HSAKMT_PAGE_SHIFT (12)
#endif
enum TEXTCOLOR {
+2 -2
View File
@@ -55,7 +55,7 @@ void PM4WriteDataPacket::InitPacket(unsigned int *destBuf, void *data) {
m_pPacketData->bitfields2.dst_sel = dst_sel_mec_write_data_MEMORY_5; // memory-async
m_pPacketData->bitfields2.addr_incr = addr_incr_mec_write_data_INCREMENT_ADDR_0; // increment addr
m_pPacketData->bitfields2.wr_confirm = wr_confirm_mec_write_data_WAIT_FOR_CONFIRMATION_1;
m_pPacketData->bitfields2.atc = is_dgpu() ?
m_pPacketData->bitfields2.atc = hsakmt_is_dgpu() ?
atc_write_data_NOT_USE_ATC_0 : atc_write_data_USE_ATC_1;
m_pPacketData->bitfields2.cache_policy = cache_policy_mec_write_data_BYPASS_2;
@@ -97,7 +97,7 @@ void PM4ReleaseMemoryPacket::InitPacketCI(bool isPolling, uint64_t address,
pkt->bitfields2.l2_wb = 1;
pkt->bitfields2.l2_inv = 1;
pkt->bitfields2.cache_policy = cache_policy_mec_release_mem_BYPASS_2;
pkt->bitfields2.atc = is_dgpu() ?
pkt->bitfields2.atc = hsakmt_is_dgpu() ?
atc_mec_release_mem_ci_NOT_USE_ATC_0 :
atc_mec_release_mem_ci_USE_ATC_1; // ATC setting for fences and timestamps to the MC or TCL2.
pkt->bitfields3.dst_sel = dst_sel_mec_release_mem_MEMORY_CONTROLLER_0;