From 2c524f94a44fcaf40d384cae647a248b77c34120 Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Mon, 11 Mar 2019 16:31:20 +0100 Subject: [PATCH] Const correctness. Change-Id: I68be05e6c1c3c9c0dc33ba8252a0a5bbeefc06a4 Signed-off-by: Piotr Fusik --- ...nd_stream_receiver_simulated_common_hw.inl | 6 +++--- .../command_stream/definitions/engine_node.h | 4 ++-- runtime/gen10/aub_mapper.h | 4 ++-- runtime/gen10/aub_mem_dump_gen10.cpp | 10 +++++----- runtime/gen8/aub_mapper.h | 4 ++-- runtime/gen8/aub_mem_dump_gen8.cpp | 10 +++++----- runtime/gen9/aub_mapper.h | 4 ++-- runtime/gen9/aub_mem_dump_gen9.cpp | 10 +++++----- ...te_command_queue_with_properties_tests.cpp | 6 +++--- .../aub_command_stream_tests.cpp | 19 ++++++++----------- unit_tests/device/device_tests.cpp | 2 +- 11 files changed, 38 insertions(+), 41 deletions(-) diff --git a/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl b/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl index f35a92dec9..b4a4d825d0 100644 --- a/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl +++ b/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl @@ -90,11 +90,11 @@ template void CommandStreamReceiverSimulatedCommonHw::setupContext(OsContext &osContext) { CommandStreamReceiverHw::setupContext(osContext); - engineIndex = getEngineIndex(osContext.getEngineType()); + auto engineType = osContext.getEngineType(); + engineIndex = getEngineIndex(engineType); uint32_t flags = 0; - getCsTraits(osContext.getEngineType()).setContextSaveRestoreFlags(flags); + getCsTraits(engineType).setContextSaveRestoreFlags(flags); - auto &engineType = osContext.getEngineType(); if (aubManager && !(engineType.type == lowPriorityGpgpuEngine.type && engineType.id == lowPriorityGpgpuEngine.id)) { hardwareContextController = std::make_unique(*aubManager, osContext, engineIndex, flags); } diff --git a/runtime/command_stream/definitions/engine_node.h b/runtime/command_stream/definitions/engine_node.h index 7346cc290d..328319eb2b 100644 --- a/runtime/command_stream/definitions/engine_node.h +++ b/runtime/command_stream/definitions/engine_node.h @@ -21,8 +21,8 @@ enum EngineType : uint32_t { namespace EngineInstanceConstants { constexpr uint32_t lowPriorityGpgpuEngineIndex = 1; -static const size_t numAllEngineInstances = 5; -static const size_t numGpgpuEngineInstances = 2; +constexpr size_t numAllEngineInstances = 5; +constexpr uint32_t numGpgpuEngineInstances = 2; } // namespace EngineInstanceConstants struct EngineInstanceT { diff --git a/runtime/gen10/aub_mapper.h b/runtime/gen10/aub_mapper.h index 465d9edf5e..e57fc30b0e 100644 --- a/runtime/gen10/aub_mapper.h +++ b/runtime/gen10/aub_mapper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,7 +18,7 @@ struct AUBFamilyMapper { using AubTraits = AubMemDump::Traits; - static const AubMemDump::LrcaHelper *csTraits[EngineType::NUM_ENGINES]; + static const AubMemDump::LrcaHelper *const csTraits[EngineType::NUM_ENGINES]; static const MMIOList globalMMIO; static const MMIOList *perEngineMMIO[EngineType::NUM_ENGINES]; diff --git a/runtime/gen10/aub_mem_dump_gen10.cpp b/runtime/gen10/aub_mem_dump_gen10.cpp index 6f10cf0fa3..f42746a7a9 100644 --- a/runtime/gen10/aub_mem_dump_gen10.cpp +++ b/runtime/gen10/aub_mem_dump_gen10.cpp @@ -30,12 +30,12 @@ template struct AubPageTableHelper64>; namespace OCLRT { using Family = CNLFamily; -static AubMemDump::LrcaHelperRcs rcs(0x002000); -static AubMemDump::LrcaHelperBcs bcs(0x022000); -static AubMemDump::LrcaHelperVcs vcs(0x012000); -static AubMemDump::LrcaHelperVecs vecs(0x01a000); +static const AubMemDump::LrcaHelperRcs rcs(0x002000); +static const AubMemDump::LrcaHelperBcs bcs(0x022000); +static const AubMemDump::LrcaHelperVcs vcs(0x012000); +static const AubMemDump::LrcaHelperVecs vecs(0x01a000); -const AubMemDump::LrcaHelper *AUBFamilyMapper::csTraits[EngineType::NUM_ENGINES] = { +const AubMemDump::LrcaHelper *const AUBFamilyMapper::csTraits[EngineType::NUM_ENGINES] = { &rcs, &bcs, &vcs, diff --git a/runtime/gen8/aub_mapper.h b/runtime/gen8/aub_mapper.h index c646f4a491..c976c54f40 100644 --- a/runtime/gen8/aub_mapper.h +++ b/runtime/gen8/aub_mapper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,7 +18,7 @@ struct AUBFamilyMapper { using AubTraits = AubMemDump::Traits; - static const AubMemDump::LrcaHelper *csTraits[EngineType::NUM_ENGINES]; + static const AubMemDump::LrcaHelper *const csTraits[EngineType::NUM_ENGINES]; static const MMIOList globalMMIO; static const MMIOList *perEngineMMIO[EngineType::NUM_ENGINES]; diff --git a/runtime/gen8/aub_mem_dump_gen8.cpp b/runtime/gen8/aub_mem_dump_gen8.cpp index 035aa04e5b..f10f1c4b67 100644 --- a/runtime/gen8/aub_mem_dump_gen8.cpp +++ b/runtime/gen8/aub_mem_dump_gen8.cpp @@ -28,12 +28,12 @@ template struct AubPageTableHelper64>; namespace OCLRT { using Family = BDWFamily; -static AubMemDump::LrcaHelperRcs rcs(0x002000); -static AubMemDump::LrcaHelperBcs bcs(0x022000); -static AubMemDump::LrcaHelperVcs vcs(0x012000); -static AubMemDump::LrcaHelperVecs vecs(0x01a000); +static const AubMemDump::LrcaHelperRcs rcs(0x002000); +static const AubMemDump::LrcaHelperBcs bcs(0x022000); +static const AubMemDump::LrcaHelperVcs vcs(0x012000); +static const AubMemDump::LrcaHelperVecs vecs(0x01a000); -const AubMemDump::LrcaHelper *AUBFamilyMapper::csTraits[EngineType::NUM_ENGINES] = { +const AubMemDump::LrcaHelper *const AUBFamilyMapper::csTraits[EngineType::NUM_ENGINES] = { &rcs, &bcs, &vcs, diff --git a/runtime/gen9/aub_mapper.h b/runtime/gen9/aub_mapper.h index 2eb4f86c82..77dee5143c 100644 --- a/runtime/gen9/aub_mapper.h +++ b/runtime/gen9/aub_mapper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,7 +18,7 @@ struct AUBFamilyMapper { using AubTraits = AubMemDump::Traits; - static const AubMemDump::LrcaHelper *csTraits[EngineType::NUM_ENGINES]; + static const AubMemDump::LrcaHelper *const csTraits[EngineType::NUM_ENGINES]; static const MMIOList globalMMIO; static const MMIOList *perEngineMMIO[EngineType::NUM_ENGINES]; diff --git a/runtime/gen9/aub_mem_dump_gen9.cpp b/runtime/gen9/aub_mem_dump_gen9.cpp index 0c585e8292..67e06a0998 100644 --- a/runtime/gen9/aub_mem_dump_gen9.cpp +++ b/runtime/gen9/aub_mem_dump_gen9.cpp @@ -28,12 +28,12 @@ template struct AubPageTableHelper64>; namespace OCLRT { using Family = SKLFamily; -static AubMemDump::LrcaHelperRcs rcs(0x002000); -static AubMemDump::LrcaHelperBcs bcs(0x022000); -static AubMemDump::LrcaHelperVcs vcs(0x012000); -static AubMemDump::LrcaHelperVecs vecs(0x01a000); +static const AubMemDump::LrcaHelperRcs rcs(0x002000); +static const AubMemDump::LrcaHelperBcs bcs(0x022000); +static const AubMemDump::LrcaHelperVcs vcs(0x012000); +static const AubMemDump::LrcaHelperVecs vecs(0x01a000); -const AubMemDump::LrcaHelper *AUBFamilyMapper::csTraits[EngineType::NUM_ENGINES] = { +const AubMemDump::LrcaHelper *const AUBFamilyMapper::csTraits[EngineType::NUM_ENGINES] = { &rcs, &bcs, &vcs, diff --git a/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp b/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp index 2216ab10b5..73e4f0b26e 100644 --- a/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp +++ b/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp @@ -356,11 +356,11 @@ TEST_F(clCreateCommandQueueWithPropertiesApi, GivenLowPriorityWhenCreatingComman } TEST_F(clCreateCommandQueueWithPropertiesApi, GivenLowPriorityWhenCreatingCommandQueueThenSelectRcs1Engine) { - cl_queue_properties preoperties[] = {CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_LOW_KHR, 0}; - auto cmdQ = clCreateCommandQueueWithProperties(pContext, devices[0], preoperties, nullptr); + cl_queue_properties properties[] = {CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_LOW_KHR, 0}; + auto cmdQ = clCreateCommandQueueWithProperties(pContext, devices[0], properties, nullptr); auto commandQueueObj = castToObject(cmdQ); - auto &engine = commandQueueObj->getCommandStreamReceiver().getOsContext().getEngineType(); + auto engine = commandQueueObj->getCommandStreamReceiver().getOsContext().getEngineType(); EXPECT_EQ(EngineType::ENGINE_RCS, engine.type); EXPECT_EQ(1, engine.id); diff --git a/unit_tests/aub_tests/command_stream/aub_command_stream_tests.cpp b/unit_tests/aub_tests/command_stream/aub_command_stream_tests.cpp index 16efb5c83c..775c1dce09 100644 --- a/unit_tests/aub_tests/command_stream/aub_command_stream_tests.cpp +++ b/unit_tests/aub_tests/command_stream/aub_command_stream_tests.cpp @@ -40,7 +40,9 @@ struct AUBFixture : public AUBCommandStreamFixture, } template - void testNoopIdXcs() { + void testNoopIdXcs(EngineType engineType) { + pCommandStreamReceiver->getOsContext().getEngineType().type = engineType; + typedef typename FamilyType::MI_NOOP MI_NOOP; auto pCmd = (MI_NOOP *)pCS->getSpace(sizeof(MI_NOOP) * 4); @@ -61,8 +63,7 @@ struct AUBFixture : public AUBCommandStreamFixture, pCommandStreamReceiver->flush(batchBuffer, allocationsForResidency); AUBCommandStreamFixture::getSimulatedCsr()->pollForCompletionImpl(); - auto engineType = pCommandStreamReceiver->getOsContext().getEngineType(); - auto mmioBase = CommandStreamReceiverSimulatedCommonHw::getCsTraits(engineType.type).mmioBase; + auto mmioBase = CommandStreamReceiverSimulatedCommonHw::getCsTraits(engineType).mmioBase; AUBCommandStreamFixture::expectMMIO(AubMemDump::computeRegisterOffset(mmioBase, 0x2094), noopId); } }; @@ -83,23 +84,19 @@ HWTEST_F(AUBcommandstreamTests, testFlushTwice) { } HWTEST_F(AUBcommandstreamTests, testNoopIdRcs) { - pCommandStreamReceiver->getOsContext().getEngineType().type = EngineType::ENGINE_RCS; - testNoopIdXcs(); + testNoopIdXcs(EngineType::ENGINE_RCS); } HWTEST_F(AUBcommandstreamTests, testNoopIdBcs) { - pCommandStreamReceiver->getOsContext().getEngineType().type = EngineType::ENGINE_BCS; - testNoopIdXcs(); + testNoopIdXcs(EngineType::ENGINE_BCS); } HWTEST_F(AUBcommandstreamTests, testNoopIdVcs) { - pCommandStreamReceiver->getOsContext().getEngineType().type = EngineType::ENGINE_VCS; - testNoopIdXcs(); + testNoopIdXcs(EngineType::ENGINE_VCS); } HWTEST_F(AUBcommandstreamTests, testNoopIdVecs) { - pCommandStreamReceiver->getOsContext().getEngineType().type = EngineType::ENGINE_VECS; - testNoopIdXcs(); + testNoopIdXcs(EngineType::ENGINE_VECS); } TEST_F(AUBcommandstreamTests, makeResident) { diff --git a/unit_tests/device/device_tests.cpp b/unit_tests/device/device_tests.cpp index 58d7d985eb..38567ada99 100644 --- a/unit_tests/device/device_tests.cpp +++ b/unit_tests/device/device_tests.cpp @@ -211,7 +211,7 @@ TEST(DeviceCreation, givenDeviceWhenAskingForDefaultEngineThenReturnValidValue) ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); auto device = std::unique_ptr(Device::create(platformDevices[0], executionEnvironment, 0)); - auto &defaultEngine = device->getDefaultEngine().osContext->getEngineType(); + auto defaultEngine = device->getDefaultEngine().osContext->getEngineType(); EXPECT_EQ(platformDevices[0]->capabilityTable.defaultEngineType, defaultEngine.type); EXPECT_EQ(0, defaultEngine.id);