diff --git a/projects/rocr-runtime/tests/kfdtest/CMakeLists.txt b/projects/rocr-runtime/tests/kfdtest/CMakeLists.txt index 63627ef04b..6c12039143 100644 --- a/projects/rocr-runtime/tests/kfdtest/CMakeLists.txt +++ b/projects/rocr-runtime/tests/kfdtest/CMakeLists.txt @@ -109,6 +109,7 @@ set (SRC_FILES gtest-1.6.0/gtest-all.cpp src/GoogleTestExtension.cpp src/IndirectBuffer.cpp src/IsaGenerator.cpp + src/IsaGenerator_Aldebaran.cpp src/IsaGenerator_Gfx10.cpp src/IsaGenerator_Gfx72.cpp src/IsaGenerator_Gfx8.cpp diff --git a/projects/rocr-runtime/tests/kfdtest/sp3/sp3.h b/projects/rocr-runtime/tests/kfdtest/sp3/sp3.h index d6235be5d8..e44ee406cf 100644 --- a/projects/rocr-runtime/tests/kfdtest/sp3/sp3.h +++ b/projects/rocr-runtime/tests/kfdtest/sp3/sp3.h @@ -108,9 +108,11 @@ struct sp3_shader { uint32_t nsgprs; ///< Number of scalar GPRs used. uint32_t nvgprs; ///< Number of vector GPRs used. uint32_t nsvgprs; ///< Number of shared vector GPRs used. + uint32_t naccvgprs; ///< Number of accumulator vector GPRs used (only available in certain projects). uint32_t nsgprs_manual_alloc; uint32_t nvgprs_manual_alloc; uint32_t nsvgprs_manual_alloc; + uint32_t naccvgprs_manual_alloc; uint32_t trap_present; uint32_t user_sgpr_count; uint32_t scratch_en; diff --git a/projects/rocr-runtime/tests/kfdtest/src/IsaGenerator.cpp b/projects/rocr-runtime/tests/kfdtest/src/IsaGenerator.cpp index 3534e02159..3e69b5f9df 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/IsaGenerator.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/IsaGenerator.cpp @@ -30,6 +30,7 @@ #include "IsaGenerator_Gfx8.hpp" #include "IsaGenerator_Gfx9.hpp" #include "IsaGenerator_Gfx10.hpp" +#include "IsaGenerator_Aldebaran.hpp" #include "GoogleTestExtension.hpp" @@ -92,8 +93,9 @@ IsaGenerator* IsaGenerator::Create(unsigned int familyId) { case FAMILY_AI: case FAMILY_RV: case FAMILY_AR: - case FAMILY_AL: return new IsaGenerator_Gfx9; + case FAMILY_AL: + return new IsaGenerator_Aldbrn; case FAMILY_NV: return new IsaGenerator_Gfx10; diff --git a/projects/rocr-runtime/tests/kfdtest/src/IsaGenerator_Aldebaran.cpp b/projects/rocr-runtime/tests/kfdtest/src/IsaGenerator_Aldebaran.cpp new file mode 100644 index 0000000000..2fcb80fd32 --- /dev/null +++ b/projects/rocr-runtime/tests/kfdtest/src/IsaGenerator_Aldebaran.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2020 Advanced Micro Devices, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include "IsaGenerator_Aldebaran.hpp" + +#include +#include + +const std::string IsaGenerator_Aldbrn::ASIC_NAME = "ALDEBARAN"; + +/* The binaries are generated from following ISA */ +#if 0 +/* flat_atomic_inc will not support by some PCIE, use flat_atomic_add instead */ +shader atomic_add +asic(ALDEBARAN) +type(CS) + v_mov_b32 v0, s0 + v_mov_b32 v1, s1 + v_mov_b32 v2, 1 + flat_atomic_add v3, v[0:1], v2 slc glc + s_waitcnt 0 + s_endpgm +end + +shader copy_dword +asic(ALDEBARAN) +type(CS) +/* copy the parameters from scalar registers to vector registers */ + v_mov_b32 v0, s0 + v_mov_b32 v1, s1 + v_mov_b32 v2, s2 + v_mov_b32 v3, s3 +/* copy a dword between the passed addresses */ + flat_load_dword v4, v[0:1] slc glc + s_waitcnt 0 + flat_store_dword v[2:3], v4 slc glc + s_endpgm +end + +shader main +asic(ALDEBARAN) +type(CS) +loop: + s_branch loop + s_endpgm +end + + +#endif + +const uint32_t IsaGenerator_Aldbrn::NOOP_ISA[] = { + 0xbf810000 +}; + +const uint32_t IsaGenerator_Aldbrn::COPY_DWORD_ISA[] = { + 0x7e000200, 0x7e020201, + 0x7e040202, 0x7e060203, + 0xdc530000, 0x047f0000, + 0xbf8c0000, 0xdc730000, + 0x007f0402, 0xbf810000 +}; + +const uint32_t IsaGenerator_Aldbrn::INFINITE_LOOP_ISA[] = { + 0xbf82ffff, 0xbf810000 +}; + +const uint32_t IsaGenerator_Aldbrn::ATOMIC_ADD_ISA[] = { + 0x7e000200, 0x7e020201, + 0x7e040281, 0xdd0b0000, + 0x037f0200, 0xbf8c0000, + 0xbf810000, 0x00000000 +}; + +void IsaGenerator_Aldbrn::GetNoopIsa(HsaMemoryBuffer& rBuf) { + std::copy(NOOP_ISA, NOOP_ISA+ARRAY_SIZE(NOOP_ISA), rBuf.As()); +} + +void IsaGenerator_Aldbrn::GetCopyDwordIsa(HsaMemoryBuffer& rBuf) { + std::copy(COPY_DWORD_ISA, COPY_DWORD_ISA+ARRAY_SIZE(COPY_DWORD_ISA), rBuf.As()); +} + +void IsaGenerator_Aldbrn::GetInfiniteLoopIsa(HsaMemoryBuffer& rBuf) { + std::copy(INFINITE_LOOP_ISA, INFINITE_LOOP_ISA+ARRAY_SIZE(INFINITE_LOOP_ISA), rBuf.As()); +} + +void IsaGenerator_Aldbrn::GetAtomicIncIsa(HsaMemoryBuffer& rBuf) { + std::copy(ATOMIC_ADD_ISA, ATOMIC_ADD_ISA+ARRAY_SIZE(ATOMIC_ADD_ISA), rBuf.As()); +} + +const std::string& IsaGenerator_Aldbrn::GetAsicName() { + return ASIC_NAME; +} + diff --git a/projects/rocr-runtime/tests/kfdtest/src/IsaGenerator_Aldebaran.hpp b/projects/rocr-runtime/tests/kfdtest/src/IsaGenerator_Aldebaran.hpp new file mode 100644 index 0000000000..5571b91c26 --- /dev/null +++ b/projects/rocr-runtime/tests/kfdtest/src/IsaGenerator_Aldebaran.hpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2020 Advanced Micro Devices, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef _ISAGENERATOR_ALDEBARAN_H_ +#define _ISAGENERATOR_ALDEBARAN_H_ + +#include +#include "IsaGenerator.hpp" + +class IsaGenerator_Aldbrn : public IsaGenerator { + public: + virtual void GetNoopIsa(HsaMemoryBuffer& rBuf); + virtual void GetCopyDwordIsa(HsaMemoryBuffer& rBuf); + virtual void GetInfiniteLoopIsa(HsaMemoryBuffer& rBuf); + virtual void GetAtomicIncIsa(HsaMemoryBuffer& rBuf); + + protected: + virtual const std::string& GetAsicName(); + + private: + static const std::string ASIC_NAME; + + static const uint32_t NOOP_ISA[]; + static const uint32_t COPY_DWORD_ISA[]; + static const uint32_t INFINITE_LOOP_ISA[]; + static const uint32_t ATOMIC_ADD_ISA[]; +}; + +#endif // _ISAGENERATOR_ALDEBARAN_H_ diff --git a/projects/rocr-runtime/tests/kfdtest/src/KFDMemoryTest.cpp b/projects/rocr-runtime/tests/kfdtest/src/KFDMemoryTest.cpp index aa816b84e4..c5c0c0afde 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/KFDMemoryTest.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/KFDMemoryTest.cpp @@ -108,6 +108,29 @@ wave_size(32)\n\ end\n\ "; +const char* aldbrn_ScratchCopyDword = +"\ +shader ScratchCopyDword\n\ +asic(ALDEBARAN)\n\ +type(CS)\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_mov_b32 flat_scratch_lo, s4\n\ + s_mov_b32 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 @@ -650,8 +673,10 @@ TEST_F(KFDMemoryTest, FlatScratchAccess) { const char *pScratchCopyDword; if (m_FamilyId < FAMILY_AI) pScratchCopyDword = gfx8_ScratchCopyDword; - else if (m_FamilyId < FAMILY_NV) + else if (m_FamilyId < FAMILY_AL) pScratchCopyDword = gfx9_ScratchCopyDword; + else if (m_FamilyId == FAMILY_AL) + pScratchCopyDword = aldbrn_ScratchCopyDword; else pScratchCopyDword = gfx10_ScratchCopyDword; m_pIsaGen->CompileShader(pScratchCopyDword, "ScratchCopyDword", isaBuffer); @@ -1508,8 +1533,10 @@ TEST_F(KFDMemoryTest, PtraceAccessInvisibleVram) { const char *pScratchCopyDword; if (m_FamilyId < FAMILY_AI) pScratchCopyDword = gfx8_ScratchCopyDword; - else if (m_FamilyId < FAMILY_NV) + else if (m_FamilyId < FAMILY_AL) pScratchCopyDword = gfx9_ScratchCopyDword; + else if (m_FamilyId == FAMILY_AL) + pScratchCopyDword = aldbrn_ScratchCopyDword; else pScratchCopyDword = gfx10_ScratchCopyDword;