Skip to content

Commit 320a404

Browse files
OpenCL Queue Families extension 15/n
Add queue family name. This change will break backwards-compatibility. Signed-off-by: Maciej Dziuban <[email protected]>
1 parent 22c25a2 commit 320a404

File tree

8 files changed

+75
-2
lines changed

8 files changed

+75
-2
lines changed

opencl/extensions/public/cl_ext_private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ using cl_unified_shared_memory_capabilities_intel = cl_bitfield;
178178

179179
typedef cl_bitfield cl_command_queue_capabilities_intel;
180180

181+
#define CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL 64
181182
typedef struct _cl_queue_family_properties_intel {
182183
cl_command_queue_properties properties;
183184
cl_command_queue_capabilities_intel capabilities;
184185
cl_uint count;
186+
char name[CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL];
185187
} cl_queue_family_properties_intel;

opencl/source/cl_device/cl_device.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "shared/source/device/sub_device.h"
1313
#include "shared/source/execution_environment/root_device_environment.h"
1414
#include "shared/source/helpers/hw_helper.h"
15+
#include "shared/source/helpers/string.h"
1516
#include "shared/source/os_interface/driver_info.h"
1617
#include "shared/source/os_interface/os_interface.h"
1718
#include "shared/source/program/sync_buffer_handler.h"
@@ -243,4 +244,31 @@ cl_command_queue_capabilities_intel ClDevice::getQueueFamilyCapabilities(EngineG
243244
return CL_QUEUE_DEFAULT_CAPABILITIES_INTEL;
244245
}
245246

247+
void ClDevice::getQueueFamilyName(char *outputName, size_t maxOutputNameLength, EngineGroupType type) {
248+
std::string name{};
249+
250+
const auto &clHwHelper = ClHwHelper::get(getHardwareInfo().platform.eRenderCoreFamily);
251+
const bool hasHwSpecificName = clHwHelper.getQueueFamilyName(name, type);
252+
253+
if (!hasHwSpecificName) {
254+
switch (type) {
255+
case EngineGroupType::RenderCompute:
256+
name = "rcs";
257+
break;
258+
case EngineGroupType::Compute:
259+
name = "ccs";
260+
break;
261+
case EngineGroupType::Copy:
262+
name = "bcs";
263+
break;
264+
default:
265+
name = "";
266+
break;
267+
}
268+
}
269+
270+
UNRECOVERABLE_IF(name.length() > maxOutputNameLength + 1);
271+
strncpy_s(outputName, maxOutputNameLength, name.c_str(), name.size());
272+
}
273+
246274
} // namespace NEO

opencl/source/cl_device/cl_device.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -125,6 +125,7 @@ class ClDevice : public BaseObject<_cl_device_id> {
125125

126126
static cl_command_queue_capabilities_intel getQueueFamilyCapabilitiesAll();
127127
MOCKABLE_VIRTUAL cl_command_queue_capabilities_intel getQueueFamilyCapabilities(EngineGroupType type);
128+
void getQueueFamilyName(char *outputName, size_t maxOutputNameLength, EngineGroupType type);
128129

129130
protected:
130131
void initializeCaps();

opencl/source/cl_device/cl_device_caps.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ void ClDevice::initializeCaps() {
369369
properties.capabilities = getQueueFamilyCapabilities(engineGroupType);
370370
properties.count = static_cast<cl_uint>(enginesInFamily.size());
371371
properties.properties = deviceInfo.queueOnHostProperties;
372+
getQueueFamilyName(properties.name, CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL, engineGroupType);
372373
deviceInfo.queueFamilyProperties.push_back(properties);
373374
}
374375
}

opencl/source/helpers/cl_hw_helper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "engine_group_types.h"
1313
#include "igfxfmid.h"
1414

15+
#include <string>
16+
1517
namespace NEO {
1618

1719
class Context;
@@ -26,6 +28,7 @@ class ClHwHelper {
2628
virtual bool requiresAuxResolves(const KernelInfo &kernelInfo) const = 0;
2729
virtual bool allowRenderCompressionForContext(const HardwareInfo &hwInfo, const Context &context) const = 0;
2830
virtual cl_command_queue_capabilities_intel getAdditionalDisabledQueueFamilyCapabilities(EngineGroupType type) const = 0;
31+
virtual bool getQueueFamilyName(std::string &name, EngineGroupType type) const = 0;
2932

3033
protected:
3134
virtual bool hasStatelessAccessToBuffer(const KernelInfo &kernelInfo) const = 0;
@@ -45,6 +48,7 @@ class ClHwHelperHw : public ClHwHelper {
4548
bool requiresAuxResolves(const KernelInfo &kernelInfo) const override;
4649
bool allowRenderCompressionForContext(const HardwareInfo &hwInfo, const Context &context) const override;
4750
cl_command_queue_capabilities_intel getAdditionalDisabledQueueFamilyCapabilities(EngineGroupType type) const override;
51+
bool getQueueFamilyName(std::string &name, EngineGroupType type) const override;
4852

4953
protected:
5054
bool hasStatelessAccessToBuffer(const KernelInfo &kernelInfo) const override;

opencl/source/helpers/cl_hw_helper_base.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,9 @@ inline bool ClHwHelperHw<GfxFamily>::allowRenderCompressionForContext(const Hard
4242
return true;
4343
}
4444

45+
template <typename GfxFamily>
46+
inline bool ClHwHelperHw<GfxFamily>::getQueueFamilyName(std::string &name, EngineGroupType type) const {
47+
return false;
48+
}
49+
4550
} // namespace NEO

opencl/test/unit_test/device/device_caps_tests.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "shared/test/unit_test/mocks/mock_device.h"
1515

1616
#include "opencl/source/platform/extensions.h"
17+
#include "opencl/test/unit_test/fixtures/device_info_fixture.h"
1718
#include "opencl/test/unit_test/helpers/hw_helper_tests.h"
1819
#include "opencl/test/unit_test/mocks/mock_builtins.h"
1920
#include "opencl/test/unit_test/mocks/mock_execution_environment.h"
@@ -1492,3 +1493,19 @@ TEST_F(DeviceGetCapsTest, givenClDeviceWhenInitializingCapsThenUseGetQueueFamily
14921493
device->initializeCaps();
14931494
EXPECT_EQ(device->queueCaps, device->getDeviceInfo().queueFamilyProperties[0].capabilities);
14941495
}
1496+
1497+
HWTEST_F(QueueFamilyNameTest, givenCcsWhenGettingQueueFamilyNameThenReturnProperValue) {
1498+
verify(EngineGroupType::Compute, "ccs");
1499+
}
1500+
1501+
HWTEST_F(QueueFamilyNameTest, givenRcsWhenGettingQueueFamilyNameThenReturnProperValue) {
1502+
verify(EngineGroupType::RenderCompute, "rcs");
1503+
}
1504+
1505+
HWTEST_F(QueueFamilyNameTest, givenBcsWhenGettingQueueFamilyNameThenReturnProperValue) {
1506+
verify(EngineGroupType::Copy, "bcs");
1507+
}
1508+
1509+
HWTEST_F(QueueFamilyNameTest, givenInvalidEngineGroupWhenGettingQueueFamilyNameThenReturnEmptyName) {
1510+
verify(EngineGroupType::MaxEngineGroups, "");
1511+
}

opencl/test/unit_test/fixtures/device_info_fixture.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -36,4 +36,19 @@ struct GetDeviceInfoMemCapabilitiesTest : ::testing::Test {
3636
}
3737
}
3838
};
39+
40+
struct QueueFamilyNameTest : ::testing::Test {
41+
void SetUp() override {
42+
device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
43+
}
44+
45+
void verify(EngineGroupType type, const char *expectedName) {
46+
char name[CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL];
47+
device->getQueueFamilyName(name, sizeof(name), type);
48+
EXPECT_EQ(0, std::strcmp(name, expectedName));
49+
}
50+
51+
std::unique_ptr<MockClDevice> device = {};
52+
};
53+
3954
} // namespace NEO

0 commit comments

Comments
 (0)