Move builtins and compiler interface to RootDeviceEnvironment

Resolves: NEO-4355
Change-Id: Id1a3365673165d775a60a7e0a3f463e1b8f5a496
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-02-27 15:32:57 +01:00
committed by sys_ocldev
parent ab3ae5fea7
commit 7cf57e04f9
45 changed files with 187 additions and 156 deletions

View File

@@ -24,8 +24,9 @@ ExecutionEnvironment::ExecutionEnvironment() {
ExecutionEnvironment::~ExecutionEnvironment() {
debugger.reset();
compilerInterface.reset();
builtins.reset();
for (auto &rootDeviceEnvironment : rootDeviceEnvironments) {
rootDeviceEnvironment->builtins.reset();
}
if (memoryManager) {
memoryManager->commonCleanup();
}
@@ -77,27 +78,6 @@ void ExecutionEnvironment::calculateMaxOsContextCount() {
}
}
CompilerInterface *ExecutionEnvironment::getCompilerInterface() {
if (this->compilerInterface.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx);
if (this->compilerInterface.get() == nullptr) {
auto cache = std::make_unique<CompilerCache>(getDefaultCompilerCacheConfig());
this->compilerInterface.reset(CompilerInterface::createInstance(std::move(cache), true));
}
}
return this->compilerInterface.get();
}
BuiltIns *ExecutionEnvironment::getBuiltIns() {
if (this->builtins.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx);
if (this->builtins.get() == nullptr) {
this->builtins = std::make_unique<BuiltIns>();
}
}
return this->builtins.get();
}
bool ExecutionEnvironment::isFullRangeSvm() const {
return hwInfo->capabilityTable.gpuAddressSpace >= maxNBitValue(47);
}

View File

@@ -6,25 +6,17 @@
*/
#pragma once
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/utilities/reference_tracked_object.h"
#include <mutex>
#include <vector>
namespace NEO {
class BuiltIns;
class CompilerInterface;
class GmmClientContext;
class GmmHelper;
class MemoryManager;
class Debugger;
struct RootDeviceEnvironment;
struct HardwareInfo;
class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment> {
private:
std::mutex mtx;
protected:
std::unique_ptr<HardwareInfo> hwInfo;
@@ -42,13 +34,8 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
bool isFullRangeSvm() const;
void prepareRootDeviceEnvironments(uint32_t numRootDevices);
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface();
BuiltIns *getBuiltIns();
std::unique_ptr<MemoryManager> memoryManager;
std::vector<std::unique_ptr<RootDeviceEnvironment>> rootDeviceEnvironments;
std::unique_ptr<BuiltIns> builtins;
std::unique_ptr<CompilerInterface> compilerInterface;
std::unique_ptr<Debugger> debugger;
};
} // namespace NEO

View File

@@ -7,6 +7,9 @@
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/built_ins/built_ins.h"
#include "shared/source/compiler_interface/compiler_interface.h"
#include "shared/source/compiler_interface/default_cache_config.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/gmm_helper/page_table_mngr.h"
@@ -42,4 +45,24 @@ void RootDeviceEnvironment::initGmm() {
}
}
CompilerInterface *RootDeviceEnvironment::getCompilerInterface() {
if (this->compilerInterface.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx);
if (this->compilerInterface.get() == nullptr) {
auto cache = std::make_unique<CompilerCache>(getDefaultCompilerCacheConfig());
this->compilerInterface.reset(CompilerInterface::createInstance(std::move(cache), true));
}
}
return this->compilerInterface.get();
}
BuiltIns *RootDeviceEnvironment::getBuiltIns() {
if (this->builtins.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx);
if (this->builtins.get() == nullptr) {
this->builtins = std::make_unique<BuiltIns>();
}
}
return this->builtins.get();
}
} // namespace NEO

View File

@@ -10,10 +10,13 @@
#include <cstdint>
#include <memory>
#include <mutex>
#include <string>
namespace NEO {
class BuiltIns;
class CompilerInterface;
class AubCenter;
class GmmClientContext;
class GmmHelper;
@@ -35,12 +38,20 @@ struct RootDeviceEnvironment {
void initGmm();
GmmHelper *getGmmHelper() const;
GmmClientContext *getGmmClientContext() const;
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface();
BuiltIns *getBuiltIns();
std::unique_ptr<GmmHelper> gmmHelper;
std::unique_ptr<OSInterface> osInterface;
std::unique_ptr<GmmPageTableMngr> pageTableManager;
std::unique_ptr<MemoryOperationsHandler> memoryOperationsInterface;
std::unique_ptr<AubCenter> aubCenter;
std::unique_ptr<BuiltIns> builtins;
std::unique_ptr<CompilerInterface> compilerInterface;
ExecutionEnvironment &executionEnvironment;
private:
std::mutex mtx;
};
} // namespace NEO