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