KFDTest: Shader modification for gfx10

Modified shaders in KFD memory test to support gfx10.
There is no gprs register for flat_scratch on gfx10.
Use s_setreg_b32 instruction to set flat scratch base
address register

Change-Id: I505156a046056b61ce2d873343feb50ce635274a
Signed-off-by: shaoyunl <shaoyun.liu@amd.com>
Signed-off-by: Oak Zeng <Oak.Zeng@amd.com>
Bu işleme şunda yer alıyor:
shaoyunl
2019-07-18 19:34:55 -04:00
işlemeyi yapan: Shaoyun Liu
ebeveyn 79a3995816
işleme 85a9821519
+105 -11
Dosyayı Görüntüle
@@ -84,6 +84,31 @@ type(CS)\n\
\n\
end\n\
";
const char* gfx10_ScratchCopyDword =
"\
shader ScratchCopyDword\n\
asic(GFX10)\n\
type(CS)\n\
wave_size(32)\n\
/*copy the parameters from scalar registers to vector registers*/\n\
v_mov_b32 v0, s0\n\
v_mov_b32 v1, s1\n\
v_mov_b32 v2, s2\n\
v_mov_b32 v3, s3\n\
/*set up the scratch parameters. This assumes a single 16-reg block.*/\n\
s_setreg_b32 hwreg(HW_REG_SHADER_FLAT_SCRATCH_LO), s4\n\
s_setreg_b32 hwreg(HW_REG_SHADER_FLAT_SCRATCH_HI), s5\n\
/*copy a dword between the passed addresses*/\n\
flat_load_dword v4, v[0:1] slc\n\
s_waitcnt vmcnt(0)&lgkmcnt(0)\n\
flat_store_dword v[2:3], v4 slc\n\
\n\
s_endpgm\n\
\n\
end\n\
";
/* Continuously poll src buffer and check buffer value
* After src buffer is filled with specific value (0x5678,
@@ -106,6 +131,22 @@ type(CS)\n\
end\n\
";
const char* gfx10_PollMemory =
"\
shader ReadMemory\n\
asic(GFX10)\n\
type(CS)\n\
/* Assume src address in s0, s1 and dst address in s2, s3*/\n\
s_movk_i32 s18, 0x5678\n\
LOOP:\n\
s_load_dword s16, s[0:1], 0x0 glc\n\
s_cmp_eq_i32 s16, s18\n\
s_cbranch_scc0 LOOP\n\
s_store_dword s18, s[2:3], 0x0 glc\n\
s_endpgm\n\
end\n\
";
/* Input: A buffer of at least 3 dwords.
* DW0: used as a signal. 0xcafe means it is signaled
* DW1: Input buffer for device to read.
@@ -134,6 +175,27 @@ POLLSIGNAL:\n\
end\n\
";
const char* gfx10_CopyOnSignal =
"\
shader CopyOnSignal\n\
asic(GFX10)\n\
type(CS)\n\
/* Assume input buffer in s0, s1 */\n\
s_mov_b32 s18, 0xcafe\n\
POLLSIGNAL:\n\
s_load_dword s16, s[0:1], 0x0 glc\n\
s_cmp_eq_i32 s16, s18\n\
s_cbranch_scc0 POLLSIGNAL\n\
s_load_dword s17, s[0:1], 0x4 glc\n\
s_waitcnt vmcnt(0) & lgkmcnt(0)\n\
s_store_dword s17, s[0:1], 0x8 glc\n\
s_waitcnt vmcnt(0) & lgkmcnt(0)\n\
s_endpgm\n\
end\n\
";
/* Input0: A buffer of at least 2 dwords.
* DW0: used as a signal. Write 0xcafe to signal
* DW1: Write to this buffer for other device to read.
@@ -155,6 +217,22 @@ type(CS)\n\
end\n\
";
const char* gfx10_WriteAndSignal =
"\
shader WriteAndSignal\n\
asic(GFX10)\n\
type(CS)\n\
/* Assume input buffer in s0, s1 */\n\
s_mov_b32 s18, 0xbeef\n\
s_store_dword s18, s[0:1], 0x4 glc\n\
s_mov_b32 s18, 0x1\n\
s_store_dword s18, s[2:3], 0 glc\n\
s_mov_b32 s18, 0xcafe\n\
s_store_dword s18, s[0:1], 0x0 glc\n\
s_endpgm\n\
end\n\
";
void KFDMemoryTest::SetUp() {
ROUTINE_START
@@ -259,8 +337,8 @@ TEST_F(KFDMemoryTest, MMapLarge) {
*/
TEST_F(KFDMemoryTest, MapUnmapToNodes) {
TEST_START(TESTPROFILE_RUNALL)
if (m_FamilyId != FAMILY_AI) {
LOG() << "Skipping test: GFX9-based shader not supported on other ASICs." << std::endl;
if (m_FamilyId < FAMILY_AI) {
LOG() << "Skipping test: Test requires gfx9 and later asics." << std::endl;
return;
}
@@ -286,7 +364,7 @@ TEST_F(KFDMemoryTest, MapUnmapToNodes) {
HsaMemoryBuffer srcBuffer(PAGE_SIZE, defaultGPUNode);
HsaMemoryBuffer dstBuffer(PAGE_SIZE, defaultGPUNode);
m_pIsaGen->CompileShader(gfx9_PollMemory, "ReadMemory", isaBuffer);
m_pIsaGen->CompileShader((m_FamilyId < FAMILY_NV) ? gfx9_PollMemory : gfx10_PollMemory, "ReadMemory", isaBuffer);
PM4Queue pm4Queue;
ASSERT_SUCCESS(pm4Queue.Create(defaultGPUNode));
@@ -623,9 +701,14 @@ TEST_F(KFDMemoryTest, FlatScratchAccess) {
// Initialize the srcBuffer to some fixed value
srcMemBuffer.Fill(0x01010101);
// Initialize a buffer with a dword copy ISA
m_pIsaGen->CompileShader((m_FamilyId >= FAMILY_AI) ? gfx9_ScratchCopyDword : gfx8_ScratchCopyDword,
"ScratchCopyDword", isaBuffer);
const char *pScratchCopyDword;
if (m_FamilyId < FAMILY_AI)
pScratchCopyDword = gfx8_ScratchCopyDword;
else if (m_FamilyId < FAMILY_NV)
pScratchCopyDword = gfx9_ScratchCopyDword;
else
pScratchCopyDword = gfx10_ScratchCopyDword;
m_pIsaGen->CompileShader(pScratchCopyDword, "ScratchCopyDword", isaBuffer);
const HsaNodeProperties *pNodeProperties = m_NodeInfo.GetNodeProperties(defaultGPUNode);
@@ -1520,8 +1603,16 @@ TEST_F(KFDMemoryTest, PtraceAccessInvisibleVram) {
HsaMemoryBuffer isaBuffer(PAGE_SIZE, defaultGPUNode, true/*zero*/, false/*local*/, true/*exec*/);
// dstBuffer is cpu accessible gtt memory
HsaMemoryBuffer dstBuffer(PAGE_SIZE, defaultGPUNode);
m_pIsaGen->CompileShader((m_FamilyId >= FAMILY_AI) ? gfx9_ScratchCopyDword : gfx8_ScratchCopyDword,
"ScratchCopyDword", isaBuffer);
const char *pScratchCopyDword;
if (m_FamilyId < FAMILY_AI)
pScratchCopyDword = gfx8_ScratchCopyDword;
else if (m_FamilyId < FAMILY_NV)
pScratchCopyDword = gfx9_ScratchCopyDword;
else
pScratchCopyDword = gfx10_ScratchCopyDword;
m_pIsaGen->CompileShader(pScratchCopyDword, "ScratchCopyDword", isaBuffer);
Dispatch dispatch0(isaBuffer);
dispatch0.SetArgs(mem0, dstBuffer.As<void*>());
dispatch0.Submit(queue);
@@ -1870,7 +1961,8 @@ TEST_F(KFDMemoryTest, HostHdpFlush) {
PM4Queue queue;
ASSERT_SUCCESS(queue.Create(defaultGPUNode));
HsaMemoryBuffer isaBuffer(PAGE_SIZE, defaultGPUNode, true/*zero*/, false/*local*/, true/*exec*/);
m_pIsaGen->CompileShader(gfx9_CopyOnSignal,"CopyOnSignal", isaBuffer);
m_pIsaGen->CompileShader((m_FamilyId < FAMILY_NV) ? gfx9_CopyOnSignal : gfx10_CopyOnSignal,
"CopyOnSignal", isaBuffer);
Dispatch dispatch0(isaBuffer);
dispatch0.SetArgs(buffer, NULL);
dispatch0.Submit(queue);
@@ -1989,7 +2081,8 @@ TEST_F(KFDMemoryTest, DeviceHdpFlush) {
PM4Queue queue;
ASSERT_SUCCESS(queue.Create(nodes[0]));
HsaMemoryBuffer isaBuffer(PAGE_SIZE, nodes[0], true/*zero*/, false/*local*/, true/*exec*/);
m_pIsaGen->CompileShader(gfx9_CopyOnSignal, "CopyOnSignal", isaBuffer);
m_pIsaGen->CompileShader((queue.GetFamilyId() < FAMILY_NV) ? gfx9_CopyOnSignal : gfx10_CopyOnSignal,
"CopyOnSignal", isaBuffer);
Dispatch dispatch(isaBuffer);
dispatch.SetArgs(buffer, NULL);
dispatch.Submit(queue);
@@ -1997,7 +2090,8 @@ TEST_F(KFDMemoryTest, DeviceHdpFlush) {
PM4Queue queue0;
ASSERT_SUCCESS(queue0.Create(nodes[1]));
HsaMemoryBuffer isaBuffer0(PAGE_SIZE, nodes[1], true/*zero*/, false/*local*/, true/*exec*/);
m_pIsaGen->CompileShader(gfx9_WriteAndSignal, "WriteAndSignal", isaBuffer0);
m_pIsaGen->CompileShader((queue0.GetFamilyId() < FAMILY_NV) ? gfx9_WriteAndSignal : gfx10_WriteAndSignal,
"WriteAndSignal", isaBuffer0);
Dispatch dispatch0(isaBuffer0);
dispatch0.SetArgs(buffer, mmioBase);
dispatch0.Submit(queue0);