From e0e0485579c11aca1f453f2f8c9c11e903989968 Mon Sep 17 00:00:00 2001 From: Graham Sider Date: Tue, 2 Nov 2021 14:04:48 -0400 Subject: [PATCH] kfdtest: Move KFDGWSTest shaders to ShaderStore Signed-off-by: Graham Sider Change-Id: I9608b8bea32d64d4d0e1a329191f9a62e3a771e7 [ROCm/ROCR-Runtime commit: b2b54dffe6886cef1c7126f92a7808f0c1a6aac4] --- .../tests/kfdtest/src/KFDGWSTest.cpp | 66 +------------------ .../tests/kfdtest/src/ShaderStore.cpp | 56 ++++++++++++++++ .../tests/kfdtest/src/ShaderStore.hpp | 4 ++ 3 files changed, 62 insertions(+), 64 deletions(-) diff --git a/projects/rocr-runtime/tests/kfdtest/src/KFDGWSTest.cpp b/projects/rocr-runtime/tests/kfdtest/src/KFDGWSTest.cpp index a6b3bec17b..99e9248d8f 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/KFDGWSTest.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/KFDGWSTest.cpp @@ -26,62 +26,6 @@ #include "PM4Packet.hpp" #include "Dispatch.hpp" -/* Shader to initialize gws counter to 1 */ -static const char* GwsInitIsa_gfx9_10 = R"( - .text - s_mov_b32 m0, 0 - s_nop 0 - s_load_dword s16, s[0:1], 0x0 glc - s_waitcnt 0 - v_mov_b32 v0, s16 - s_waitcnt 0 - ds_gws_init v0 offset:0 gds - s_waitcnt 0 - s_endpgm -)"; - -/* Atomically increase a value in memory - * This is expected to be executed from - * multiple work groups simultaneously. - * GWS semaphore is used to guarantee - * the operation is atomic. - */ -static const char* AtomicIncreaseIsa_gfx9 = R"( - .text - // Assume src address in s0, s1 - s_mov_b32 m0, 0 - s_nop 0 - ds_gws_sema_p offset:0 gds - s_waitcnt 0 - s_load_dword s16, s[0:1], 0x0 glc - s_waitcnt 0 - s_add_u32 s16, s16, 1 - s_store_dword s16, s[0:1], 0x0 glc - s_waitcnt lgkmcnt(0) - ds_gws_sema_v offset:0 gds - s_waitcnt 0 - s_endpgm -)"; - -static const char* AtomicIncreaseIsa_gfx10 = R"( - .text - // Assume src address in s0, s1 - s_mov_b32 m0, 0 - s_mov_b32 exec_lo, 0x1 - v_mov_b32 v0, s0 - v_mov_b32 v1, s1 - ds_gws_sema_p offset:0 gds - s_waitcnt 0 - flat_load_dword v2, v[0:1] glc dlc - s_waitcnt 0 - v_add_nc_u32 v2, v2, 1 - flat_store_dword v[0:1], v2 - s_waitcnt_vscnt null, 0 - ds_gws_sema_v offset:0 gds - s_waitcnt 0 - s_endpgm -)"; - void KFDGWSTest::SetUp() { ROUTINE_START @@ -142,7 +86,7 @@ TEST_F(KFDGWSTest, Semaphore) { pNodeProperties->NumGws,&firstGWS)); EXPECT_EQ(0, firstGWS); - ASSERT_SUCCESS(m_pAsm->RunAssembleBuf(GwsInitIsa_gfx9_10, isaBuffer.As())); + ASSERT_SUCCESS(m_pAsm->RunAssembleBuf(GwsInitIsa, isaBuffer.As())); Dispatch dispatch0(isaBuffer); buffer.Fill(numResources, 0, 4); @@ -150,13 +94,7 @@ TEST_F(KFDGWSTest, Semaphore) { dispatch0.Submit(queue); dispatch0.Sync(); - const char *pAtomicIncreaseIsa; - if (m_FamilyId <= FAMILY_AL) - pAtomicIncreaseIsa = AtomicIncreaseIsa_gfx9; - else - pAtomicIncreaseIsa = AtomicIncreaseIsa_gfx10; - - ASSERT_SUCCESS(m_pAsm->RunAssembleBuf(pAtomicIncreaseIsa, isaBuffer.As())); + ASSERT_SUCCESS(m_pAsm->RunAssembleBuf(GwsAtomicIncreaseIsa, isaBuffer.As())); Dispatch dispatch(isaBuffer); dispatch.SetArgs(buffer.As(), NULL); diff --git a/projects/rocr-runtime/tests/kfdtest/src/ShaderStore.cpp b/projects/rocr-runtime/tests/kfdtest/src/ShaderStore.cpp index fdf536b4db..e720d4b8ce 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/ShaderStore.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/ShaderStore.cpp @@ -542,3 +542,59 @@ const char *ReadMemoryIsa = R"( s_waitcnt vmcnt(0) & lgkmcnt(0) // wait for memory writes to finish s_endpgm )"; + +/** + * KFDGWSTest + */ + +/* Shader to initialize gws counter to 1 */ +const char *GwsInitIsa = R"( + .text + s_mov_b32 m0, 0 + s_nop 0 + s_load_dword s16, s[0:1], 0x0 glc + s_waitcnt 0 + v_mov_b32 v0, s16 + s_waitcnt 0 + ds_gws_init v0 offset:0 gds + s_waitcnt 0 + s_endpgm +)"; + +/* Atomically increase a value in memory + * This is expected to be executed from + * multiple work groups simultaneously. + * GWS semaphore is used to guarantee + * the operation is atomic. + */ +const char *GwsAtomicIncreaseIsa = R"( + .text + // Assume src address in s0, s1 + .if (.amdgcn.gfx_generation_number >= 10) + s_mov_b32 m0, 0 + s_mov_b32 exec_lo, 0x1 + v_mov_b32 v0, s0 + v_mov_b32 v1, s1 + ds_gws_sema_p offset:0 gds + s_waitcnt 0 + flat_load_dword v2, v[0:1] glc dlc + s_waitcnt 0 + v_add_nc_u32 v2, v2, 1 + flat_store_dword v[0:1], v2 + s_waitcnt_vscnt null, 0 + ds_gws_sema_v offset:0 gds + .else + s_mov_b32 m0, 0 + s_nop 0 + ds_gws_sema_p offset:0 gds + s_waitcnt 0 + s_load_dword s16, s[0:1], 0x0 glc + s_waitcnt 0 + s_add_u32 s16, s16, 1 + s_store_dword s16, s[0:1], 0x0 glc + s_waitcnt lgkmcnt(0) + ds_gws_sema_v offset:0 gds + .endif + s_waitcnt 0 + s_endpgm +)"; diff --git a/projects/rocr-runtime/tests/kfdtest/src/ShaderStore.hpp b/projects/rocr-runtime/tests/kfdtest/src/ShaderStore.hpp index de73034ee4..231e7f73d6 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/ShaderStore.hpp +++ b/projects/rocr-runtime/tests/kfdtest/src/ShaderStore.hpp @@ -48,4 +48,8 @@ extern const char *IterateIsa; /* KFDEvictTest */ extern const char *ReadMemoryIsa; +/* KFDGWSTest */ +extern const char *GwsInitIsa; +extern const char *GwsAtomicIncreaseIsa; + #endif // _SHADERSTORE_H_