From 7f7808fb71220849c80339bba597ff57774ab786 Mon Sep 17 00:00:00 2001 From: "Dunajski, Bartosz" Date: Thu, 6 Dec 2018 15:54:55 +0100 Subject: [PATCH] Select RCS1 for low priority CommandQueue Change-Id: I1f86b0afedb8f6e76fee896c2751a0bf196996d7 Signed-off-by: Dunajski, Bartosz --- runtime/command_queue/command_queue_hw.h | 2 ++ .../aub_command_stream_receiver_hw.h | 4 ++-- .../command_stream/definitions/engine_node.h | 18 +++++++++++++----- runtime/device/device.h | 2 +- .../execution_environment.h | 2 +- runtime/memory_manager/memory_manager.h | 2 +- ...ate_command_queue_with_properties_tests.cpp | 14 ++++++++++++++ 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/runtime/command_queue/command_queue_hw.h b/runtime/command_queue/command_queue_hw.h index 7c364d2ef6..47f2115886 100644 --- a/runtime/command_queue/command_queue_hw.h +++ b/runtime/command_queue/command_queue_hw.h @@ -13,6 +13,7 @@ #include "runtime/program/printf_handler.h" #include "runtime/helpers/dispatch_info.h" #include "runtime/command_stream/preemption.h" +#include "runtime/helpers/engine_control.h" #include "runtime/helpers/queue_helpers.h" #include @@ -33,6 +34,7 @@ class CommandQueueHw : public CommandQueue { if (clPriority & static_cast(CL_QUEUE_PRIORITY_LOW_KHR)) { priority = QueuePriority::LOW; + this->engine = &device->getEngine(EngineInstanceConstants::lowPriorityGpgpuEngineIndex); } else if (clPriority & static_cast(CL_QUEUE_PRIORITY_MED_KHR)) { priority = QueuePriority::MEDIUM; } else if (clPriority & static_cast(CL_QUEUE_PRIORITY_HIGH_KHR)) { diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.h b/runtime/command_stream/aub_command_stream_receiver_hw.h index e50421ac94..5490255927 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.h +++ b/runtime/command_stream/aub_command_stream_receiver_hw.h @@ -106,8 +106,8 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw subCaptureManager; uint32_t aubDeviceId; diff --git a/runtime/command_stream/definitions/engine_node.h b/runtime/command_stream/definitions/engine_node.h index 6f0695f79d..80640a4876 100644 --- a/runtime/command_stream/definitions/engine_node.h +++ b/runtime/command_stream/definitions/engine_node.h @@ -19,10 +19,13 @@ enum EngineType : uint32_t { NUM_ENGINES }; -struct EngineInstanceT { - static const size_t numAllEngineInstances = 5; - static const size_t numGpgpuEngineInstances = 2; +namespace EngineInstanceConstants { +constexpr uint32_t lowPriorityGpgpuEngineIndex = 1; +static const size_t numAllEngineInstances = 5; +static const size_t numGpgpuEngineInstances = 2; +} // namespace EngineInstanceConstants +struct EngineInstanceT { constexpr EngineInstanceT(EngineType type) : type(type), id(0) {} constexpr EngineInstanceT(EngineType type, int id) : type(type), id(id) {} @@ -30,7 +33,7 @@ struct EngineInstanceT { int id; }; -static constexpr std::array allEngineInstances = {{ +static constexpr std::array allEngineInstances = {{ {ENGINE_RCS, 0}, {ENGINE_RCS, 1}, {ENGINE_BCS}, @@ -38,8 +41,13 @@ static constexpr std::array gpgpuEngineInstances = {{ +static constexpr std::array gpgpuEngineInstances = {{ {ENGINE_RCS, 0}, {ENGINE_RCS, 1}, }}; + +static_assert(gpgpuEngineInstances[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].type == EngineType::ENGINE_RCS && + gpgpuEngineInstances[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].id == 1, + "{RCS,1} is low priority engine"); + } // namespace OCLRT diff --git a/runtime/device/device.h b/runtime/device/device.h index 96a417dfa1..7b81976363 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -151,7 +151,7 @@ class Device : public BaseObject<_cl_device_id> { std::unique_ptr driverInfo; std::unique_ptr performanceCounters; - std::array engines = {{}}; + std::array engines = {{}}; void *slmWindowStartAddress = nullptr; diff --git a/runtime/execution_environment/execution_environment.h b/runtime/execution_environment/execution_environment.h index 527e00c633..d47e6df18c 100644 --- a/runtime/execution_environment/execution_environment.h +++ b/runtime/execution_environment/execution_environment.h @@ -24,7 +24,7 @@ class BuiltIns; struct HardwareInfo; class OSInterface; -using CsrContainer = std::vector, EngineInstanceT::numGpgpuEngineInstances>>; +using CsrContainer = std::vector, EngineInstanceConstants::numGpgpuEngineInstances>>; class ExecutionEnvironment : public ReferenceTrackedObject { private: diff --git a/runtime/memory_manager/memory_manager.h b/runtime/memory_manager/memory_manager.h index 99977e74f3..63e9c0c7e2 100644 --- a/runtime/memory_manager/memory_manager.h +++ b/runtime/memory_manager/memory_manager.h @@ -30,7 +30,7 @@ class AllocsTracker; class MapBaseAllocationTracker; class SVMAllocsManager; -using CsrContainer = std::vector, EngineInstanceT::numGpgpuEngineInstances>>; +using CsrContainer = std::vector, EngineInstanceConstants::numGpgpuEngineInstances>>; enum AllocationUsage { TEMPORARY_ALLOCATION, 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 a2c142d03e..417b752323 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 @@ -8,10 +8,12 @@ #include "cl_api_tests.h" #include "CL/cl_ext.h" #include "runtime/context/context.h" +#include "runtime/command_stream/command_stream_receiver.h" #include "runtime/command_queue/command_queue.h" #include "runtime/device/device.h" #include "runtime/device_queue/device_queue.h" #include "runtime/helpers/base_object.h" +#include "runtime/os_interface/os_context.h" #include "unit_tests/fixtures/memory_management_fixture.h" #include "unit_tests/mocks/mock_context.h" @@ -352,6 +354,18 @@ TEST_F(clCreateCommandQueueWithPropertiesApi, GivenLowPriorityWhenCreatingComman EXPECT_EQ(retVal, CL_SUCCESS); } +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); + + auto commandQueueObj = castToObject(cmdQ); + auto &engine = commandQueueObj->getCommandStreamReceiver().getOsContext().getEngineType(); + EXPECT_EQ(EngineType::ENGINE_RCS, engine.type); + EXPECT_EQ(1, engine.id); + + clReleaseCommandQueue(cmdQ); +} + std::pair priorityParams[3]{ std::make_pair(CL_QUEUE_PRIORITY_LOW_KHR, QueuePriority::LOW), std::make_pair(CL_QUEUE_PRIORITY_MED_KHR, QueuePriority::MEDIUM),