mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 09:59:39 +08:00
Change-Id: I543df4accdeba6c69b7dcf86d4238d12dafe92fe Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
/*
|
|
* Copyright (C) 2018 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "runtime/os_interface/os_context.h"
|
|
#include "runtime/os_interface/linux/drm_engine_mapper.h"
|
|
#include "runtime/os_interface/linux/drm_neo.h"
|
|
#include "runtime/os_interface/linux/os_context_linux.h"
|
|
#include "runtime/os_interface/linux/os_interface.h"
|
|
|
|
namespace OCLRT {
|
|
|
|
OsContext::OsContext(OSInterface *osInterface, uint32_t contextId, EngineInstanceT engineType, PreemptionMode preemptionMode)
|
|
: contextId(contextId), engineType(engineType) {
|
|
if (osInterface) {
|
|
osContextImpl = std::make_unique<OsContextLinux>(*osInterface->get()->getDrm(), engineType);
|
|
}
|
|
}
|
|
|
|
OsContext::~OsContext() = default;
|
|
|
|
OsContextLinux::OsContextImpl(Drm &drm, EngineInstanceT engineType) : drm(drm) {
|
|
engineFlag = DrmEngineMapper::engineNodeMap(engineType.type);
|
|
this->drmContextId = drm.createDrmContext();
|
|
if (drm.isPreemptionSupported() &&
|
|
engineType.type == gpgpuEngineInstances[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].type &&
|
|
engineType.id == gpgpuEngineInstances[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].id) {
|
|
drm.setLowPriorityContextParam(this->drmContextId);
|
|
}
|
|
}
|
|
|
|
OsContextLinux::~OsContextImpl() {
|
|
drm.destroyDrmContext(drmContextId);
|
|
}
|
|
} // namespace OCLRT
|