2018-08-23 23:53:58 +08:00
|
|
|
/*
|
2021-02-10 23:13:50 +08:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2018-08-23 23:53:58 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2018-08-23 23:53:58 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/preemption_mode.h"
|
|
|
|
#include "shared/source/helpers/common_types.h"
|
2021-03-09 02:50:32 +08:00
|
|
|
#include "shared/source/helpers/engine_node_helper.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/utilities/reference_tracked_object.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2018-11-26 21:04:52 +08:00
|
|
|
#include "engine_node.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2018-08-23 23:53:58 +08:00
|
|
|
#include <memory>
|
2018-08-27 21:48:29 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-08-23 23:53:58 +08:00
|
|
|
class OSInterface;
|
2018-12-10 17:30:39 +08:00
|
|
|
|
2021-02-10 23:13:50 +08:00
|
|
|
struct DirectSubmissionProperties;
|
|
|
|
struct HardwareInfo;
|
|
|
|
|
2018-08-27 21:48:29 +08:00
|
|
|
class OsContext : public ReferenceTrackedObject<OsContext> {
|
2018-08-23 23:53:58 +08:00
|
|
|
public:
|
2019-02-27 18:17:17 +08:00
|
|
|
OsContext() = delete;
|
2018-08-23 23:53:58 +08:00
|
|
|
|
2019-03-18 20:57:59 +08:00
|
|
|
static OsContext *create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
|
2021-03-09 02:50:32 +08:00
|
|
|
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice);
|
2018-12-10 17:30:39 +08:00
|
|
|
uint32_t getContextId() const { return contextId; }
|
2019-03-06 01:50:10 +08:00
|
|
|
uint32_t getNumSupportedDevices() const { return numSupportedDevices; }
|
2019-03-13 22:00:07 +08:00
|
|
|
DeviceBitfield getDeviceBitfield() const { return deviceBitfield; }
|
2019-02-27 18:17:17 +08:00
|
|
|
PreemptionMode getPreemptionMode() const { return preemptionMode; }
|
2019-03-27 17:06:29 +08:00
|
|
|
aub_stream::EngineType &getEngineType() { return engineType; }
|
2021-03-09 02:50:32 +08:00
|
|
|
bool isLowPriority() const { return engineUsage == EngineUsage::LowPriority; }
|
|
|
|
bool isInternalEngine() const { return engineUsage == EngineUsage::Internal; }
|
2020-03-04 06:33:31 +08:00
|
|
|
bool isRootDevice() const { return rootDevice; }
|
2019-12-19 21:02:05 +08:00
|
|
|
virtual bool isInitialized() const { return true; }
|
2020-03-07 02:02:24 +08:00
|
|
|
bool isDefaultContext() const { return defaultContext; }
|
|
|
|
void setDefaultContext(bool value) { defaultContext = value; }
|
2020-10-15 14:48:58 +08:00
|
|
|
bool isDirectSubmissionActive() { return directSubmissionActive; }
|
|
|
|
void setDirectSubmissionActive() { directSubmissionActive = true; }
|
2018-09-06 21:54:29 +08:00
|
|
|
|
2021-02-10 23:13:50 +08:00
|
|
|
bool isDirectSubmissionAvailable(const HardwareInfo &hwInfo, bool &submitOnInit);
|
|
|
|
bool checkDirectSubmissionSupportsEngine(const DirectSubmissionProperties &directSubmissionProperty,
|
|
|
|
aub_stream::EngineType contextEngineType,
|
|
|
|
bool &startOnInit,
|
|
|
|
bool &startInContext);
|
|
|
|
|
2018-08-23 23:53:58 +08:00
|
|
|
protected:
|
2021-03-09 02:50:32 +08:00
|
|
|
OsContext(uint32_t contextId, DeviceBitfield deviceBitfield, EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice)
|
2019-03-13 22:00:07 +08:00
|
|
|
: contextId(contextId),
|
|
|
|
deviceBitfield(deviceBitfield),
|
|
|
|
preemptionMode(preemptionMode),
|
|
|
|
numSupportedDevices(static_cast<uint32_t>(deviceBitfield.count())),
|
2021-03-09 02:50:32 +08:00
|
|
|
engineType(typeUsage.first),
|
|
|
|
engineUsage(typeUsage.second),
|
2020-03-04 06:33:31 +08:00
|
|
|
rootDevice(rootDevice) {}
|
2019-02-27 18:17:17 +08:00
|
|
|
|
2019-02-12 18:31:19 +08:00
|
|
|
const uint32_t contextId;
|
2019-03-13 22:00:07 +08:00
|
|
|
const DeviceBitfield deviceBitfield;
|
2019-02-27 18:17:17 +08:00
|
|
|
const PreemptionMode preemptionMode;
|
2019-03-13 22:00:07 +08:00
|
|
|
const uint32_t numSupportedDevices;
|
2019-03-27 17:06:29 +08:00
|
|
|
aub_stream::EngineType engineType = aub_stream::ENGINE_RCS;
|
2021-03-09 02:50:32 +08:00
|
|
|
const EngineUsage engineUsage;
|
2020-03-04 06:33:31 +08:00
|
|
|
const bool rootDevice = false;
|
2020-03-07 02:02:24 +08:00
|
|
|
bool defaultContext = false;
|
2020-10-15 14:48:58 +08:00
|
|
|
bool directSubmissionActive = false;
|
2018-08-23 23:53:58 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|