mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
Make sure that devices reuse memory manager and command stream receiver.
- initialize them only once per execution environment - initialize tag allocation only once Change-Id: Ic816c81a84320aeb66b09d333bec69a92fe0859b
This commit is contained in:
committed by
sys_ocldev
parent
8da3da402f
commit
aa71442d50
@@ -349,6 +349,9 @@ void CommandStreamReceiver::setExperimentalCmdBuffer(std::unique_ptr<Experimenta
|
||||
}
|
||||
|
||||
bool CommandStreamReceiver::initializeTagAllocation() {
|
||||
if (tagAllocation) {
|
||||
return true;
|
||||
}
|
||||
auto tagAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
|
||||
if (!tagAllocation) {
|
||||
return false;
|
||||
|
||||
@@ -35,6 +35,9 @@ void ExecutionEnvironment::initGmm(const HardwareInfo *hwInfo) {
|
||||
gmmHelper.reset(new GmmHelper(hwInfo));
|
||||
}
|
||||
bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *pHwInfo) {
|
||||
if (this->commandStreamReceiver) {
|
||||
return true;
|
||||
}
|
||||
CommandStreamReceiver *commandStreamReceiver = createCommandStream(pHwInfo);
|
||||
if (!commandStreamReceiver) {
|
||||
return false;
|
||||
@@ -43,6 +46,10 @@ bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *p
|
||||
return true;
|
||||
}
|
||||
void ExecutionEnvironment::initializeMemoryManager(MemoryManager *externalMemoryManager, bool enable64KBpages) {
|
||||
if (this->memoryManager) {
|
||||
commandStreamReceiver->setMemoryManager(this->memoryManager.get());
|
||||
return;
|
||||
}
|
||||
if (!externalMemoryManager) {
|
||||
memoryManager.reset(commandStreamReceiver->createMemoryManager(enable64KBpages));
|
||||
commandStreamReceiver->setMemoryManager(memoryManager.get());
|
||||
|
||||
@@ -156,3 +156,14 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
|
||||
executionEnvironment.reset(nullptr);
|
||||
EXPECT_EQ(3u, destructorId);
|
||||
}
|
||||
|
||||
TEST(ExecutionEnvironment, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseTheSameMemoryManagerAndCommandStreamReceiver) {
|
||||
auto executionEnvironment = new ExecutionEnvironment;
|
||||
std::unique_ptr<Device> device(Device::create<OCLRT::Device>(nullptr, executionEnvironment));
|
||||
auto &commandStreamReceiver = device->getCommandStreamReceiver();
|
||||
auto memoryManager = device->getMemoryManager();
|
||||
|
||||
std::unique_ptr<Device> device2(Device::create<OCLRT::Device>(nullptr, executionEnvironment));
|
||||
EXPECT_EQ(&commandStreamReceiver, &device->getCommandStreamReceiver());
|
||||
EXPECT_EQ(memoryManager, device2->getMemoryManager());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user