Files
compute-runtime/runtime/os_interface/os_context.h
Pawel Wilma a1bfbcf293 Fix typo for DeviceBitfield
Change-Id: I21718950f3d1b17ad507af76762153aefb090615
Signed-off-by: Pawel Wilma <pawel.wilma@intel.com>
2019-03-12 08:21:14 +01:00

50 lines
1.7 KiB
C++

/*
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "common/helpers/bit_helpers.h"
#include "runtime/command_stream/preemption_mode.h"
#include "runtime/utilities/reference_tracked_object.h"
#include "engine_node.h"
#include <limits>
#include <memory>
namespace OCLRT {
class OSInterface;
class OsContext : public ReferenceTrackedObject<OsContext> {
public:
OsContext() = delete;
static OsContext *create(OSInterface *osInterface, uint32_t contextId, uint32_t deviceBitfiled, EngineInstanceT engineType, PreemptionMode preemptionMode);
uint32_t getContextId() const { return contextId; }
uint32_t getNumSupportedDevices() const { return numSupportedDevices; }
uint8_t getDeviceBitfield() const { return deviceBitfield; }
PreemptionMode getPreemptionMode() const { return preemptionMode; }
EngineInstanceT &getEngineType() { return engineType; }
protected:
OsContext(uint32_t contextId, uint32_t deviceBitfiled, EngineInstanceT engineType, PreemptionMode preemptionMode)
: contextId(contextId), deviceBitfield(deviceBitfiled), preemptionMode(preemptionMode), engineType(engineType) {
constexpr uint32_t maxIndex = std::numeric_limits<decltype(deviceBitfiled)>::digits;
for (uint32_t deviceIndex = 0; deviceIndex < maxIndex; deviceIndex++) {
if (isBitSet(deviceBitfiled, deviceIndex)) {
numSupportedDevices++;
}
}
};
const uint32_t contextId;
const uint32_t deviceBitfield;
const PreemptionMode preemptionMode;
uint32_t numSupportedDevices = 0;
EngineInstanceT engineType = {EngineType::ENGINE_RCS, 0};
};
} // namespace OCLRT