Files
compute-runtime/runtime/os_interface/linux/os_context_linux.cpp
Piotr Fusik 429487fad0 Add constructor parameter to select low priority context.
Change-Id: Ieb3fa008a2f1b54052e393516038c88f00944fa0
Signed-off-by: Piotr Fusik <piotr.fusik@intel.com>
2019-03-18 15:09:59 +01:00

40 lines
1.4 KiB
C++

/*
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/os_interface/linux/os_context_linux.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "runtime/os_interface/linux/drm_neo.h"
#include "runtime/os_interface/linux/os_interface.h"
#include "runtime/os_interface/os_context.h"
namespace OCLRT {
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineInstanceT engineType, PreemptionMode preemptionMode, bool lowPriority) {
if (osInterface) {
return new OsContextLinux(*osInterface->get()->getDrm(), contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
}
return new OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
}
OsContextLinux::OsContextLinux(Drm &drm, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineInstanceT engineType, PreemptionMode preemptionMode, bool lowPriority)
: OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority), drm(drm) {
engineFlag = DrmEngineMapper::engineNodeMap(engineType.type);
this->drmContextId = drm.createDrmContext();
if (drm.isPreemptionSupported() && lowPriority) {
drm.setLowPriorityContextParam(this->drmContextId);
}
}
OsContextLinux::~OsContextLinux() {
drm.destroyDrmContext(drmContextId);
}
} // namespace OCLRT