Skip to content

Commit 6f6ee90

Browse files
Extend copy engine selector data
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
1 parent d7a2a62 commit 6f6ee90

File tree

8 files changed

+32
-10
lines changed

8 files changed

+32
-10
lines changed

opencl/source/cl_device/cl_device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const HardwareInfo &ClDevice::getHardwareInfo() const { return device.getHardwar
132132
EngineControl &ClDevice::getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) { return device.getEngine(engineType, engineUsage); }
133133
EngineControl &ClDevice::getDefaultEngine() { return device.getDefaultEngine(); }
134134
EngineControl &ClDevice::getInternalEngine() { return device.getInternalEngine(); }
135-
std::atomic<uint32_t> &ClDevice::getSelectorCopyEngine() { return device.getSelectorCopyEngine(); }
135+
SelectorCopyEngine &ClDevice::getSelectorCopyEngine() { return device.getSelectorCopyEngine(); }
136136
MemoryManager *ClDevice::getMemoryManager() const { return device.getMemoryManager(); }
137137
GmmHelper *ClDevice::getGmmHelper() const { return device.getGmmHelper(); }
138138
GmmClientContext *ClDevice::getGmmClientContext() const { return device.getGmmClientContext(); }

opencl/source/cl_device/cl_device.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct EngineControl;
3636
struct HardwareCapabilities;
3737
struct HardwareInfo;
3838
struct RootDeviceEnvironment;
39+
struct SelectorCopyEngine;
3940

4041
template <>
4142
struct OpenCLObjectMapper<_cl_device_id> {
@@ -69,7 +70,7 @@ class ClDevice : public BaseObject<_cl_device_id> {
6970
EngineControl &getDefaultEngine();
7071
EngineControl &getInternalEngine();
7172
EngineControl *getInternalCopyEngine();
72-
std::atomic<uint32_t> &getSelectorCopyEngine();
73+
SelectorCopyEngine &getSelectorCopyEngine();
7374
MemoryManager *getMemoryManager() const;
7475
GmmHelper *getGmmHelper() const;
7576
GmmClientContext *getGmmClientContext() const;

opencl/source/command_queue/command_queue.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ CommandQueue *CommandQueue::create(Context *context,
6060
}
6161

6262
CommandQueue::CommandQueue(Context *context, ClDevice *device, const cl_queue_properties *properties)
63+
: CommandQueue(context, device, properties, false) {}
64+
65+
CommandQueue::CommandQueue(Context *context, ClDevice *device, const cl_queue_properties *properties, bool internalUsage)
6366
: context(context), device(device) {
6467
if (context) {
6568
context->incRefInternal();
@@ -83,8 +86,10 @@ CommandQueue::CommandQueue(Context *context, ClDevice *device, const cl_queue_pr
8386
deferredTimestampPackets = std::make_unique<TimestampPacketContainer>();
8487
}
8588
if (bcsAllowed) {
86-
auto &selectorCopyEngine = device->getDeviceById(0)->getSelectorCopyEngine();
87-
bcsEngine = device->getDeviceById(0)->getDevice().tryGetEngine(EngineHelpers::getBcsEngineType(hwInfo, selectorCopyEngine), EngineUsage::Regular);
89+
auto &neoDevice = device->getDeviceById(0)->getDevice();
90+
auto &selectorCopyEngine = neoDevice.getSelectorCopyEngine();
91+
auto bcsEngineType = EngineHelpers::getBcsEngineType(hwInfo, selectorCopyEngine, internalUsage);
92+
bcsEngine = neoDevice.tryGetEngine(bcsEngineType, EngineUsage::Regular);
8893
}
8994
}
9095

@@ -109,6 +114,11 @@ CommandQueue::~CommandQueue() {
109114
if (this->perfCountersEnabled) {
110115
device->getPerformanceCounters()->shutdown();
111116
}
117+
118+
if (bcsEngine) {
119+
auto &selectorCopyEngine = device->getDeviceById(0)->getSelectorCopyEngine();
120+
EngineHelpers::releaseBcsEngineType(bcsEngine->getEngineType(), selectorCopyEngine);
121+
}
112122
}
113123

114124
timestampPacketContainer.reset();

opencl/source/command_queue/command_queue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
6767

6868
CommandQueue() = delete;
6969

70+
CommandQueue(Context *context, ClDevice *device, const cl_queue_properties *properties, bool internalUsage);
71+
7072
CommandQueue(Context *context, ClDevice *device,
7173
const cl_queue_properties *properties);
7274

opencl/source/command_queue/command_queue_hw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class CommandQueueHw : public CommandQueue {
3636
CommandQueueHw(Context *context,
3737
ClDevice *device,
3838
const cl_queue_properties *properties,
39-
bool internalUsage) : BaseClass(context, device, properties) {
39+
bool internalUsage) : BaseClass(context, device, properties, internalUsage) {
4040

4141
auto clPriority = getCmdQueueProperties<cl_queue_priority_khr>(properties, CL_QUEUE_PRIORITY_KHR);
4242

shared/source/device/device.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class OSTime;
2626
class SourceLevelDebugger;
2727
class SubDevice;
2828

29+
struct SelectorCopyEngine : NonCopyableOrMovableClass {
30+
std::atomic<bool> isMainUsed = false;
31+
std::atomic<uint32_t> selector = 0;
32+
};
33+
2934
class Device : public ReferenceTrackedObject<Device> {
3035
public:
3136
Device &operator=(const Device &) = delete;
@@ -60,7 +65,7 @@ class Device : public ReferenceTrackedObject<Device> {
6065
EngineControl &getDefaultEngine();
6166
EngineControl &getInternalEngine();
6267
EngineControl *getInternalCopyEngine();
63-
std::atomic<uint32_t> &getSelectorCopyEngine();
68+
SelectorCopyEngine &getSelectorCopyEngine();
6469
MemoryManager *getMemoryManager() const;
6570
GmmHelper *getGmmHelper() const;
6671
GmmClientContext *getGmmClientContext() const;
@@ -166,7 +171,7 @@ class Device : public ReferenceTrackedObject<Device> {
166171
bool hasGenericSubDevices = false;
167172
bool engineInstanced = false;
168173

169-
std::atomic<uint32_t> selectorCopyEngine{0};
174+
SelectorCopyEngine selectorCopyEngine = {};
170175

171176
DeviceBitfield deviceBitfield = 1;
172177

@@ -195,7 +200,7 @@ inline BuiltIns *Device::getBuiltIns() const {
195200
return executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->getBuiltIns();
196201
}
197202

198-
inline std::atomic<uint32_t> &Device::getSelectorCopyEngine() {
203+
inline SelectorCopyEngine &Device::getSelectorCopyEngine() {
199204
return selectorCopyEngine;
200205
}
201206

shared/source/helpers/engine_node_helper.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace NEO {
1717
struct HardwareInfo;
18+
struct SelectorCopyEngine;
1819

1920
enum class EngineUsage : uint32_t {
2021
Regular,
@@ -29,7 +30,8 @@ using EngineTypeUsage = std::pair<aub_stream::EngineType, EngineUsage>;
2930
namespace EngineHelpers {
3031
bool isCcs(aub_stream::EngineType engineType);
3132
bool isBcs(aub_stream::EngineType engineType);
32-
aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, std::atomic<uint32_t> &selectorCopyEngine);
33+
aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, SelectorCopyEngine &selectorCopyEngine, bool internalUsage = false);
34+
void releaseBcsEngineType(aub_stream::EngineType engineType, SelectorCopyEngine &selectorCopyEngine);
3335

3436
std::string engineTypeToString(aub_stream::EngineType engineType);
3537
std::string engineTypeToStringAdditional(aub_stream::EngineType engineType);

shared/source/helpers/engine_node_helper_extra.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ bool isBcs(aub_stream::EngineType engineType) {
1313
return engineType == aub_stream::ENGINE_BCS;
1414
}
1515

16-
aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, std::atomic<uint32_t> &selectorCopyEngine) {
16+
aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, SelectorCopyEngine &selectorCopyEngine, bool internalUsage) {
1717
return aub_stream::EngineType::ENGINE_BCS;
1818
}
1919

20+
void releaseBcsEngineType(aub_stream::EngineType engineType, SelectorCopyEngine &selectorCopyEngine) {}
21+
2022
std::string engineTypeToStringAdditional(aub_stream::EngineType engineType) {
2123
return "Unknown";
2224
}

0 commit comments

Comments
 (0)