mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00

Change-Id: I7f0c9a9a13cae5cbf831e0d4e410c78c001a75d1 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
/*
|
|
* Copyright (C) 2020 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
|
|
|
#include "shared/source/device/device.h"
|
|
#include "shared/source/os_interface/device_factory.h"
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_cl_execution_environment.h"
|
|
|
|
namespace NEO {
|
|
|
|
bool initPlatform() {
|
|
auto pPlatform = platform();
|
|
return pPlatform->initialize(DeviceFactory::createDevices(*pPlatform->peekExecutionEnvironment()));
|
|
}
|
|
bool MockPlatform::initializeWithNewDevices() {
|
|
executionEnvironment.prepareRootDeviceEnvironments(1u);
|
|
return Platform::initialize(DeviceFactory::createDevices(executionEnvironment));
|
|
}
|
|
|
|
Platform *platform() {
|
|
if (platformsImpl->empty()) {
|
|
return nullptr;
|
|
}
|
|
return (*platformsImpl)[0].get();
|
|
}
|
|
|
|
Platform *constructPlatform() {
|
|
static std::mutex mutex;
|
|
std::unique_lock<std::mutex> lock(mutex);
|
|
if (platformsImpl->empty()) {
|
|
platformsImpl->push_back(std::make_unique<Platform>(*(new MockClExecutionEnvironment())));
|
|
}
|
|
return (*platformsImpl)[0].get();
|
|
}
|
|
} // namespace NEO
|