mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
OpenCL Queue Families extension 6/n
Add queue family and index querying from existing queue Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com> Related-To: NEO-5120
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4732a4e692
commit
2293fc0cb5
@@ -736,12 +736,15 @@ void CommandQueue::processProperties(const cl_queue_properties *properties) {
|
||||
}
|
||||
|
||||
if (specificEngineSelected) {
|
||||
this->queueFamilySelected = true;
|
||||
if (getDevice().getNumAvailableDevices() == 1) {
|
||||
auto queueFamily = getDevice().getNonEmptyEngineGroup(selectedQueueFamilyIndex);
|
||||
auto engine = queueFamily->at(selectedQueueIndex);
|
||||
auto engineType = engine.getEngineType();
|
||||
this->overrideEngine(engineType);
|
||||
this->queueCapabilities = getClDevice().getDeviceInfo().queueFamilyProperties[selectedQueueFamilyIndex].capabilities;
|
||||
this->queueFamilyIndex = selectedQueueFamilyIndex;
|
||||
this->queueIndexWithinFamily = selectedQueueIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +302,9 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
|
||||
|
||||
bool validateCapability(cl_command_queue_capabilities_intel capability) const;
|
||||
bool validateCapabilityForOperation(cl_command_queue_capabilities_intel capability, const cl_event *waitList, const cl_event *outEvent) const;
|
||||
cl_uint getQueueFamilyIndex() const { return queueFamilyIndex; }
|
||||
cl_uint getQueueIndexWithinFamily() const { return queueIndexWithinFamily; }
|
||||
bool isQueueFamilySelected() const { return queueFamilySelected; }
|
||||
|
||||
bool getRequiresCacheFlushAfterWalker() const {
|
||||
return requiresCacheFlushAfterWalker;
|
||||
@@ -360,7 +363,11 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
|
||||
|
||||
cl_command_queue_properties commandQueueProperties = 0;
|
||||
std::vector<uint64_t> propertiesVector;
|
||||
|
||||
cl_command_queue_capabilities_intel queueCapabilities = CL_QUEUE_CAPABILITY_ALL_INTEL;
|
||||
cl_uint queueFamilyIndex = 0;
|
||||
cl_uint queueIndexWithinFamily = 0;
|
||||
bool queueFamilySelected = false;
|
||||
|
||||
QueuePriority priority = QueuePriority::MEDIUM;
|
||||
QueueThrottle throttle = QueueThrottle::MEDIUM;
|
||||
|
||||
@@ -37,8 +37,6 @@ void retainQueue(cl_command_queue commandQueue, cl_int &retVal) {
|
||||
}
|
||||
}
|
||||
|
||||
void getIntelQueueInfo(CommandQueue *queue, cl_command_queue_info paramName, GetInfoHelper &getInfoHelper, cl_int &retVal);
|
||||
|
||||
template <typename QueueType>
|
||||
void releaseQueue(cl_command_queue commandQueue, cl_int &retVal) {
|
||||
using BaseType = typename QueueType::BaseType;
|
||||
@@ -62,6 +60,30 @@ inline void releaseQueue<CommandQueue>(cl_command_queue commandQueue, cl_int &re
|
||||
}
|
||||
}
|
||||
|
||||
void getIntelQueueInfo(CommandQueue *queue, cl_command_queue_info paramName, GetInfoHelper &getInfoHelper, cl_int &retVal);
|
||||
|
||||
inline void getHostQueueInfo(CommandQueue *queue, cl_command_queue_info paramName, GetInfoHelper &getInfoHelper, cl_int &retVal) {
|
||||
switch (paramName) {
|
||||
case CL_QUEUE_FAMILY_INTEL:
|
||||
if (queue->isQueueFamilySelected()) {
|
||||
retVal = changeGetInfoStatusToCLResultType(getInfoHelper.set<cl_uint>(queue->getQueueFamilyIndex()));
|
||||
} else {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
}
|
||||
break;
|
||||
case CL_QUEUE_INDEX_INTEL:
|
||||
if (queue->isQueueFamilySelected()) {
|
||||
retVal = changeGetInfoStatusToCLResultType(getInfoHelper.set<cl_uint>(queue->getQueueIndexWithinFamily()));
|
||||
} else {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
getIntelQueueInfo(queue, paramName, getInfoHelper, retVal);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename QueueType>
|
||||
cl_int getQueueInfo(QueueType *queue,
|
||||
cl_command_queue_info paramName,
|
||||
@@ -110,7 +132,7 @@ cl_int getQueueInfo(QueueType *queue,
|
||||
default:
|
||||
if (std::is_same<QueueType, class CommandQueue>::value) {
|
||||
auto cmdQ = reinterpret_cast<CommandQueue *>(queue);
|
||||
getIntelQueueInfo(cmdQ, paramName, getInfoHelper, retVal);
|
||||
getHostQueueInfo(cmdQ, paramName, getInfoHelper, retVal);
|
||||
break;
|
||||
}
|
||||
retVal = CL_INVALID_VALUE;
|
||||
|
||||
@@ -124,6 +124,11 @@ TEST(CommandQueue, WhenConstructingCommandQueueThenTaskLevelAndTaskCountAreZero)
|
||||
EXPECT_EQ(0u, cmdQ.taskCount);
|
||||
}
|
||||
|
||||
TEST(CommandQueue, WhenConstructingCommandQueueThenQueueFamilyIsNotSelected) {
|
||||
MockCommandQueue cmdQ(nullptr, nullptr, 0);
|
||||
EXPECT_FALSE(cmdQ.isQueueFamilySelected());
|
||||
}
|
||||
|
||||
struct GetTagTest : public ClDeviceFixture,
|
||||
public CommandQueueFixture,
|
||||
public CommandStreamFixture,
|
||||
@@ -1366,12 +1371,18 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenMultipleFamiliesWhenCreatingQue
|
||||
MockCommandQueue queueRcs(&context, context.getDevice(0), properties);
|
||||
EXPECT_EQ(&engineCcs, &queueRcs.getGpgpuEngine());
|
||||
EXPECT_FALSE(queueRcs.isCopyOnly);
|
||||
EXPECT_TRUE(queueRcs.isQueueFamilySelected());
|
||||
EXPECT_EQ(properties[1], queueRcs.getQueueFamilyIndex());
|
||||
EXPECT_EQ(properties[3], queueRcs.getQueueIndexWithinFamily());
|
||||
|
||||
fillProperties(properties, 1, 0);
|
||||
EngineControl &engineBcs = context.getDevice(0)->getEngine(aub_stream::ENGINE_BCS, false, false);
|
||||
MockCommandQueue queueBcs(&context, context.getDevice(0), properties);
|
||||
EXPECT_EQ(engineBcs.commandStreamReceiver, queueBcs.getBcsCommandStreamReceiver());
|
||||
EXPECT_TRUE(queueBcs.isCopyOnly);
|
||||
EXPECT_TRUE(queueBcs.isQueueFamilySelected());
|
||||
EXPECT_EQ(properties[1], queueBcs.getQueueFamilyIndex());
|
||||
EXPECT_EQ(properties[3], queueBcs.getQueueIndexWithinFamily());
|
||||
EXPECT_NE(nullptr, queueBcs.getTimestampPacketContainer());
|
||||
}
|
||||
|
||||
@@ -1386,6 +1397,9 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenRootDeviceAndMultipleFamiliesWh
|
||||
MockCommandQueue defaultQueue(&context, context.getDevice(0), properties);
|
||||
EXPECT_EQ(&defaultEngine, &defaultQueue.getGpgpuEngine());
|
||||
EXPECT_FALSE(defaultQueue.isCopyOnly);
|
||||
EXPECT_TRUE(defaultQueue.isQueueFamilySelected());
|
||||
EXPECT_EQ(properties[1], defaultQueue.getQueueFamilyIndex());
|
||||
EXPECT_EQ(properties[3], defaultQueue.getQueueIndexWithinFamily());
|
||||
}
|
||||
|
||||
HWTEST_F(CommandQueueOnSpecificEngineTests, givenSubDeviceAndMultipleFamiliesWhenCreatingQueueOnSpecificEngineThenUseDefaultEngine) {
|
||||
@@ -1399,6 +1413,9 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenSubDeviceAndMultipleFamiliesWhe
|
||||
MockCommandQueue queueRcs(&context, context.getDevice(0), properties);
|
||||
EXPECT_EQ(&engineCcs, &queueRcs.getGpgpuEngine());
|
||||
EXPECT_FALSE(queueRcs.isCopyOnly);
|
||||
EXPECT_TRUE(queueRcs.isQueueFamilySelected());
|
||||
EXPECT_EQ(properties[1], queueRcs.getQueueFamilyIndex());
|
||||
EXPECT_EQ(properties[3], queueRcs.getQueueIndexWithinFamily());
|
||||
|
||||
fillProperties(properties, 1, 0);
|
||||
EngineControl &engineBcs = context.getDevice(0)->getEngine(aub_stream::ENGINE_BCS, false, false);
|
||||
@@ -1406,6 +1423,9 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenSubDeviceAndMultipleFamiliesWhe
|
||||
EXPECT_EQ(engineBcs.commandStreamReceiver, queueBcs.getBcsCommandStreamReceiver());
|
||||
EXPECT_TRUE(queueBcs.isCopyOnly);
|
||||
EXPECT_NE(nullptr, queueBcs.getTimestampPacketContainer());
|
||||
EXPECT_TRUE(queueBcs.isQueueFamilySelected());
|
||||
EXPECT_EQ(properties[1], queueBcs.getQueueFamilyIndex());
|
||||
EXPECT_EQ(properties[3], queueBcs.getQueueIndexWithinFamily());
|
||||
}
|
||||
|
||||
HWTEST_F(CommandQueueOnSpecificEngineTests, givenBcsFamilySelectedWhenCreatingQueueOnSpecificEngineThenInitializeBcsProperly) {
|
||||
@@ -1419,6 +1439,9 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenBcsFamilySelectedWhenCreatingQu
|
||||
EXPECT_EQ(engineBcs.commandStreamReceiver, queueBcs.getBcsCommandStreamReceiver());
|
||||
EXPECT_TRUE(queueBcs.isCopyOnly);
|
||||
EXPECT_NE(nullptr, queueBcs.getTimestampPacketContainer());
|
||||
EXPECT_TRUE(queueBcs.isQueueFamilySelected());
|
||||
EXPECT_EQ(properties[1], queueBcs.getQueueFamilyIndex());
|
||||
EXPECT_EQ(properties[3], queueBcs.getQueueIndexWithinFamily());
|
||||
}
|
||||
|
||||
HWTEST_F(CommandQueueOnSpecificEngineTests, givenBliterDisabledAndBcsFamilySelectedWhenCreatingQueueOnSpecificEngineThenInitializeBcsProperly) {
|
||||
@@ -1435,4 +1458,7 @@ HWTEST_F(CommandQueueOnSpecificEngineTests, givenBliterDisabledAndBcsFamilySelec
|
||||
EXPECT_EQ(engineBcs.commandStreamReceiver, queueBcs.getBcsCommandStreamReceiver());
|
||||
EXPECT_TRUE(queueBcs.isCopyOnly);
|
||||
EXPECT_NE(nullptr, queueBcs.getTimestampPacketContainer());
|
||||
EXPECT_TRUE(queueBcs.isQueueFamilySelected());
|
||||
EXPECT_EQ(properties[1], queueBcs.getQueueFamilyIndex());
|
||||
EXPECT_EQ(properties[3], queueBcs.getQueueIndexWithinFamily());
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "opencl/test/unit_test/command_queue/command_queue_fixture.h"
|
||||
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
|
||||
#include "opencl/test/unit_test/fixtures/context_fixture.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -120,3 +121,51 @@ INSTANTIATE_TEST_CASE_P(
|
||||
GetCommandQueueInfoTest,
|
||||
GetCommandQueueInfoTest,
|
||||
::testing::ValuesIn(DefaultCommandQueueProperties));
|
||||
|
||||
TEST(GetCommandQueueFamilyInfoTest, givenQueueFamilyNotSelectedWhenGettingFamilyAndQueueIndexThenInvalidValueueIsReturned) {
|
||||
MockCommandQueue queue;
|
||||
queue.queueFamilySelected = false;
|
||||
cl_int retVal{};
|
||||
|
||||
cl_uint familyIndex{};
|
||||
retVal = queue.getCommandQueueInfo(
|
||||
CL_QUEUE_FAMILY_INTEL,
|
||||
sizeof(cl_uint),
|
||||
&familyIndex,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
|
||||
cl_uint queueIndex{};
|
||||
retVal = queue.getCommandQueueInfo(
|
||||
CL_QUEUE_INDEX_INTEL,
|
||||
sizeof(cl_uint),
|
||||
&queueIndex,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
TEST(GetCommandQueueFamilyInfoTest, givenQueueFamilySelectedWhenGettingFamilyAndQueueIndexThenValuesAreReturned) {
|
||||
MockCommandQueue queue;
|
||||
queue.queueFamilySelected = true;
|
||||
queue.queueFamilyIndex = 12u;
|
||||
queue.queueIndexWithinFamily = 1432u;
|
||||
cl_int retVal{};
|
||||
|
||||
cl_uint familyIndex{};
|
||||
retVal = queue.getCommandQueueInfo(
|
||||
CL_QUEUE_FAMILY_INTEL,
|
||||
sizeof(cl_uint),
|
||||
&familyIndex,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(queue.queueFamilyIndex, familyIndex);
|
||||
|
||||
cl_uint queueIndex{};
|
||||
retVal = queue.getCommandQueueInfo(
|
||||
CL_QUEUE_INDEX_INTEL,
|
||||
sizeof(cl_uint),
|
||||
&queueIndex,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(queue.queueIndexWithinFamily, queueIndex);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ class MockCommandQueue : public CommandQueue {
|
||||
using CommandQueue::isCopyOnly;
|
||||
using CommandQueue::obtainNewTimestampPacketNodes;
|
||||
using CommandQueue::queueCapabilities;
|
||||
using CommandQueue::queueFamilyIndex;
|
||||
using CommandQueue::queueFamilySelected;
|
||||
using CommandQueue::queueIndexWithinFamily;
|
||||
using CommandQueue::requiresCacheFlushAfterWalker;
|
||||
using CommandQueue::throttle;
|
||||
using CommandQueue::timestampPacketContainer;
|
||||
|
||||
Reference in New Issue
Block a user