|
9 | 9 | #include "shared/source/helpers/ptr_math.h" |
10 | 10 |
|
11 | 11 | #include "opencl/source/kernel/kernel.h" |
12 | | -#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" |
| 12 | +#include "opencl/test/unit_test/fixtures/multi_root_device_fixture.h" |
13 | 13 | #include "opencl/test/unit_test/mocks/mock_context.h" |
14 | 14 | #include "opencl/test/unit_test/mocks/mock_kernel.h" |
15 | 15 | #include "opencl/test/unit_test/mocks/mock_program.h" |
|
19 | 19 |
|
20 | 20 | using namespace NEO; |
21 | 21 |
|
22 | | -class KernelSlmArgTest : public Test<ClDeviceFixture> { |
| 22 | +class KernelSlmArgTest : public MultiRootDeviceWithSubDevicesFixture { |
23 | 23 | protected: |
24 | 24 | void SetUp() override { |
25 | | - ClDeviceFixture::SetUp(); |
26 | | - pKernelInfo = std::make_unique<KernelInfo>(); |
27 | | - pKernelInfo->kernelDescriptor.kernelAttributes.simdSize = 1; |
28 | | - |
29 | | - KernelArgPatchInfo kernelArgPatchInfo; |
30 | | - |
31 | | - pKernelInfo->kernelArgInfo.resize(3); |
32 | | - pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo); |
33 | | - pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo); |
34 | | - pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo); |
35 | | - |
36 | | - pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x10; |
37 | | - pKernelInfo->kernelArgInfo[0].slmAlignment = 0x1; |
38 | | - pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector[0].crossthreadOffset = 0x20; |
39 | | - pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector[0].size = sizeof(void *); |
40 | | - pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30; |
41 | | - pKernelInfo->kernelArgInfo[2].slmAlignment = 0x400; |
42 | | - pKernelInfo->workloadInfo.slmStaticSize = 3 * KB; |
43 | | - |
44 | | - program = std::make_unique<MockProgram>(toClDeviceVector(*pClDevice)); |
45 | | - pKernel = new MockKernel(program.get(), MockKernel::toKernelInfoContainer(*pKernelInfo, rootDeviceIndex)); |
| 25 | + MultiRootDeviceWithSubDevicesFixture::SetUp(); |
| 26 | + |
| 27 | + program = std::make_unique<MockProgram>(context.get(), false, context->getDevices()); |
| 28 | + KernelInfoContainer kernelInfos; |
| 29 | + kernelInfos.resize(3); |
| 30 | + for (auto &rootDeviceIndex : this->context->getRootDeviceIndices()) { |
| 31 | + |
| 32 | + pKernelInfo[rootDeviceIndex] = std::make_unique<KernelInfo>(); |
| 33 | + pKernelInfo[rootDeviceIndex]->kernelDescriptor.kernelAttributes.simdSize = 1; |
| 34 | + |
| 35 | + KernelArgPatchInfo kernelArgPatchInfo; |
| 36 | + |
| 37 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo.resize(3); |
| 38 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[1].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo); |
| 39 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[2].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo); |
| 40 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo); |
| 41 | + |
| 42 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x10; |
| 43 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[0].slmAlignment = 0x1; |
| 44 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[0].metadata.addressQualifier = KernelArgMetadata::AddrLocal; |
| 45 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[1].kernelArgPatchInfoVector[0].crossthreadOffset = 0x20; |
| 46 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[1].kernelArgPatchInfoVector[0].size = sizeof(void *); |
| 47 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[2].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30; |
| 48 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[2].slmAlignment = 0x400; |
| 49 | + pKernelInfo[rootDeviceIndex]->kernelArgInfo[2].metadata.addressQualifier = KernelArgMetadata::AddrLocal; |
| 50 | + pKernelInfo[rootDeviceIndex]->workloadInfo.slmStaticSize = 3 * KB; |
| 51 | + |
| 52 | + kernelInfos[rootDeviceIndex] = pKernelInfo[rootDeviceIndex].get(); |
| 53 | + } |
| 54 | + pKernel = new MockKernel(program.get(), kernelInfos); |
46 | 55 | ASSERT_EQ(CL_SUCCESS, pKernel->initialize()); |
47 | 56 |
|
48 | | - pKernel->setKernelArgHandler(0, &Kernel::setArgLocal); |
49 | | - pKernel->setKernelArgHandler(1, &Kernel::setArgImmediate); |
50 | | - pKernel->setKernelArgHandler(2, &Kernel::setArgLocal); |
51 | | - |
52 | | - uint32_t crossThreadData[0x40] = {}; |
53 | | - crossThreadData[0x20 / sizeof(uint32_t)] = 0x12344321; |
54 | | - pKernel->setCrossThreadData(crossThreadData, sizeof(crossThreadData)); |
| 57 | + for (auto &rootDeviceIndex : this->context->getRootDeviceIndices()) { |
| 58 | + crossThreadData[rootDeviceIndex][0x20 / sizeof(uint32_t)] = 0x12344321; |
| 59 | + pKernel->setCrossThreadDataForRootDeviceIndex(rootDeviceIndex, &crossThreadData[rootDeviceIndex], sizeof(crossThreadData[rootDeviceIndex])); |
| 60 | + } |
55 | 61 | } |
56 | 62 |
|
57 | 63 | void TearDown() override { |
58 | 64 | delete pKernel; |
59 | 65 |
|
60 | | - ClDeviceFixture::TearDown(); |
| 66 | + MultiRootDeviceWithSubDevicesFixture::TearDown(); |
61 | 67 | } |
62 | 68 |
|
63 | 69 | cl_int retVal = CL_SUCCESS; |
64 | 70 | std::unique_ptr<MockProgram> program; |
65 | 71 | MockKernel *pKernel = nullptr; |
66 | | - std::unique_ptr<KernelInfo> pKernelInfo; |
| 72 | + std::unique_ptr<KernelInfo> pKernelInfo[3]; |
67 | 73 |
|
68 | 74 | static const size_t slmSize0 = 0x200; |
69 | 75 | static const size_t slmSize2 = 0x30; |
| 76 | + uint32_t crossThreadData[3][0x40]{}; |
70 | 77 | }; |
71 | 78 |
|
72 | 79 | TEST_F(KernelSlmArgTest, WhenSettingSizeThenAlignmentOfHigherSlmArgsIsUpdated) { |
73 | 80 | pKernel->setArg(0, slmSize0, nullptr); |
74 | 81 | pKernel->setArg(2, slmSize2, nullptr); |
75 | 82 |
|
76 | | - auto crossThreadData = reinterpret_cast<uint32_t *>(pKernel->getCrossThreadData(rootDeviceIndex)); |
77 | | - auto slmOffset = ptrOffset(crossThreadData, 0x10); |
78 | | - EXPECT_EQ(0u, *slmOffset); |
| 83 | + for (auto &rootDeviceIndex : this->context->getRootDeviceIndices()) { |
| 84 | + auto crossThreadData = reinterpret_cast<uint32_t *>(pKernel->getCrossThreadData(rootDeviceIndex)); |
| 85 | + auto slmOffset = ptrOffset(crossThreadData, 0x10); |
| 86 | + EXPECT_EQ(0u, *slmOffset); |
79 | 87 |
|
80 | | - slmOffset = ptrOffset(crossThreadData, 0x20); |
81 | | - EXPECT_EQ(0x12344321u, *slmOffset); |
| 88 | + slmOffset = ptrOffset(crossThreadData, 0x20); |
| 89 | + EXPECT_EQ(0x12344321u, *slmOffset); |
82 | 90 |
|
83 | | - slmOffset = ptrOffset(crossThreadData, 0x30); |
84 | | - EXPECT_EQ(0x400u, *slmOffset); |
| 91 | + slmOffset = ptrOffset(crossThreadData, 0x30); |
| 92 | + EXPECT_EQ(0x400u, *slmOffset); |
85 | 93 |
|
86 | | - EXPECT_EQ(5 * KB, pKernel->kernelDeviceInfos[rootDeviceIndex].slmTotalSize); |
| 94 | + EXPECT_EQ(5 * KB, pKernel->kernelDeviceInfos[rootDeviceIndex].slmTotalSize); |
| 95 | + } |
87 | 96 | } |
88 | 97 |
|
89 | 98 | TEST_F(KernelSlmArgTest, GivenReverseOrderWhenSettingSizeThenAlignmentOfHigherSlmArgsIsUpdated) { |
90 | 99 | pKernel->setArg(2, slmSize2, nullptr); |
91 | 100 | pKernel->setArg(0, slmSize0, nullptr); |
92 | 101 |
|
93 | | - auto crossThreadData = reinterpret_cast<uint32_t *>(pKernel->getCrossThreadData(rootDeviceIndex)); |
94 | | - auto slmOffset = ptrOffset(crossThreadData, 0x10); |
95 | | - EXPECT_EQ(0u, *slmOffset); |
| 102 | + for (auto &rootDeviceIndex : this->context->getRootDeviceIndices()) { |
| 103 | + auto crossThreadData = reinterpret_cast<uint32_t *>(pKernel->getCrossThreadData(rootDeviceIndex)); |
| 104 | + auto slmOffset = ptrOffset(crossThreadData, 0x10); |
| 105 | + EXPECT_EQ(0u, *slmOffset); |
96 | 106 |
|
97 | | - slmOffset = ptrOffset(crossThreadData, 0x20); |
98 | | - EXPECT_EQ(0x12344321u, *slmOffset); |
| 107 | + slmOffset = ptrOffset(crossThreadData, 0x20); |
| 108 | + EXPECT_EQ(0x12344321u, *slmOffset); |
99 | 109 |
|
100 | | - slmOffset = ptrOffset(crossThreadData, 0x30); |
101 | | - EXPECT_EQ(0x400u, *slmOffset); |
| 110 | + slmOffset = ptrOffset(crossThreadData, 0x30); |
| 111 | + EXPECT_EQ(0x400u, *slmOffset); |
102 | 112 |
|
103 | | - EXPECT_EQ(5 * KB, pKernel->kernelDeviceInfos[rootDeviceIndex].slmTotalSize); |
| 113 | + EXPECT_EQ(5 * KB, pKernel->kernelDeviceInfos[rootDeviceIndex].slmTotalSize); |
| 114 | + } |
104 | 115 | } |
0 commit comments