Files
compute-runtime/shared/source/os_interface/os_context.h
Spruit, Neil R 02f075c541 Power Saving Hint Support for Level Zero in Windows
- Added Functionality to pass ze_power_saving_hint_type_t to zeContextCreate
included in the pNext extensions in ze_context_desc_t.
- Enables handling a hint value 0-100 with 0 being no power savings
and 100 being maximum power savings.
- ZE_RESULT_ERROR_INVALID_ENUMERATION is returned given an invalid hint.

Related-To: LOCI-2567

Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
2022-01-06 23:56:59 +01:00

80 lines
3.3 KiB
C++

/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/command_stream/preemption_mode.h"
#include "shared/source/helpers/common_types.h"
#include "shared/source/helpers/engine_node_helper.h"
#include "shared/source/utilities/reference_tracked_object.h"
#include "engine_node.h"
#include <memory>
#include <mutex>
namespace NEO {
class OSInterface;
struct DirectSubmissionProperties;
struct HardwareInfo;
class OsContext : public ReferenceTrackedObject<OsContext> {
public:
OsContext(uint32_t contextId, const EngineDescriptor &engineDescriptor);
static OsContext *create(OSInterface *osInterface, uint32_t contextId, const EngineDescriptor &engineDescriptor);
bool isImmediateContextInitializationEnabled(bool isDefaultEngine) const;
bool isInitialized() const { return contextInitialized; }
void ensureContextInitialized();
uint32_t getContextId() const { return contextId; }
uint32_t getNumSupportedDevices() const { return numSupportedDevices; }
DeviceBitfield getDeviceBitfield() const { return deviceBitfield; }
PreemptionMode getPreemptionMode() const { return preemptionMode; }
aub_stream::EngineType &getEngineType() { return engineType; }
EngineUsage getEngineUsage() { return engineUsage; }
bool isRegular() const { return engineUsage == EngineUsage::Regular; }
bool isLowPriority() const { return engineUsage == EngineUsage::LowPriority; }
bool isInternalEngine() const { return engineUsage == EngineUsage::Internal; }
bool isCooperativeEngine() const { return engineUsage == EngineUsage::Cooperative; }
bool isRootDevice() const { return rootDevice; }
bool isEngineInstanced() const { return engineInstancedDevice; }
virtual bool isDirectSubmissionSupported(const HardwareInfo &hwInfo) const { return false; }
bool isDefaultContext() const { return defaultContext; }
void setDefaultContext(bool value) { defaultContext = value; }
bool isDirectSubmissionActive() { return directSubmissionActive; }
void setDirectSubmissionActive() { directSubmissionActive = true; }
bool isDirectSubmissionAvailable(const HardwareInfo &hwInfo, bool &submitOnInit);
bool checkDirectSubmissionSupportsEngine(const DirectSubmissionProperties &directSubmissionProperty,
aub_stream::EngineType contextEngineType,
bool &startOnInit,
bool &startInContext);
virtual void reInitializeContext() {}
uint8_t getUmdPowerHintValue() { return powerHintValue; }
void setUmdPowerHintValue(uint8_t powerHintValue) { this->powerHintValue = powerHintValue; }
protected:
virtual void initializeContext() {}
const uint32_t contextId;
const DeviceBitfield deviceBitfield;
const PreemptionMode preemptionMode;
const uint32_t numSupportedDevices;
aub_stream::EngineType engineType = aub_stream::ENGINE_RCS;
const EngineUsage engineUsage;
const bool rootDevice = false;
bool defaultContext = false;
bool directSubmissionActive = false;
bool directSubmissionAvailableChecked = false;
std::once_flag contextInitializedFlag = {};
bool contextInitialized = false;
bool engineInstancedDevice = false;
uint8_t powerHintValue = 0;
};
} // namespace NEO