Skip to content

Commit e379249

Browse files
Add platform specific aub tests
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
1 parent c546333 commit e379249

12 files changed

+1773
-1
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#
2-
# Copyright (C) 2021 Intel Corporation
2+
# Copyright (C) 2022 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
66

77
if(TESTS_XE_HP_CORE)
88
target_sources(igdrcl_aub_tests PRIVATE
99
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
${CMAKE_CURRENT_SOURCE_DIR}/aub_mem_dump_tests_xe_hp_core.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}/aub_tests_stateless_compression_in_sba_xe_hp_core.cpp
1012
)
1113
add_subdirectories()
1214
endif()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/test/common/helpers/debug_manager_state_restore.h"
9+
#include "shared/test/common/helpers/ult_hw_config.h"
10+
#include "shared/test/common/helpers/variable_backup.h"
11+
12+
#include "opencl/test/unit_test/aub_tests/command_stream/aub_mem_dump_tests.h"
13+
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
14+
15+
namespace NEO {
16+
extern bool overrideCommandStreamReceiverCreation;
17+
using XeHpCoreAubMemDumpTests = Test<ClDeviceFixture>;
18+
19+
XE_HP_CORE_TEST_F(XeHpCoreAubMemDumpTests, GivenCcsThenExpectationsAreMet) {
20+
setupAUB<FamilyType>(pDevice, aub_stream::ENGINE_CCS);
21+
}
22+
23+
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCoreAubMemDumpTests, whenAubCsrIsCreatedThenCreateHardwareContext) {
24+
DebugManagerStateRestore restore;
25+
VariableBackup<UltHwConfig> backup(&ultHwConfig);
26+
ultHwConfig.useHwCsr = true;
27+
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB);
28+
29+
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
30+
31+
auto &baseCsr = device->getGpgpuCommandStreamReceiver();
32+
auto &aubCsr = static_cast<AUBCommandStreamReceiverHw<FamilyType> &>(baseCsr);
33+
34+
EXPECT_NE(nullptr, aubCsr.hardwareContextController.get());
35+
EXPECT_NE(0u, aubCsr.hardwareContextController->hardwareContexts.size());
36+
}
37+
} // namespace NEO

opencl/test/unit_test/aub_tests/xe_hp_core/aub_tests_stateless_compression_in_sba_xe_hp_core.cpp

Lines changed: 572 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Copyright (C) 2022 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(TESTS_XE_HPC_CORE)
8+
target_sources(igdrcl_aub_tests PRIVATE
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
${CMAKE_CURRENT_SOURCE_DIR}/aub_mem_dump_tests_xe_hpc_core.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_kernel_aub_tests_xe_hpc_core.cpp
12+
${CMAKE_CURRENT_SOURCE_DIR}/system_memfence_aub_tests_xe_hpc_core.cpp
13+
${CMAKE_CURRENT_SOURCE_DIR}/um_stateless_compression_aub_tests_xe_hpc_core.cpp
14+
${CMAKE_CURRENT_SOURCE_DIR}/aub_test_excludes_xe_hpc_core.cpp
15+
)
16+
add_subdirectories()
17+
endif()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "opencl/test/unit_test/aub_tests/command_stream/aub_mem_dump_tests.h"
9+
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
10+
11+
using XeHpcCoreAubMemDumpTests = Test<NEO::ClDeviceFixture>;
12+
13+
XE_HPC_CORETEST_F(XeHpcCoreAubMemDumpTests, GivenCcsThenExpectationsAreMet) {
14+
setupAUB<FamilyType>(pDevice, aub_stream::ENGINE_CCS);
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/test/common/test_macros/test.h"
9+
10+
HWTEST_EXCLUDE_PRODUCT(MiAtomicAubTest, GivenSystemMemoryWhenDispatchingAtomicMove4BytesOperationThenExpectCorrectEndValues, IGFX_XE_HPC_CORE);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/test/common/helpers/debug_manager_state_restore.h"
9+
#include "shared/test/common/test_macros/test.h"
10+
11+
#include "opencl/source/command_queue/command_queue.h"
12+
#include "opencl/source/mem_obj/buffer.h"
13+
#include "opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h"
14+
#include "opencl/test/unit_test/fixtures/simple_arg_fixture.h"
15+
16+
using namespace NEO;
17+
18+
extern const HardwareInfo *defaultHwInfo;
19+
20+
using AUBSimpleKernelStatelessTest = Test<KernelAUBFixture<SimpleKernelStatelessFixture>>;
21+
22+
HWTEST_F(AUBSimpleKernelStatelessTest, givenPrefetchEnabledWhenEnqueuedKernelThenDataIsCorrect) {
23+
DebugManagerStateRestore restore;
24+
DebugManager.flags.EnableMemoryPrefetch.set(1);
25+
26+
constexpr size_t bufferSize = MemoryConstants::pageSize;
27+
28+
cl_uint workDim = 1;
29+
size_t globalWorkOffset[3] = {0, 0, 0};
30+
size_t globalWorkSize[3] = {bufferSize, 1, 1};
31+
size_t localWorkSize[3] = {1, 1, 1};
32+
33+
uint8_t bufferData[bufferSize] = {};
34+
uint8_t bufferExpected[bufferSize];
35+
memset(bufferExpected, 0xCD, bufferSize);
36+
37+
auto buffer = std::unique_ptr<Buffer>(Buffer::create(context, CL_MEM_USE_HOST_PTR | CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL,
38+
bufferSize, bufferData, retVal));
39+
ASSERT_NE(nullptr, buffer);
40+
41+
kernel->setArg(0, buffer.get());
42+
43+
retVal = this->pCmdQ->enqueueKernel(kernel.get(), workDim, globalWorkOffset, globalWorkSize,
44+
localWorkSize, 0, nullptr, nullptr);
45+
46+
this->pCmdQ->flush();
47+
expectMemory<FamilyType>(reinterpret_cast<void *>(buffer->getGraphicsAllocation(rootDeviceIndex)->getGpuAddress()),
48+
bufferExpected, bufferSize);
49+
}
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/test/common/helpers/debug_manager_state_restore.h"
9+
#include "shared/test/common/test_macros/test.h"
10+
#include "shared/test/unit_test/utilities/base_object_utils.h"
11+
12+
#include "opencl/source/api/api.h"
13+
#include "opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h"
14+
#include "opencl/test/unit_test/aub_tests/fixtures/multicontext_aub_fixture.h"
15+
#include "opencl/test/unit_test/fixtures/program_fixture.h"
16+
#include "opencl/test/unit_test/mocks/mock_kernel.h"
17+
18+
using namespace NEO;
19+
20+
class SystemMemFenceViaMiMemFence : public AUBFixture,
21+
public ::testing::Test {
22+
public:
23+
void SetUp() override {
24+
DebugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(1);
25+
DebugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
26+
DebugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
27+
AUBFixture::SetUp(defaultHwInfo.get());
28+
}
29+
void TearDown() override {
30+
AUBFixture::TearDown();
31+
}
32+
33+
DebugManagerStateRestore debugRestorer;
34+
cl_int retVal = CL_SUCCESS;
35+
};
36+
37+
XE_HPC_CORETEST_F(SystemMemFenceViaMiMemFence, givenSystemMemFenceWhenGeneratedAsMiMemFenceCommandInCommandStreamThenWritesToSystemMemoryAreGloballyObservable) {
38+
const size_t bufferSize = MemoryConstants::kiloByte;
39+
std::vector<char> buffer(bufferSize, 0x11);
40+
41+
auto deviceMemAlloc = clDeviceMemAllocINTEL(this->context, this->device.get(), nullptr, bufferSize, 0, &retVal);
42+
EXPECT_EQ(CL_SUCCESS, retVal);
43+
ASSERT_NE(nullptr, deviceMemAlloc);
44+
45+
retVal = clEnqueueMemcpyINTEL(this->pCmdQ, true, deviceMemAlloc, buffer.data(), bufferSize, 0, nullptr, nullptr);
46+
EXPECT_EQ(CL_SUCCESS, retVal);
47+
48+
expectMemory<FamilyType>(deviceMemAlloc, buffer.data(), bufferSize);
49+
50+
auto hostMemAlloc = clHostMemAllocINTEL(this->context, nullptr, bufferSize, 0, &retVal);
51+
EXPECT_EQ(CL_SUCCESS, retVal);
52+
ASSERT_NE(nullptr, hostMemAlloc);
53+
54+
retVal = clEnqueueMemcpyINTEL(this->pCmdQ, true, hostMemAlloc, deviceMemAlloc, bufferSize, 0, nullptr, nullptr);
55+
EXPECT_EQ(CL_SUCCESS, retVal);
56+
57+
expectMemory<FamilyType>(hostMemAlloc, buffer.data(), bufferSize);
58+
59+
retVal = clMemFreeINTEL(this->context, deviceMemAlloc);
60+
EXPECT_EQ(CL_SUCCESS, retVal);
61+
62+
retVal = clMemFreeINTEL(this->context, hostMemAlloc);
63+
EXPECT_EQ(CL_SUCCESS, retVal);
64+
}
65+
66+
class SystemMemFenceViaComputeWalker : public AUBFixture,
67+
public ::testing::Test {
68+
public:
69+
void SetUp() override {
70+
DebugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0);
71+
DebugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(1);
72+
DebugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
73+
AUBFixture::SetUp(defaultHwInfo.get());
74+
}
75+
void TearDown() override {
76+
AUBFixture::TearDown();
77+
}
78+
79+
DebugManagerStateRestore debugRestorer;
80+
cl_int retVal = CL_SUCCESS;
81+
};
82+
83+
XE_HPC_CORETEST_F(SystemMemFenceViaComputeWalker, givenSystemMemFenceWhenGeneratedAsPostSyncOperationInWalkerThenWritesToSystemMemoryAreGloballyObservable) {
84+
const size_t bufferSize = MemoryConstants::kiloByte;
85+
std::vector<char> buffer(bufferSize, 0x11);
86+
87+
auto deviceMemAlloc = clDeviceMemAllocINTEL(this->context, this->device.get(), nullptr, bufferSize, 0, &retVal);
88+
EXPECT_EQ(CL_SUCCESS, retVal);
89+
ASSERT_NE(nullptr, deviceMemAlloc);
90+
91+
retVal = clEnqueueMemcpyINTEL(this->pCmdQ, true, deviceMemAlloc, buffer.data(), bufferSize, 0, nullptr, nullptr);
92+
EXPECT_EQ(CL_SUCCESS, retVal);
93+
94+
expectMemory<FamilyType>(deviceMemAlloc, buffer.data(), bufferSize);
95+
96+
auto hostMemAlloc = clHostMemAllocINTEL(this->context, nullptr, bufferSize, 0, &retVal);
97+
EXPECT_EQ(CL_SUCCESS, retVal);
98+
ASSERT_NE(nullptr, hostMemAlloc);
99+
100+
retVal = clEnqueueMemcpyINTEL(this->pCmdQ, true, hostMemAlloc, deviceMemAlloc, bufferSize, 0, nullptr, nullptr);
101+
EXPECT_EQ(CL_SUCCESS, retVal);
102+
103+
expectMemory<FamilyType>(hostMemAlloc, buffer.data(), bufferSize);
104+
105+
retVal = clMemFreeINTEL(this->context, deviceMemAlloc);
106+
EXPECT_EQ(CL_SUCCESS, retVal);
107+
108+
retVal = clMemFreeINTEL(this->context, hostMemAlloc);
109+
EXPECT_EQ(CL_SUCCESS, retVal);
110+
}
111+
112+
class SystemMemFenceWithBlitter : public MulticontextAubFixture,
113+
public ::testing::Test {
114+
public:
115+
void SetUp() override {
116+
DebugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(1);
117+
DebugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
118+
DebugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
119+
120+
DebugManager.flags.EnableBlitterOperationsSupport.set(1);
121+
DebugManager.flags.EnableBlitterForEnqueueOperations.set(1);
122+
123+
MulticontextAubFixture::SetUp(1, EnabledCommandStreamers::Single, true);
124+
}
125+
void TearDown() override {
126+
MulticontextAubFixture::TearDown();
127+
}
128+
129+
DebugManagerStateRestore debugRestorer;
130+
cl_int retVal = CL_SUCCESS;
131+
};
132+
133+
XE_HPC_CORETEST_F(SystemMemFenceWithBlitter, givenSystemMemFenceWhenGeneratedAsMiMemFenceCmdInBCSThenWritesToSystemMemoryAreGloballyObservable) {
134+
const size_t bufferSize = MemoryConstants::kiloByte;
135+
std::vector<char> buffer(bufferSize, 0x11);
136+
137+
auto deviceMemAlloc = clDeviceMemAllocINTEL(context.get(), tileDevices[0], nullptr, bufferSize, 0, &retVal);
138+
EXPECT_EQ(CL_SUCCESS, retVal);
139+
ASSERT_NE(nullptr, deviceMemAlloc);
140+
141+
retVal = clEnqueueMemcpyINTEL(commandQueues[0][0].get(), true, deviceMemAlloc, buffer.data(), bufferSize, 0, nullptr, nullptr);
142+
EXPECT_EQ(CL_SUCCESS, retVal);
143+
144+
expectMemory<FamilyType>(deviceMemAlloc, buffer.data(), bufferSize, 0, 0);
145+
146+
auto hostMemAlloc = clHostMemAllocINTEL(context.get(), nullptr, bufferSize, 0, &retVal);
147+
EXPECT_EQ(CL_SUCCESS, retVal);
148+
ASSERT_NE(nullptr, hostMemAlloc);
149+
150+
retVal = clEnqueueMemcpyINTEL(commandQueues[0][0].get(), true, hostMemAlloc, deviceMemAlloc, bufferSize, 0, nullptr, nullptr);
151+
EXPECT_EQ(CL_SUCCESS, retVal);
152+
153+
expectMemory<FamilyType>(hostMemAlloc, buffer.data(), bufferSize, 0, 0);
154+
155+
retVal = clMemFreeINTEL(context.get(), deviceMemAlloc);
156+
EXPECT_EQ(CL_SUCCESS, retVal);
157+
158+
retVal = clMemFreeINTEL(context.get(), hostMemAlloc);
159+
EXPECT_EQ(CL_SUCCESS, retVal);
160+
}
161+
162+
class SystemMemFenceViaKernelInstruction : public ProgramFixture,
163+
public MulticontextAubFixture,
164+
public ::testing::Test {
165+
public:
166+
void SetUp() override {
167+
DebugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0);
168+
DebugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
169+
DebugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(1);
170+
171+
ProgramFixture::SetUp();
172+
MulticontextAubFixture::SetUp(1, EnabledCommandStreamers::Single, true);
173+
}
174+
void TearDown() override {
175+
MulticontextAubFixture::TearDown();
176+
ProgramFixture::TearDown();
177+
}
178+
179+
DebugManagerStateRestore debugRestorer;
180+
cl_int retVal = CL_SUCCESS;
181+
};
182+
183+
XE_HPC_CORETEST_F(SystemMemFenceViaKernelInstruction, givenSystemMemFenceWhenGeneratedAsKernelInstructionThenWritesToSystemMemoryAreGloballyObservable) {
184+
const size_t bufferSize = MemoryConstants::kiloByte;
185+
std::vector<char> buffer(bufferSize, 0x11);
186+
187+
auto deviceMemAlloc = clDeviceMemAllocINTEL(context.get(), tileDevices[0], nullptr, bufferSize, 0, &retVal);
188+
EXPECT_EQ(CL_SUCCESS, retVal);
189+
ASSERT_NE(nullptr, deviceMemAlloc);
190+
191+
retVal = clEnqueueMemcpyINTEL(commandQueues[0][0].get(), true, deviceMemAlloc, buffer.data(), bufferSize, 0, nullptr, nullptr);
192+
EXPECT_EQ(CL_SUCCESS, retVal);
193+
194+
expectMemory<FamilyType>(deviceMemAlloc, buffer.data(), bufferSize, 0, 0);
195+
196+
auto hostMemAlloc = clHostMemAllocINTEL(context.get(), nullptr, bufferSize, 0, &retVal);
197+
EXPECT_EQ(CL_SUCCESS, retVal);
198+
ASSERT_NE(nullptr, hostMemAlloc);
199+
200+
CreateProgramFromBinary(context.get(), context->getDevices(), "system_memfence");
201+
202+
retVal = pProgram->build(pProgram->getDevices(), nullptr, false);
203+
ASSERT_EQ(CL_SUCCESS, retVal);
204+
205+
const KernelInfo *pKernelInfo = pProgram->getKernelInfo("SystemMemFence", rootDeviceIndex);
206+
ASSERT_NE(nullptr, pKernelInfo);
207+
208+
auto pMultiDeviceKernel = clUniquePtr(MultiDeviceKernel::create<MockKernel>(pProgram, MockKernel::toKernelInfoContainer(*pKernelInfo, rootDeviceIndex), &retVal));
209+
ASSERT_NE(nullptr, pMultiDeviceKernel);
210+
211+
retVal = clSetKernelArgSVMPointer(pMultiDeviceKernel.get(), 0, deviceMemAlloc);
212+
ASSERT_EQ(CL_SUCCESS, retVal);
213+
214+
retVal = clSetKernelArgSVMPointer(pMultiDeviceKernel.get(), 1, hostMemAlloc);
215+
ASSERT_EQ(CL_SUCCESS, retVal);
216+
217+
size_t globalWorkSize[3] = {bufferSize, 1, 1};
218+
retVal = commandQueues[0][0]->enqueueKernel(pMultiDeviceKernel->getKernel(rootDeviceIndex), 1, nullptr, globalWorkSize, nullptr, 0, nullptr, nullptr);
219+
ASSERT_EQ(CL_SUCCESS, retVal);
220+
221+
commandQueues[0][0]->finish();
222+
223+
expectMemory<FamilyType>(hostMemAlloc, buffer.data(), bufferSize, 0, 0);
224+
225+
retVal = clMemFreeINTEL(context.get(), deviceMemAlloc);
226+
EXPECT_EQ(CL_SUCCESS, retVal);
227+
228+
retVal = clMemFreeINTEL(context.get(), hostMemAlloc);
229+
EXPECT_EQ(CL_SUCCESS, retVal);
230+
}

0 commit comments

Comments
 (0)