2018-06-22 18:54:33 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018, Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
2018-06-27 17:35:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "runtime/execution_environment/execution_environment.h"
|
2018-07-16 23:11:43 +08:00
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
2018-07-03 16:00:12 +08:00
|
|
|
#include "runtime/gmm_helper/gmm_helper.h"
|
2018-07-16 23:11:43 +08:00
|
|
|
#include "runtime/memory_manager/memory_manager.h"
|
2018-06-27 17:35:37 +08:00
|
|
|
#include "runtime/os_interface/device_factory.h"
|
|
|
|
|
2018-07-03 16:00:12 +08:00
|
|
|
namespace OCLRT {
|
|
|
|
ExecutionEnvironment::ExecutionEnvironment() = default;
|
2018-07-12 17:45:02 +08:00
|
|
|
ExecutionEnvironment::~ExecutionEnvironment() = default;
|
2018-07-16 23:11:43 +08:00
|
|
|
extern CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo);
|
|
|
|
|
2018-07-03 16:00:12 +08:00
|
|
|
void ExecutionEnvironment::initGmm(const HardwareInfo *hwInfo) {
|
2018-07-16 22:37:17 +08:00
|
|
|
if (!gmmHelper) {
|
|
|
|
gmmHelper.reset(new GmmHelper(hwInfo));
|
|
|
|
}
|
2018-07-03 16:00:12 +08:00
|
|
|
}
|
2018-07-16 23:11:43 +08:00
|
|
|
bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *pHwInfo) {
|
2018-07-17 17:11:48 +08:00
|
|
|
if (this->commandStreamReceiver) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-07-16 23:11:43 +08:00
|
|
|
CommandStreamReceiver *commandStreamReceiver = createCommandStream(pHwInfo);
|
|
|
|
if (!commandStreamReceiver) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
this->commandStreamReceiver.reset(commandStreamReceiver);
|
|
|
|
return true;
|
|
|
|
}
|
2018-07-20 15:01:58 +08:00
|
|
|
void ExecutionEnvironment::initializeMemoryManager(bool enable64KBpages) {
|
2018-07-17 17:11:48 +08:00
|
|
|
if (this->memoryManager) {
|
|
|
|
commandStreamReceiver->setMemoryManager(this->memoryManager.get());
|
|
|
|
return;
|
|
|
|
}
|
2018-07-20 15:01:58 +08:00
|
|
|
|
|
|
|
memoryManager.reset(commandStreamReceiver->createMemoryManager(enable64KBpages));
|
|
|
|
commandStreamReceiver->setMemoryManager(memoryManager.get());
|
|
|
|
|
2018-07-16 23:11:43 +08:00
|
|
|
DEBUG_BREAK_IF(!this->memoryManager);
|
|
|
|
}
|
|
|
|
|
2018-07-03 16:00:12 +08:00
|
|
|
} // namespace OCLRT
|