2018-08-23 17:53:58 +02:00
|
|
|
/*
|
2019-01-10 13:57:40 +01:00
|
|
|
* Copyright (C) 2018-2019 Intel Corporation
|
2018-09-18 09:11:08 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
2018-08-23 17:53:58 +02:00
|
|
|
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "runtime/os_interface/linux/os_context_linux.h"
|
|
|
|
|
|
2018-11-26 14:04:52 +01:00
|
|
|
#include "runtime/os_interface/linux/drm_engine_mapper.h"
|
2018-11-08 13:05:46 +01:00
|
|
|
#include "runtime/os_interface/linux/drm_neo.h"
|
|
|
|
|
#include "runtime/os_interface/linux/os_interface.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "runtime/os_interface/os_context.h"
|
2018-08-23 17:53:58 +02:00
|
|
|
|
|
|
|
|
namespace OCLRT {
|
2018-11-08 13:05:46 +01:00
|
|
|
|
2019-02-12 11:31:19 +01:00
|
|
|
OsContext::OsContext(OSInterface *osInterface, uint32_t contextId, uint32_t numDevicesSupported, EngineInstanceT engineType, PreemptionMode preemptionMode)
|
|
|
|
|
: contextId(contextId), numDevicesSupported(numDevicesSupported), engineType(engineType) {
|
2018-11-08 13:05:46 +01:00
|
|
|
if (osInterface) {
|
2018-11-26 14:04:52 +01:00
|
|
|
osContextImpl = std::make_unique<OsContextLinux>(*osInterface->get()->getDrm(), engineType);
|
2018-11-08 13:05:46 +01:00
|
|
|
}
|
2018-08-23 17:53:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OsContext::~OsContext() = default;
|
2018-11-08 13:05:46 +01:00
|
|
|
|
2018-11-26 14:04:52 +01:00
|
|
|
OsContextLinux::OsContextImpl(Drm &drm, EngineInstanceT engineType) : drm(drm) {
|
|
|
|
|
engineFlag = DrmEngineMapper::engineNodeMap(engineType.type);
|
2018-12-11 08:21:56 +01:00
|
|
|
this->drmContextId = drm.createDrmContext();
|
|
|
|
|
if (drm.isPreemptionSupported() &&
|
2019-01-10 13:57:40 +01:00
|
|
|
engineType.type == lowPriorityGpgpuEngine.type &&
|
|
|
|
|
engineType.id == lowPriorityGpgpuEngine.id) {
|
2018-12-11 08:21:56 +01:00
|
|
|
drm.setLowPriorityContextParam(this->drmContextId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OsContextLinux::~OsContextImpl() {
|
|
|
|
|
drm.destroyDrmContext(drmContextId);
|
2018-11-26 14:04:52 +01:00
|
|
|
}
|
2018-08-23 17:53:58 +02:00
|
|
|
} // namespace OCLRT
|