Skip to content

Commit eace896

Browse files
Change order of command queue groups
Resolves: NEO-6257 Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
1 parent 4fbabed commit eace896

File tree

7 files changed

+66
-12
lines changed

7 files changed

+66
-12
lines changed

level_zero/core/test/unit_tests/gen12lp/test_device_gen12lp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ HWTEST2_F(DeviceQueueGroupTest,
211211
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
212212

213213
for (uint32_t i = 0; i < count; i++) {
214-
if (i == static_cast<uint32_t>(NEO::EngineGroupType::RenderCompute)) {
214+
if (i == neoMockDevice->getIndexOfNonEmptyEngineGroup(NEO::EngineGroupType::RenderCompute)) {
215215
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
216216
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
217217
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS);
218218
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS);
219219
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits<size_t>::max());
220220
EXPECT_EQ(properties[i].numQueues, 1u);
221-
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
221+
} else if (i == neoMockDevice->getIndexOfNonEmptyEngineGroup(NEO::EngineGroupType::Copy)) {
222222
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
223223
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, 4 * sizeof(uint32_t));
224224
EXPECT_EQ(properties[i].numQueues, 1u);
@@ -253,14 +253,14 @@ HWTEST2_F(DeviceQueueGroupTest,
253253
L0::Context *context = Context::fromHandle(hContext);
254254

255255
for (uint32_t i = 0; i < count; i++) {
256-
if (i == static_cast<uint32_t>(NEO::EngineGroupType::RenderCompute)) {
256+
if (i == neoMockDevice->getIndexOfNonEmptyEngineGroup(NEO::EngineGroupType::RenderCompute)) {
257257
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
258258
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
259259
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS);
260260
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS);
261261
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits<size_t>::max());
262262
EXPECT_EQ(properties[i].numQueues, 1u);
263-
} else if (i == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
263+
} else if (i == neoMockDevice->getIndexOfNonEmptyEngineGroup(NEO::EngineGroupType::Copy)) {
264264
EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY);
265265
EXPECT_EQ(properties[i].maxMemoryFillPatternSize, 4 * sizeof(uint32_t));
266266
EXPECT_EQ(properties[i].numQueues, 1u);

level_zero/core/test/unit_tests/gen9/test_cmdqueue_gen9.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ HWTEST2_F(CommandQueueGroupMultiDevice,
211211

212212
L0::CommandQueueImp *cmdQueue = reinterpret_cast<CommandQueueImp *>(commandList0->cmdQImmediate);
213213
L0::DeviceImp *deviceImp = reinterpret_cast<L0::DeviceImp *>(device);
214-
auto expectedCSR = deviceImp->neoDevice->getNearestGenericSubDevice(0)->getEngineGroups()[queueGroupOrdinal][queueGroupIndex].commandStreamReceiver;
214+
const auto rcsIndex = static_cast<size_t>(NEO::EngineGroupType::RenderCompute);
215+
auto expectedCSR = deviceImp->neoDevice->getNearestGenericSubDevice(0)->getEngineGroups()[rcsIndex][queueGroupIndex].commandStreamReceiver;
215216
EXPECT_EQ(cmdQueue->getCsr(), expectedCSR);
216217
}
217218

opencl/test/unit_test/command_queue/command_queue_tests.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,7 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenBcsFamilySelectedWhenCreatingQu
16771677
EXPECT_EQ(properties[3], queueBcs.getQueueIndexWithinFamily());
16781678
}
16791679

1680-
HWTEST_F(CommandQueueOnSpecificEngineTests, givenNotInitializedCcsOsContextWhenCreatingQueueThenInitializeOsContext) {
1680+
HWTEST_F(CommandQueueOnSpecificEngineTests, givenNotInitializedRcsOsContextWhenCreatingQueueThenInitializeOsContext) {
16811681
DebugManagerStateRestore restore{};
16821682
DebugManager.flags.NodeOrdinal.set(static_cast<int32_t>(aub_stream::EngineType::ENGINE_RCS));
16831683
DebugManager.flags.DeferOsContextInitialization.set(1);
@@ -1689,7 +1689,27 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenNotInitializedCcsOsContextWhenC
16891689
OsContext &osContext = *context.getDevice(0)->getEngine(aub_stream::ENGINE_CCS, EngineUsage::Regular).osContext;
16901690
EXPECT_FALSE(osContext.isInitialized());
16911691

1692-
fillProperties(properties, 1, 0);
1692+
const auto ccsFamilyIndex = static_cast<cl_uint>(context.getDevice(0)->getDevice().getIndexOfNonEmptyEngineGroup(EngineGroupType::Compute));
1693+
fillProperties(properties, ccsFamilyIndex, 0);
1694+
MockCommandQueueHw<FamilyType> queue(&context, context.getDevice(0), properties);
1695+
ASSERT_EQ(&osContext, queue.gpgpuEngine->osContext);
1696+
EXPECT_TRUE(osContext.isInitialized());
1697+
}
1698+
1699+
HWTEST_F(CommandQueueOnSpecificEngineTests, givenNotInitializedCcsOsContextWhenCreatingQueueThenInitializeOsContext) {
1700+
DebugManagerStateRestore restore{};
1701+
DebugManager.flags.NodeOrdinal.set(static_cast<int32_t>(aub_stream::EngineType::ENGINE_CCS));
1702+
DebugManager.flags.DeferOsContextInitialization.set(1);
1703+
1704+
auto raiiHwHelper = overrideHwHelper<FamilyType, MockHwHelper<FamilyType, 1, 1, 1>>();
1705+
MockContext context{};
1706+
cl_command_queue_properties properties[5] = {};
1707+
1708+
OsContext &osContext = *context.getDevice(0)->getEngine(aub_stream::ENGINE_RCS, EngineUsage::Regular).osContext;
1709+
EXPECT_FALSE(osContext.isInitialized());
1710+
1711+
const auto rcsFamilyIndex = static_cast<cl_uint>(context.getDevice(0)->getDevice().getIndexOfNonEmptyEngineGroup(EngineGroupType::RenderCompute));
1712+
fillProperties(properties, rcsFamilyIndex, 0);
16931713
MockCommandQueueHw<FamilyType> queue(&context, context.getDevice(0), properties);
16941714
ASSERT_EQ(&osContext, queue.gpgpuEngine->osContext);
16951715
EXPECT_TRUE(osContext.isInitialized());

opencl/test/unit_test/command_queue/get_command_queue_info_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, GetCommandQueueFamilyInfoTests, givenFamilyIdWhenGe
219219
clReleaseContext(context);
220220
}
221221

222-
HWCMDTEST_F(IGFX_XE_HP_CORE, GetCommandQueueFamilyInfoTests, givenFamilyIdWhenCreatingCommandQueueForRootDeviceWithMultipleSubDevicesThenInvalidValueIsReturned) {
222+
HWCMDTEST_F(IGFX_XE_HP_CORE, GetCommandQueueFamilyInfoTests, givenNonZeroFamilyIdWhenCreatingCommandQueueForRootDeviceWithMultipleSubDevicesThenInvalidValueIsReturned) {
223223
DebugManagerStateRestore restorer;
224224
DebugManager.flags.CreateMultipleSubDevices.set(2);
225225
initPlatform();
@@ -228,7 +228,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, GetCommandQueueFamilyInfoTests, givenFamilyIdWhenCr
228228
const cl_device_id deviceId = rootDevice;
229229
auto context = clCreateContext(nullptr, 1, &deviceId, nullptr, nullptr, nullptr);
230230

231-
cl_command_queue_properties properties[] = {CL_QUEUE_FAMILY_INTEL, static_cast<uint32_t>(EngineGroupType::Compute), CL_QUEUE_INDEX_INTEL, 0, 0};
231+
cl_command_queue_properties properties[] = {CL_QUEUE_FAMILY_INTEL, 1u, CL_QUEUE_INDEX_INTEL, 0, 0};
232232
EXPECT_EQ(2u, rootDevice->getNumGenericSubDevices());
233233
cl_int retVal;
234234
auto commandQueue = clCreateCommandQueueWithProperties(context, rootDevice, properties, &retVal);
@@ -266,4 +266,4 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, MultiEngineQueueHwTests, givenLimitedNumberOfCcsWhe
266266
EXPECT_EQ(CL_SUCCESS, retVal);
267267
clReleaseCommandQueue(clCommandQueue);
268268
}
269-
}
269+
}

opencl/test/unit_test/device/device_tests.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "shared/source/indirect_heap/indirect_heap.h"
1212
#include "shared/source/os_interface/os_context.h"
1313
#include "shared/test/common/helpers/debug_manager_state_restore.h"
14+
#include "shared/test/common/helpers/engine_descriptor_helper.h"
1415
#include "shared/test/common/helpers/ult_hw_config.h"
1516
#include "shared/test/common/helpers/unit_test_helper.h"
1617
#include "shared/test/common/helpers/variable_backup.h"
@@ -21,6 +22,7 @@
2122

2223
#include "opencl/source/platform/platform.h"
2324
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
25+
#include "opencl/test/unit_test/helpers/raii_hw_helper.h"
2426
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
2527
#include "opencl/test/unit_test/mocks/mock_context.h"
2628
#include "opencl/test/unit_test/mocks/mock_csr.h"
@@ -557,6 +559,36 @@ HWTEST_F(DeviceHwTest, givenDeviceCreationWhenCsrFailsToCreateGlobalSyncAllocati
557559
EXPECT_EQ(nullptr, mockDevice);
558560
}
559561

562+
HWTEST_F(DeviceHwTest, givenBothCcsAndRcsEnginesInDeviceWhenGettingFirstEngineGroupsThenReturnCcs) {
563+
struct MyHwHelper : HwHelperHw<FamilyType> {
564+
EngineGroupType getEngineGroupType(aub_stream::EngineType engineType, EngineUsage engineUsage, const HardwareInfo &hwInfo) const {
565+
if (engineType == aub_stream::ENGINE_RCS) {
566+
return EngineGroupType::RenderCompute;
567+
}
568+
if (EngineHelpers::isCcs(engineType)) {
569+
return EngineGroupType::Compute;
570+
}
571+
UNRECOVERABLE_IF(true);
572+
}
573+
};
574+
RAIIHwHelperFactory<MyHwHelper> overrideHwHelper{::defaultHwInfo->platform.eRenderCoreFamily};
575+
576+
MockOsContext rcsContext(0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::EngineType::ENGINE_RCS, EngineUsage::Regular}));
577+
EngineControl rcsEngine{nullptr, &rcsContext};
578+
579+
MockOsContext ccsContext(1, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::EngineType::ENGINE_CCS, EngineUsage::Regular}));
580+
EngineControl ccsEngine{nullptr, &ccsContext};
581+
582+
MockDevice device{};
583+
ASSERT_EQ(nullptr, device.getNonEmptyEngineGroup(0u));
584+
device.addEngineToEngineGroup(rcsEngine);
585+
device.addEngineToEngineGroup(ccsEngine);
586+
587+
const auto firstGroup = device.getNonEmptyEngineGroup(0u);
588+
EXPECT_EQ(1u, firstGroup->size());
589+
EXPECT_EQ(aub_stream::EngineType::ENGINE_CCS, firstGroup->at(0).getEngineType());
590+
}
591+
560592
TEST(DeviceGetEngineTest, givenHwCsrModeWhenGetEngineThenDedicatedForInternalUsageEngineIsReturned) {
561593
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
562594

shared/source/helpers/definitions/engine_group_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace NEO {
1313

1414
enum class EngineGroupType : uint32_t {
15-
RenderCompute = 0,
16-
Compute,
15+
Compute = 0,
16+
RenderCompute,
1717
Copy,
1818
MaxEngineGroups
1919
};

shared/test/common/mocks/mock_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct MockSubDevice : public SubDevice {
4646

4747
class MockDevice : public RootDevice {
4848
public:
49+
using Device::addEngineToEngineGroup;
4950
using Device::commandStreamReceivers;
5051
using Device::createDeviceInternals;
5152
using Device::createEngine;

0 commit comments

Comments
 (0)