mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Move SVM allocs memory manager to L0::Context (1/N)
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
47256642c3
commit
9080e2ee5b
@@ -128,6 +128,10 @@ struct Context : _ze_context_handle_t {
|
||||
virtual ze_result_t createImage(ze_device_handle_t hDevice,
|
||||
const ze_image_desc_t *desc,
|
||||
ze_image_handle_t *phImage) = 0;
|
||||
virtual NEO::MemoryManager *getMemoryManager() = 0;
|
||||
virtual void setMemoryManager(NEO::MemoryManager *memoryManager) = 0;
|
||||
virtual NEO::SVMAllocsManager *getSvmAllocsManager() = 0;
|
||||
virtual void setSvmAllocsManager(NEO::SVMAllocsManager *) = 0;
|
||||
|
||||
static Context *fromHandle(ze_context_handle_t handle) { return static_cast<Context *>(handle); }
|
||||
inline ze_context_handle_t toHandle() { return this; }
|
||||
|
||||
@@ -18,6 +18,15 @@
|
||||
namespace L0 {
|
||||
|
||||
ze_result_t ContextImp::destroy() {
|
||||
if (this->svmAllocsManager) {
|
||||
delete this->svmAllocsManager;
|
||||
this->svmAllocsManager = nullptr;
|
||||
}
|
||||
|
||||
if (this->driverHandle->mainContext == this) {
|
||||
this->driverHandle->mainContext = nullptr;
|
||||
}
|
||||
|
||||
delete this;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
@@ -78,7 +87,7 @@ ze_result_t ContextImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc,
|
||||
this->rootDeviceIndices,
|
||||
this->deviceBitfields);
|
||||
|
||||
auto usmPtr = this->driverHandle->svmAllocsManager->createHostUnifiedMemoryAllocation(size,
|
||||
auto usmPtr = this->driverHandle->getSvmAllocsManager()->createHostUnifiedMemoryAllocation(size,
|
||||
unifiedMemoryProperties);
|
||||
if (usmPtr == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
@@ -157,7 +166,7 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
|
||||
}
|
||||
|
||||
void *usmPtr =
|
||||
this->driverHandle->svmAllocsManager->createUnifiedMemoryAllocation(size, unifiedMemoryProperties);
|
||||
this->driverHandle->getSvmAllocsManager()->createUnifiedMemoryAllocation(size, unifiedMemoryProperties);
|
||||
if (usmPtr == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
}
|
||||
@@ -216,7 +225,7 @@ ze_result_t ContextImp::allocSharedMem(ze_device_handle_t hDevice,
|
||||
}
|
||||
|
||||
auto usmPtr =
|
||||
this->driverHandle->svmAllocsManager->createSharedUnifiedMemoryAllocation(size,
|
||||
this->driverHandle->getSvmAllocsManager()->createSharedUnifiedMemoryAllocation(size,
|
||||
unifiedMemoryProperties,
|
||||
static_cast<void *>(neoDevice->getSpecializedDevice<L0::Device>()));
|
||||
|
||||
@@ -229,7 +238,7 @@ ze_result_t ContextImp::allocSharedMem(ze_device_handle_t hDevice,
|
||||
}
|
||||
|
||||
ze_result_t ContextImp::freeMem(const void *ptr) {
|
||||
auto allocation = this->driverHandle->svmAllocsManager->getSVMAlloc(ptr);
|
||||
auto allocation = this->driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
if (allocation == nullptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
@@ -244,13 +253,13 @@ ze_result_t ContextImp::freeMem(const void *ptr) {
|
||||
auto peerAllocData = &iter->second;
|
||||
auto peerAlloc = peerAllocData->gpuAllocations.getDefaultGraphicsAllocation();
|
||||
auto peerPtr = reinterpret_cast<void *>(peerAlloc->getGpuAddress());
|
||||
this->driverHandle->svmAllocsManager->freeSVMAlloc(peerPtr);
|
||||
this->driverHandle->getSvmAllocsManager()->freeSVMAlloc(peerPtr);
|
||||
}
|
||||
}
|
||||
|
||||
this->driverHandle->svmAllocsManager->freeSVMAlloc(const_cast<void *>(ptr));
|
||||
if (this->driverHandle->svmAllocsManager->getSvmMapOperation(ptr)) {
|
||||
this->driverHandle->svmAllocsManager->removeSvmMapOperation(ptr);
|
||||
this->driverHandle->getSvmAllocsManager()->freeSVMAlloc(const_cast<void *>(ptr));
|
||||
if (this->driverHandle->getSvmAllocsManager()->getSvmMapOperation(ptr)) {
|
||||
this->driverHandle->getSvmAllocsManager()->removeSvmMapOperation(ptr);
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
@@ -326,7 +335,7 @@ ze_result_t ContextImp::evictImage(ze_device_handle_t hDevice, ze_image_handle_t
|
||||
ze_result_t ContextImp::getMemAddressRange(const void *ptr,
|
||||
void **pBase,
|
||||
size_t *pSize) {
|
||||
NEO::SvmAllocationData *allocData = this->driverHandle->svmAllocsManager->getSVMAlloc(ptr);
|
||||
NEO::SvmAllocationData *allocData = this->driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
if (allocData) {
|
||||
NEO::GraphicsAllocation *alloc;
|
||||
alloc = allocData->gpuAllocations.getDefaultGraphicsAllocation();
|
||||
@@ -351,7 +360,7 @@ ze_result_t ContextImp::closeIpcMemHandle(const void *ptr) {
|
||||
|
||||
ze_result_t ContextImp::getIpcMemHandle(const void *ptr,
|
||||
ze_ipc_mem_handle_t *pIpcHandle) {
|
||||
NEO::SvmAllocationData *allocData = this->driverHandle->svmAllocsManager->getSVMAlloc(ptr);
|
||||
NEO::SvmAllocationData *allocData = this->driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
if (allocData) {
|
||||
uint64_t handle = allocData->gpuAllocations.getDefaultGraphicsAllocation()->peekInternalHandle(this->driverHandle->getMemoryManager());
|
||||
memcpy_s(reinterpret_cast<void *>(pIpcHandle->data),
|
||||
@@ -385,7 +394,7 @@ ze_result_t ContextImp::openIpcMemHandle(ze_device_handle_t hDevice,
|
||||
ze_result_t ContextImp::getMemAllocProperties(const void *ptr,
|
||||
ze_memory_allocation_properties_t *pMemAllocProperties,
|
||||
ze_device_handle_t *phDevice) {
|
||||
auto alloc = driverHandle->svmAllocsManager->getSVMAlloc(ptr);
|
||||
auto alloc = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
if (nullptr == alloc) {
|
||||
pMemAllocProperties->type = ZE_MEMORY_TYPE_UNKNOWN;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -115,11 +115,28 @@ struct ContextImp : Context {
|
||||
return devices;
|
||||
}
|
||||
|
||||
NEO::MemoryManager *getMemoryManager() override {
|
||||
return this->memoryManager;
|
||||
}
|
||||
void setMemoryManager(NEO::MemoryManager *memoryManager) override {
|
||||
this->memoryManager = memoryManager;
|
||||
}
|
||||
NEO::SVMAllocsManager *getSvmAllocsManager() override {
|
||||
return this->svmAllocsManager;
|
||||
}
|
||||
|
||||
void setSvmAllocsManager(NEO::SVMAllocsManager *svmManager) override {
|
||||
this->svmAllocsManager = svmManager;
|
||||
}
|
||||
|
||||
std::set<uint32_t> rootDeviceIndices = {};
|
||||
std::map<uint32_t, NEO::DeviceBitfield> deviceBitfields;
|
||||
|
||||
bool isDeviceDefinedForThisContext(Device *inDevice);
|
||||
|
||||
NEO::MemoryManager *memoryManager = nullptr;
|
||||
NEO::SVMAllocsManager *svmAllocsManager = nullptr;
|
||||
|
||||
protected:
|
||||
std::map<ze_device_handle_t, Device *> devices;
|
||||
DriverHandleImp *driverHandle = nullptr;
|
||||
|
||||
@@ -47,6 +47,7 @@ struct DriverHandle : _ze_driver_handle_t {
|
||||
bool *allocationRangeCovered) = 0;
|
||||
|
||||
virtual NEO::SVMAllocsManager *getSvmAllocsManager() = 0;
|
||||
virtual void setSvmAllocsManager(NEO::SVMAllocsManager *) = 0;
|
||||
virtual ze_result_t sysmanEventsListen(uint32_t timeout, uint32_t count, zes_device_handle_t *phDevices,
|
||||
uint32_t *pNumDeviceEvents, zes_event_type_flags_t *pEvents) = 0;
|
||||
virtual ze_result_t sysmanEventsListenEx(uint64_t timeout, uint32_t count, zes_device_handle_t *phDevices,
|
||||
|
||||
@@ -53,13 +53,22 @@ ze_result_t DriverHandleImp::createContext(const ze_context_desc_t *desc,
|
||||
}
|
||||
}
|
||||
|
||||
bool multiOsContextDriver = false;
|
||||
for (auto devicePair : context->getDevices()) {
|
||||
auto neoDevice = devicePair.second->getNEODevice();
|
||||
multiOsContextDriver |= devicePair.second->isMultiDeviceCapable();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(),
|
||||
neoDevice->getDeviceBitfield()});
|
||||
}
|
||||
|
||||
if (this->mainContext == nullptr) {
|
||||
this->mainContext = context;
|
||||
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), multiOsContextDriver));
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -72,7 +81,11 @@ void DriverHandleImp::setMemoryManager(NEO::MemoryManager *memoryManager) {
|
||||
}
|
||||
|
||||
NEO::SVMAllocsManager *DriverHandleImp::getSvmAllocsManager() {
|
||||
return this->svmAllocsManager;
|
||||
return this->mainContext->getSvmAllocsManager();
|
||||
}
|
||||
|
||||
void DriverHandleImp::setSvmAllocsManager(NEO::SVMAllocsManager *svmManager) {
|
||||
this->mainContext->setSvmAllocsManager(svmManager);
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::getApiVersion(ze_api_version_t *version) {
|
||||
@@ -133,10 +146,6 @@ DriverHandleImp::~DriverHandleImp() {
|
||||
for (auto &device : this->devices) {
|
||||
delete device;
|
||||
}
|
||||
if (this->svmAllocsManager) {
|
||||
delete this->svmAllocsManager;
|
||||
this->svmAllocsManager = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>> neoDevices) {
|
||||
@@ -153,9 +162,6 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
|
||||
|
||||
if (this->memoryManager == nullptr) {
|
||||
this->memoryManager = neoDevice->getMemoryManager();
|
||||
if (this->memoryManager == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
const auto rootDeviceIndex = neoDevice->getRootDeviceIndex();
|
||||
@@ -189,11 +195,6 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
this->svmAllocsManager = new NEO::SVMAllocsManager(memoryManager, multiOsContextDriver);
|
||||
if (this->svmAllocsManager == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
this->numDevices = static_cast<uint32_t>(this->devices.size());
|
||||
|
||||
extensionFunctionsLookupMap = getExtensionFunctionsLookupMap();
|
||||
@@ -250,8 +251,8 @@ bool DriverHandleImp::findAllocationDataForRange(const void *buffer,
|
||||
NEO::SvmAllocationData **allocData) {
|
||||
// Make sure the host buffer does not overlap any existing allocation
|
||||
const char *baseAddress = reinterpret_cast<const char *>(buffer);
|
||||
NEO::SvmAllocationData *beginAllocData = svmAllocsManager->getSVMAlloc(baseAddress);
|
||||
NEO::SvmAllocationData *endAllocData = svmAllocsManager->getSVMAlloc(baseAddress + size - 1);
|
||||
NEO::SvmAllocationData *beginAllocData = this->getSvmAllocsManager()->getSVMAlloc(baseAddress);
|
||||
NEO::SvmAllocationData *endAllocData = this->getSvmAllocsManager()->getSVMAlloc(baseAddress + size - 1);
|
||||
|
||||
if (allocData) {
|
||||
if (beginAllocData) {
|
||||
@@ -275,8 +276,8 @@ std::vector<NEO::SvmAllocationData *> DriverHandleImp::findAllocationsWithinRang
|
||||
std::vector<NEO::SvmAllocationData *> allocDataArray;
|
||||
const char *baseAddress = reinterpret_cast<const char *>(buffer);
|
||||
// Check if the host buffer overlaps any existing allocation
|
||||
NEO::SvmAllocationData *beginAllocData = svmAllocsManager->getSVMAlloc(baseAddress);
|
||||
NEO::SvmAllocationData *endAllocData = svmAllocsManager->getSVMAlloc(baseAddress + size - 1);
|
||||
NEO::SvmAllocationData *beginAllocData = this->getSvmAllocsManager()->getSVMAlloc(baseAddress);
|
||||
NEO::SvmAllocationData *endAllocData = this->getSvmAllocsManager()->getSVMAlloc(baseAddress + size - 1);
|
||||
|
||||
// Add the allocation that matches the beginning address
|
||||
if (beginAllocData) {
|
||||
|
||||
@@ -10,11 +10,13 @@
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include "level_zero/api/extensions/public/ze_exp_ext.h"
|
||||
#include "level_zero/core/source/context/context.h"
|
||||
#include "level_zero/core/source/driver/driver_handle.h"
|
||||
#include "level_zero/core/source/get_extension_function_lookup_map.h"
|
||||
|
||||
namespace L0 {
|
||||
class HostPointerManager;
|
||||
struct Context;
|
||||
|
||||
struct DriverHandleImp : public DriverHandle {
|
||||
~DriverHandleImp() override;
|
||||
@@ -38,6 +40,7 @@ struct DriverHandleImp : public DriverHandle {
|
||||
ze_result_t openEventPoolIpcHandle(ze_ipc_event_pool_handle_t hIpc, ze_event_pool_handle_t *phEventPool) override;
|
||||
ze_result_t checkMemoryAccessFromDevice(Device *device, const void *ptr) override;
|
||||
NEO::SVMAllocsManager *getSvmAllocsManager() override;
|
||||
void setSvmAllocsManager(NEO::SVMAllocsManager *) override;
|
||||
ze_result_t initialize(std::vector<std::unique_ptr<NEO::Device>> neoDevices);
|
||||
bool findAllocationDataForRange(const void *buffer,
|
||||
size_t size,
|
||||
@@ -91,10 +94,11 @@ struct DriverHandleImp : public DriverHandle {
|
||||
uint64_t uuidTimestamp = 0u;
|
||||
|
||||
NEO::MemoryManager *memoryManager = nullptr;
|
||||
NEO::SVMAllocsManager *svmAllocsManager = nullptr;
|
||||
|
||||
uint32_t numDevices = 0;
|
||||
|
||||
Context *mainContext = nullptr;
|
||||
|
||||
std::set<uint32_t> rootDeviceIndices = {};
|
||||
std::map<uint32_t, NEO::DeviceBitfield> deviceBitfields;
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, Context *context, uin
|
||||
alignedSize,
|
||||
allocationType,
|
||||
false,
|
||||
(deviceBitfield.count() > 1) && driverHandleImp->svmAllocsManager->getMultiOsContextSupport(),
|
||||
(deviceBitfield.count() > 1) && driverHandleImp->getSvmAllocsManager()->getMultiOsContextSupport(),
|
||||
deviceBitfield};
|
||||
unifiedMemoryProperties.flags.isUSMHostAllocation = true;
|
||||
unifiedMemoryProperties.flags.isUSMDeviceAllocation = false;
|
||||
|
||||
@@ -51,7 +51,7 @@ void *DriverHandleImp::importFdHandle(ze_device_handle_t hDevice, ze_ipc_memory_
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::checkMemoryAccessFromDevice(Device *device, const void *ptr) {
|
||||
auto allocation = svmAllocsManager->getSVMAlloc(ptr);
|
||||
auto allocation = this->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
if (allocation == nullptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
@@ -31,17 +31,23 @@ class CommandListFixture : public DeviceFixture {
|
||||
eventDesc.wait = 0;
|
||||
eventDesc.signal = 0;
|
||||
|
||||
eventPool = std::unique_ptr<EventPool>(EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc));
|
||||
event = std::unique_ptr<Event>(Event::create(eventPool.get(), &eventDesc, device));
|
||||
eventPool = EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc);
|
||||
event = Event::create(eventPool, &eventDesc, device);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (event) {
|
||||
event->destroy();
|
||||
}
|
||||
if (eventPool) {
|
||||
eventPool->destroy();
|
||||
}
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
std::unique_ptr<L0::ult::CommandList> commandList;
|
||||
std::unique_ptr<EventPool> eventPool;
|
||||
std::unique_ptr<Event> event;
|
||||
EventPool *eventPool = nullptr;
|
||||
Event *event = nullptr;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_compilers.h"
|
||||
|
||||
#include "level_zero/core/source/context/context_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
#include "level_zero/core/test/unit_tests/mock.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_device.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
||||
#include "level_zero/core/test/unit_tests/white_box.h"
|
||||
|
||||
namespace L0 {
|
||||
struct Context;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_host_pointer_manager.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -39,29 +38,29 @@ struct HostPointerManagerFixure {
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
|
||||
DebugManager.flags.EnableHostPointerImport.set(1);
|
||||
hostDriverHandle = std::make_unique<L0::ult::DriverHandle>();
|
||||
hostDriverHandle = std::make_unique<L0::DriverHandleImp>();
|
||||
hostDriverHandle->initialize(std::move(devices));
|
||||
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t ret = hostDriverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
context = L0::Context::fromHandle(hContext);
|
||||
|
||||
device = hostDriverHandle->devices[0];
|
||||
EXPECT_NE(nullptr, hostDriverHandle->hostPointerManager.get());
|
||||
openHostPointerManager = static_cast<L0::ult::HostPointerManager *>(hostDriverHandle->hostPointerManager.get());
|
||||
|
||||
heapPointer = hostDriverHandle->getMemoryManager()->allocateSystemMemory(heapSize, MemoryConstants::pageSize);
|
||||
ASSERT_NE(nullptr, heapPointer);
|
||||
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t ret = hostDriverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
context = L0::Context::fromHandle(hContext);
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
context->destroy();
|
||||
|
||||
hostDriverHandle->getMemoryManager()->freeSystemMemory(heapPointer);
|
||||
context->destroy();
|
||||
}
|
||||
DebugManagerStateRestore debugRestore;
|
||||
|
||||
std::unique_ptr<L0::ult::DriverHandle> hostDriverHandle;
|
||||
std::unique_ptr<L0::DriverHandleImp> hostDriverHandle;
|
||||
|
||||
L0::ult::HostPointerManager *openHostPointerManager = nullptr;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
|
||||
@@ -147,7 +147,7 @@ struct ModuleImmutableDataFixture : public DeviceFixture {
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
module = std::make_unique<MockModule>(device,
|
||||
module = new MockModule(device,
|
||||
moduleBuildLog,
|
||||
ModuleType::User,
|
||||
perHwThreadPrivateMemorySize,
|
||||
@@ -165,13 +165,16 @@ struct ModuleImmutableDataFixture : public DeviceFixture {
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (module) {
|
||||
module->destroy();
|
||||
}
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
const std::string binaryFilename = "test_kernel";
|
||||
const std::string kernelName = "test";
|
||||
const uint32_t numKernelArguments = 6;
|
||||
std::unique_ptr<MockModule> module;
|
||||
MockModule *module = nullptr;
|
||||
MockImmutableMemoryManager *memoryManager;
|
||||
};
|
||||
|
||||
@@ -201,27 +204,36 @@ struct ModuleFixture : public DeviceFixture {
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
module.reset(Module::create(device, &moduleDesc, moduleBuildLog, type));
|
||||
if (module) {
|
||||
module->destroy();
|
||||
}
|
||||
module = Module::create(device, &moduleDesc, moduleBuildLog, type);
|
||||
}
|
||||
|
||||
void createKernel() {
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
|
||||
kernel = std::make_unique<WhiteBox<::L0::Kernel>>();
|
||||
kernel->module = module.get();
|
||||
kernel = new WhiteBox<::L0::Kernel>();
|
||||
kernel->module = module;
|
||||
kernel->initialize(&desc);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (kernel) {
|
||||
kernel->destroy();
|
||||
}
|
||||
if (module) {
|
||||
module->destroy();
|
||||
}
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
const std::string binaryFilename = "test_kernel";
|
||||
const std::string kernelName = "test";
|
||||
const uint32_t numKernelArguments = 6;
|
||||
std::unique_ptr<L0::Module> module;
|
||||
std::unique_ptr<WhiteBox<::L0::Kernel>> kernel;
|
||||
L0::Module *module = nullptr;
|
||||
WhiteBox<::L0::Kernel> *kernel = nullptr;
|
||||
};
|
||||
|
||||
struct MultiDeviceModuleFixture : public MultiDeviceFixture {
|
||||
@@ -248,29 +260,35 @@ struct MultiDeviceModuleFixture : public MultiDeviceFixture {
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
auto device = driverHandle->devices[rootDeviceIndex];
|
||||
modules[rootDeviceIndex].reset(Module::create(device,
|
||||
modules[rootDeviceIndex] = Module::create(device,
|
||||
&moduleDesc,
|
||||
moduleBuildLog, ModuleType::User));
|
||||
moduleBuildLog, ModuleType::User);
|
||||
}
|
||||
|
||||
void createKernel(uint32_t rootDeviceIndex) {
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
|
||||
kernel = std::make_unique<WhiteBox<::L0::Kernel>>();
|
||||
kernel->module = modules[rootDeviceIndex].get();
|
||||
kernel = new WhiteBox<::L0::Kernel>();
|
||||
kernel->module = modules[rootDeviceIndex];
|
||||
kernel->initialize(&desc);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (kernel) {
|
||||
kernel->destroy();
|
||||
}
|
||||
for (auto &module : modules) {
|
||||
module->destroy();
|
||||
}
|
||||
MultiDeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
const std::string binaryFilename = "test_kernel";
|
||||
const std::string kernelName = "test";
|
||||
const uint32_t numKernelArguments = 6;
|
||||
std::vector<std::unique_ptr<L0::Module>> modules;
|
||||
std::unique_ptr<WhiteBox<::L0::Kernel>> kernel;
|
||||
std::vector<L0::Module *> modules;
|
||||
WhiteBox<::L0::Kernel> *kernel = nullptr;
|
||||
};
|
||||
|
||||
struct ImportHostPointerModuleFixture : public ModuleFixture {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_compilers.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/source/context/context_imp.h"
|
||||
#include "level_zero/core/source/driver/driver_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
@@ -38,9 +39,14 @@ struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
|
||||
|
||||
auto driverHandleUlt = whitebox_cast(DriverHandle::create(std::move(devices), L0EnvVariables{}, &returnValue));
|
||||
driverHandle.reset(driverHandleUlt);
|
||||
|
||||
ASSERT_NE(nullptr, driverHandle);
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc = {};
|
||||
returnValue = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
ze_device_handle_t hDevice;
|
||||
uint32_t count = 1;
|
||||
ze_result_t result = driverHandle->getDevice(&count, &hDevice);
|
||||
@@ -63,6 +69,7 @@ struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
|
||||
void TearDown() override {
|
||||
commandList->destroy();
|
||||
commandQueue->destroy();
|
||||
context->destroy();
|
||||
L0::GlobalDriver = nullptr;
|
||||
}
|
||||
|
||||
@@ -72,6 +79,7 @@ struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
|
||||
std::unique_ptr<L0::ult::WhiteBox<L0::DriverHandle>> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device;
|
||||
L0::ContextImp *context = nullptr;
|
||||
};
|
||||
|
||||
HWTEST2_F(CommandQueueThreadArbitrationPolicyTests,
|
||||
|
||||
@@ -32,18 +32,20 @@ struct TimestampEvent : public Test<DeviceFixture> {
|
||||
eventDesc.signal = 0;
|
||||
eventDesc.wait = 0;
|
||||
|
||||
eventPool = std::unique_ptr<L0::EventPool>(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc));
|
||||
eventPool = L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc);
|
||||
ASSERT_NE(nullptr, eventPool);
|
||||
event = std::unique_ptr<L0::Event>(L0::Event::create(eventPool.get(), &eventDesc, device));
|
||||
event = L0::Event::create(eventPool, &eventDesc, device);
|
||||
ASSERT_NE(nullptr, event);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
event->destroy();
|
||||
eventPool->destroy();
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
std::unique_ptr<L0::EventPool> eventPool;
|
||||
std::unique_ptr<L0::Event> event;
|
||||
L0::EventPool *eventPool = nullptr;
|
||||
L0::Event *event = nullptr;
|
||||
};
|
||||
|
||||
GEN12LPTEST_F(TimestampEvent, givenEventTimestampsWhenQueryKernelTimestampThenCorrectDataAreSet) {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue/cmdqueue_imp.h"
|
||||
#include "level_zero/core/source/context/context_imp.h"
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
#include "level_zero/core/source/driver/driver_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
@@ -40,9 +41,14 @@ struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
|
||||
|
||||
auto driverHandleUlt = whitebox_cast(DriverHandle::create(std::move(devices), L0EnvVariables{}, &returnValue));
|
||||
driverHandle.reset(driverHandleUlt);
|
||||
|
||||
ASSERT_NE(nullptr, driverHandle);
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc = {};
|
||||
returnValue = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
ze_device_handle_t hDevice;
|
||||
uint32_t count = 1;
|
||||
ze_result_t result = driverHandle->getDevice(&count, &hDevice);
|
||||
@@ -65,6 +71,7 @@ struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
|
||||
void TearDown() override {
|
||||
commandList->destroy();
|
||||
commandQueue->destroy();
|
||||
context->destroy();
|
||||
L0::GlobalDriver = nullptr;
|
||||
}
|
||||
|
||||
@@ -74,6 +81,7 @@ struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
|
||||
std::unique_ptr<L0::ult::WhiteBox<L0::DriverHandle>> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device;
|
||||
L0::ContextImp *context = nullptr;
|
||||
};
|
||||
|
||||
HWTEST2_F(CommandQueueThreadArbitrationPolicyTests,
|
||||
|
||||
@@ -25,8 +25,6 @@ set(L0_MOCKS_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_device_recompile_built_ins.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_driver.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_driver.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_driver_handle.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_driver_handle.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_event.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_event.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_resource_info_l0.cpp
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "level_zero/core/source/driver/host_pointer_manager.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
using MockDriverHandle = Mock<L0::ult::DriverHandle>;
|
||||
using namespace testing;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::Return;
|
||||
|
||||
Mock<DriverHandle>::Mock() = default;
|
||||
|
||||
NEO::MemoryManager *Mock<DriverHandle>::getMemoryManager() {
|
||||
return memoryManager;
|
||||
}
|
||||
|
||||
NEO::SVMAllocsManager *Mock<DriverHandle>::getSvmAllocManager() {
|
||||
return svmAllocsManager;
|
||||
}
|
||||
|
||||
ze_result_t Mock<DriverHandle>::getDevice(uint32_t *pCount, ze_device_handle_t *phDevices) {
|
||||
if (*pCount == 0) { // User wants to know number of devices
|
||||
*pCount = this->num_devices;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
if (phDevices == nullptr) // User is expected to allocate space
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
phDevices[0] = &this->device;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t Mock<DriverHandle>::allocDeviceMem(ze_device_handle_t hDevice, const ze_device_mem_alloc_desc_t *deviceDesc,
|
||||
size_t size, size_t alignment, void **ptr) {
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY, rootDeviceIndices, deviceBitfields);
|
||||
|
||||
auto allocation = svmAllocsManager->createUnifiedMemoryAllocation(size, unifiedMemoryProperties);
|
||||
|
||||
if (allocation == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
}
|
||||
|
||||
*ptr = allocation;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t Mock<DriverHandle>::freeMem(const void *ptr) {
|
||||
auto allocation = svmAllocsManager->getSVMAlloc(ptr);
|
||||
if (allocation == nullptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
svmAllocsManager->freeSVMAlloc(const_cast<void *>(ptr));
|
||||
if (svmAllocsManager->getSvmMapOperation(ptr)) {
|
||||
svmAllocsManager->removeSvmMapOperation(ptr);
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void Mock<DriverHandle>::setupDevices(std::vector<std::unique_ptr<NEO::Device>> neoDevices) {
|
||||
this->numDevices = static_cast<uint32_t>(neoDevices.size());
|
||||
for (auto &neoDevice : neoDevices) {
|
||||
ze_result_t returnValue = ZE_RESULT_SUCCESS;
|
||||
this->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
this->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
auto device = Device::create(this, neoDevice.release(), std::numeric_limits<uint32_t>::max(), false, &returnValue);
|
||||
this->devices.push_back(device);
|
||||
}
|
||||
}
|
||||
|
||||
Mock<DriverHandle>::~Mock(){};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/mock.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_device.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
||||
#include "level_zero/core/test/unit_tests/white_box.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
template <>
|
||||
struct WhiteBox<::L0::DriverHandle> : public ::L0::DriverHandleImp {
|
||||
using ::L0::DriverHandleImp::enableProgramDebugging;
|
||||
};
|
||||
|
||||
using DriverHandle = WhiteBox<::L0::DriverHandle>;
|
||||
#define ADDMETHOD_NOBASE(funcName, retType, defaultReturn, funcParams) \
|
||||
retType funcName##Result = defaultReturn; \
|
||||
uint32_t funcName##Called = 0u; \
|
||||
retType funcName funcParams override { \
|
||||
funcName##Called++; \
|
||||
return funcName##Result; \
|
||||
}
|
||||
|
||||
template <>
|
||||
struct Mock<DriverHandle> : public DriverHandleImp {
|
||||
Mock();
|
||||
~Mock() override;
|
||||
|
||||
ADDMETHOD_NOBASE(getProperties, ze_result_t, ZE_RESULT_SUCCESS, (ze_driver_properties_t * properties))
|
||||
ADDMETHOD_NOBASE(getApiVersion, ze_result_t, ZE_RESULT_SUCCESS, (ze_api_version_t * version))
|
||||
ADDMETHOD_NOBASE(getIPCProperties, ze_result_t, ZE_RESULT_SUCCESS, (ze_driver_ipc_properties_t * pIPCProperties))
|
||||
|
||||
uint32_t num_devices = 1;
|
||||
Mock<Device> device;
|
||||
|
||||
void setupDevices(std::vector<std::unique_ptr<NEO::Device>> devices);
|
||||
|
||||
ze_result_t freeMem(const void *ptr);
|
||||
ze_result_t getDevice(uint32_t *pCount,
|
||||
ze_device_handle_t *phDevices) override;
|
||||
NEO::MemoryManager *getMemoryManager() override;
|
||||
NEO::SVMAllocsManager *getSvmAllocManager();
|
||||
ze_result_t allocDeviceMem(ze_device_handle_t hDevice,
|
||||
const ze_device_mem_alloc_desc_t *deviceDesc,
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
void **ptr);
|
||||
|
||||
ze_result_t importExternalPointer(void *ptr, size_t size) override {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t releaseImportedPointer(void *ptr) override {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t getHostPointerBaseAddress(void *ptr, void **baseAddress) override {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
NEO::GraphicsAllocation *findHostPointerAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) override {
|
||||
return nullptr;
|
||||
}
|
||||
NEO::GraphicsAllocation *getDriverSystemMemoryAllocation(void *ptr,
|
||||
size_t size,
|
||||
uint32_t rootDeviceIndex,
|
||||
uintptr_t *gpuAddress) override {
|
||||
auto svmData = svmAllocsManager->getSVMAlloc(ptr);
|
||||
if (svmData != nullptr) {
|
||||
if (gpuAddress != nullptr) {
|
||||
*gpuAddress = reinterpret_cast<uintptr_t>(ptr);
|
||||
}
|
||||
return svmData->gpuAllocations.getGraphicsAllocation(rootDeviceIndex);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
#undef ADDMETHOD_NOBASE
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -200,7 +200,7 @@ HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithPrintfUsedWhenAppendedToC
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
EXPECT_EQ(1u, commandList->getPrintfFunctionContainer().size());
|
||||
EXPECT_EQ(kernel.get(), commandList->getPrintfFunctionContainer()[0]);
|
||||
EXPECT_EQ(kernel, commandList->getPrintfFunctionContainer()[0]);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithPrintfUsedWhenAppendedToCommandListMultipleTimesThenKernelIsStoredOnce) {
|
||||
@@ -215,7 +215,7 @@ HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithPrintfUsedWhenAppendedToC
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
EXPECT_EQ(1u, commandList->getPrintfFunctionContainer().size());
|
||||
EXPECT_EQ(kernel.get(), commandList->getPrintfFunctionContainer()[0]);
|
||||
EXPECT_EQ(kernel, commandList->getPrintfFunctionContainer()[0]);
|
||||
|
||||
result = commandList->appendLaunchKernel(kernel->toHandle(), &groupCount, nullptr, 0, nullptr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
@@ -595,9 +595,9 @@ HWTEST_F(CommandListAppendLaunchKernel, givenIndirectDispatchWhenAppendingThenWo
|
||||
using MI_LOAD_REGISTER_REG = typename FamilyType::MI_LOAD_REGISTER_REG;
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
|
||||
Mock<::L0::Kernel> kernel;
|
||||
kernel.descriptor.payloadMappings.dispatchTraits.numWorkGroups[0] = 2;
|
||||
kernel.descriptor.payloadMappings.dispatchTraits.globalWorkSize[0] = 2;
|
||||
Mock<::L0::Kernel> mockKernel;
|
||||
mockKernel.descriptor.payloadMappings.dispatchTraits.numWorkGroups[0] = 2;
|
||||
mockKernel.descriptor.payloadMappings.dispatchTraits.globalWorkSize[0] = 2;
|
||||
ze_result_t returnValue;
|
||||
std::unique_ptr<L0::CommandList> commandList(L0::CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue));
|
||||
|
||||
@@ -606,7 +606,7 @@ HWTEST_F(CommandListAppendLaunchKernel, givenIndirectDispatchWhenAppendingThenWo
|
||||
auto result = context->allocDeviceMem(device->toHandle(), &deviceDesc, 16384u, 4096u, &alloc);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
result = commandList->appendLaunchKernelIndirect(kernel.toHandle(),
|
||||
result = commandList->appendLaunchKernelIndirect(mockKernel.toHandle(),
|
||||
static_cast<ze_group_count_t *>(alloc),
|
||||
nullptr, 0, nullptr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
@@ -112,7 +112,7 @@ HWTEST_F(CommandListAppendWaitOnEvent, givenEventWithWaitScopeFlagDeviceWhenAppe
|
||||
0,
|
||||
ZE_EVENT_SCOPE_FLAG_DEVICE};
|
||||
|
||||
auto event = std::unique_ptr<Event>(Event::create(eventPool.get(), &eventDesc, device));
|
||||
auto event = std::unique_ptr<Event>(Event::create(eventPool, &eventDesc, device));
|
||||
ze_event_handle_t hEventHandle = event->toHandle();
|
||||
|
||||
auto result = commandList->appendWaitOnEvents(1, &hEventHandle);
|
||||
|
||||
@@ -85,11 +85,19 @@ HWTEST2_F(AppendMemoryCopy, givenCopyOnlyCommandListWhenAppenBlitFillThenCopyBlt
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT;
|
||||
MockCommandListForMemFill<gfxCoreFamily> commandList;
|
||||
|
||||
MockDriverHandle driverHandleMock;
|
||||
NEO::DeviceVector neoDevices;
|
||||
neoDevices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandleMock.initialize(std::move(neoDevices));
|
||||
device->setDriverHandle(&driverHandleMock);
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandleMock.createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
L0::ContextImp *contextDriverMock = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
commandList.initialize(device, NEO::EngineGroupType::Copy);
|
||||
uint16_t pattern = 1;
|
||||
void *ptr = reinterpret_cast<void *>(0x1234);
|
||||
@@ -99,6 +107,7 @@ HWTEST2_F(AppendMemoryCopy, givenCopyOnlyCommandListWhenAppenBlitFillThenCopyBlt
|
||||
cmdList, ptrOffset(commandList.commandContainer.getCommandStream()->getCpuBase(), 0), commandList.commandContainer.getCommandStream()->getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
contextDriverMock->destroy();
|
||||
device->setDriverHandle(driverHandle.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -80,11 +80,18 @@ class AppendFillFixture : public DeviceFixture, public ::testing::Test {
|
||||
driverHandle = std::make_unique<Mock<MockDriverFillHandle>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete[] immediateDstPtr;
|
||||
delete[] dstPtr;
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
std::unique_ptr<Mock<MockDriverFillHandle>> driverHandle;
|
||||
@@ -94,6 +101,7 @@ class AppendFillFixture : public DeviceFixture, public ::testing::Test {
|
||||
static constexpr size_t patternSize = 8;
|
||||
uint8_t *dstPtr = nullptr;
|
||||
uint8_t pattern[patternSize] = {1, 2, 3, 4};
|
||||
L0::ContextImp *context = nullptr;
|
||||
|
||||
static constexpr size_t immediateAllocSize = 106;
|
||||
uint8_t immediatePattern = 4;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "level_zero/core/source/image/image.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/host_pointer_manager_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -159,23 +158,9 @@ struct ContextHostAllocTests : public ::testing::Test {
|
||||
driverHandle = std::make_unique<DriverHandleImp>();
|
||||
ze_result_t res = driverHandle->initialize(std::move(devices));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
prevSvmAllocsManager = driverHandle->svmAllocsManager;
|
||||
currSvmAllocsManager = new SVMAllocsManagerContextMock(driverHandle->memoryManager);
|
||||
driverHandle->svmAllocsManager = currSvmAllocsManager;
|
||||
|
||||
zeDevices.resize(numberOfDevicesInContext);
|
||||
driverHandle->getDevice(&numberOfDevicesInContext, zeDevices.data());
|
||||
|
||||
for (uint32_t i = 0; i < numberOfDevicesInContext; i++) {
|
||||
L0::DeviceImp *deviceImp = static_cast<L0::DeviceImp *>(L0::Device::fromHandle(zeDevices[i]));
|
||||
currSvmAllocsManager->expectedRootDeviceIndexes.push_back(deviceImp->getRootDeviceIndex());
|
||||
}
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
driverHandle->svmAllocsManager = prevSvmAllocsManager;
|
||||
delete currSvmAllocsManager;
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
@@ -189,6 +174,9 @@ struct ContextHostAllocTests : public ::testing::Test {
|
||||
|
||||
TEST_F(ContextHostAllocTests,
|
||||
whenAllocatingHostMemoryOnlyIndexesOfDevicesWithinTheContextAreUsed) {
|
||||
zeDevices.resize(numberOfDevicesInContext);
|
||||
driverHandle->getDevice(&numberOfDevicesInContext, zeDevices.data());
|
||||
|
||||
L0::ContextImp *context = nullptr;
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
@@ -199,6 +187,15 @@ TEST_F(ContextHostAllocTests,
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
prevSvmAllocsManager = context->getSvmAllocsManager();
|
||||
currSvmAllocsManager = new SVMAllocsManagerContextMock(context->getMemoryManager());
|
||||
context->setSvmAllocsManager(currSvmAllocsManager);
|
||||
|
||||
for (uint32_t i = 0; i < numberOfDevicesInContext; i++) {
|
||||
L0::DeviceImp *deviceImp = static_cast<L0::DeviceImp *>(L0::Device::fromHandle(zeDevices[i]));
|
||||
currSvmAllocsManager->expectedRootDeviceIndexes.push_back(deviceImp->getRootDeviceIndex());
|
||||
}
|
||||
|
||||
void *hostPtr = nullptr;
|
||||
ze_host_mem_alloc_desc_t hostDesc = {};
|
||||
size_t size = 1024;
|
||||
@@ -209,6 +206,9 @@ TEST_F(ContextHostAllocTests,
|
||||
res = context->freeMem(hostPtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
context->setSvmAllocsManager(prevSvmAllocsManager);
|
||||
delete currSvmAllocsManager;
|
||||
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_source_level_debugger.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue/cmdqueue_hw.h"
|
||||
#include "level_zero/core/source/context/context_imp.h"
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
#include "level_zero/core/source/fence/fence.h"
|
||||
#include "level_zero/core/source/module/module.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_device.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -54,6 +54,12 @@ struct ActiveDebuggerFixture {
|
||||
|
||||
ASSERT_NE(nullptr, driverHandle);
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
ze_device_handle_t hDevice;
|
||||
uint32_t count = 1;
|
||||
ze_result_t result = driverHandle->getDevice(&count, &hDevice);
|
||||
@@ -62,6 +68,7 @@ struct ActiveDebuggerFixture {
|
||||
ASSERT_NE(nullptr, deviceL0);
|
||||
}
|
||||
void TearDown() { // NOLINT(readability-identifier-naming)
|
||||
context->destroy();
|
||||
L0::GlobalDriver = nullptr;
|
||||
}
|
||||
|
||||
@@ -70,6 +77,7 @@ struct ActiveDebuggerFixture {
|
||||
L0::Device *deviceL0;
|
||||
MockActiveSourceLevelDebugger *debugger = nullptr;
|
||||
HardwareInfo hwInfo;
|
||||
L0::ContextImp *context = nullptr;
|
||||
};
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -38,15 +38,23 @@ struct L0DebuggerFixture {
|
||||
|
||||
driverHandle->initialize(std::move(devices));
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
NEO::HardwareInfo hwInfo;
|
||||
L0::ContextImp *context = nullptr;
|
||||
};
|
||||
|
||||
struct L0DebuggerHwFixture : public L0DebuggerFixture {
|
||||
|
||||
@@ -23,8 +23,11 @@
|
||||
#include "level_zero/core/source/context/context_imp.h"
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
#include "level_zero/core/source/driver/host_pointer_manager.h"
|
||||
#include "level_zero/core/test/unit_tests/mock.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_device.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
||||
#include "level_zero/core/test/unit_tests/white_box.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -192,6 +195,16 @@ struct DeviceTest : public ::testing::Test {
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
@@ -200,6 +213,7 @@ struct DeviceTest : public ::testing::Test {
|
||||
L0::Device *device = nullptr;
|
||||
const uint32_t rootDeviceIndex = 1u;
|
||||
const uint32_t numRootDevices = 2u;
|
||||
L0::ContextImp *context = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(DeviceTest, givenEmptySVmAllocStorageWhenAllocateManagedMemoryFromHostPtrThenBufferHostAllocationIsCreated) {
|
||||
@@ -248,12 +262,19 @@ struct DeviceHostPointerTest : public ::testing::Test {
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
static_cast<MockMemoryManager *>(driverHandle.get()->getMemoryManager())->isMockHostMemoryManager = true;
|
||||
static_cast<MockMemoryManager *>(driverHandle.get()->getMemoryManager())->forceFailureInAllocationWithHostPointer = true;
|
||||
|
||||
device = driverHandle->devices[0];
|
||||
}
|
||||
void TearDown() override {
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
NEO::ExecutionEnvironment *executionEnvironment = nullptr;
|
||||
@@ -262,6 +283,7 @@ struct DeviceHostPointerTest : public ::testing::Test {
|
||||
L0::Device *device = nullptr;
|
||||
const uint32_t rootDeviceIndex = 1u;
|
||||
const uint32_t numRootDevices = 2u;
|
||||
L0::ContextImp *context = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(DeviceHostPointerTest, givenHostPointerNotAcceptedByKernelThenNewAllocationIsCreatedAndHostPointerCopied) {
|
||||
|
||||
@@ -165,10 +165,11 @@ TEST(DriverTest, givenNullEnvVariableWhenCreatingDriverThenEnableProgramDebuggin
|
||||
L0EnvVariables envVariables = {};
|
||||
envVariables.programDebugging = false;
|
||||
|
||||
auto driverHandle = whitebox_cast(DriverHandle::create(std::move(devices), envVariables, &returnValue));
|
||||
auto driverHandle = DriverHandle::create(std::move(devices), envVariables, &returnValue);
|
||||
EXPECT_NE(nullptr, driverHandle);
|
||||
|
||||
EXPECT_FALSE(driverHandle->enableProgramDebugging);
|
||||
DriverHandleImp *driverHandleImp = static_cast<DriverHandleImp *>(driverHandle);
|
||||
EXPECT_FALSE(driverHandleImp->enableProgramDebugging);
|
||||
|
||||
delete driverHandle;
|
||||
L0::GlobalDriver = nullptr;
|
||||
@@ -262,10 +263,11 @@ TEST(DriverTest, givenProgramDebuggingEnvVarNonZeroWhenCreatingDriverThenEnableP
|
||||
L0EnvVariables envVariables = {};
|
||||
envVariables.programDebugging = true;
|
||||
|
||||
auto driverHandle = whitebox_cast(DriverHandle::create(std::move(devices), envVariables, &returnValue));
|
||||
auto driverHandle = DriverHandle::create(std::move(devices), envVariables, &returnValue);
|
||||
EXPECT_NE(nullptr, driverHandle);
|
||||
|
||||
EXPECT_TRUE(driverHandle->enableProgramDebugging);
|
||||
DriverHandleImp *driverHandleImp = static_cast<DriverHandleImp *>(driverHandle);
|
||||
EXPECT_TRUE(driverHandleImp->enableProgramDebugging);
|
||||
|
||||
delete driverHandle;
|
||||
L0::GlobalDriver = nullptr;
|
||||
@@ -381,13 +383,21 @@ struct DriverHandleTest : public ::testing::Test {
|
||||
|
||||
driverHandle = whitebox_cast(DriverHandle::create(std::move(devices), envVariables, &returnValue));
|
||||
L0::GlobalDriverHandle = driverHandle;
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
}
|
||||
void TearDown() override {
|
||||
context->destroy();
|
||||
delete driverHandle;
|
||||
L0::GlobalDriver = nullptr;
|
||||
L0::GlobalDriverHandle = nullptr;
|
||||
}
|
||||
L0::DriverHandle *driverHandle;
|
||||
L0::DriverHandle *driverHandle = nullptr;
|
||||
L0::ContextImp *context = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(DriverHandleTest, givenInitializedDriverWhenZeDriverGetIsCalledThenDriverHandleCountIsObtained) {
|
||||
@@ -451,11 +461,9 @@ TEST_F(DriverHandleTest, givenInitializedDriverWhenZeDriverGetIsCalledThenGlobal
|
||||
}
|
||||
|
||||
TEST_F(DriverHandleTest, givenInitializedDriverWhenGetDeviceIsCalledThenOneDeviceIsObtained) {
|
||||
ze_result_t result;
|
||||
uint32_t count = 1;
|
||||
|
||||
ze_device_handle_t device;
|
||||
result = driverHandle->getDevice(&count, &device);
|
||||
ze_result_t result = driverHandle->getDevice(&count, &device);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_NE(nullptr, &device);
|
||||
}
|
||||
@@ -465,40 +473,37 @@ TEST_F(DriverHandleTest, givenValidDriverHandleWhenGetSvmAllocManagerIsCalledThe
|
||||
EXPECT_NE(nullptr, svmAllocsManager);
|
||||
}
|
||||
|
||||
TEST(zeDriverHandleGetProperties, whenZeDriverGetPropertiesIsCalledThenGetPropertiesIsCalled) {
|
||||
ze_result_t result;
|
||||
Mock<DriverHandle> driverHandle;
|
||||
ze_driver_properties_t properties;
|
||||
ze_result_t expectedResult = ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
|
||||
driverHandle.getPropertiesResult = expectedResult;
|
||||
result = zeDriverGetProperties(driverHandle.toHandle(), &properties);
|
||||
EXPECT_EQ(expectedResult, result);
|
||||
EXPECT_EQ(1u, driverHandle.getPropertiesCalled);
|
||||
TEST_F(DriverHandleTest, whenZeDriverGetPropertiesIsCalledThenSuccessIsReturned) {
|
||||
ze_driver_properties_t properties = {};
|
||||
ze_result_t result = zeDriverGetProperties(driverHandle->toHandle(), &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST(zeDriverHandleGetApiVersion, whenZeDriverGetApiIsCalledThenGetApiVersionIsCalled) {
|
||||
ze_result_t result;
|
||||
Mock<DriverHandle> driverHandle;
|
||||
ze_api_version_t version;
|
||||
ze_result_t expectedResult = ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
|
||||
driverHandle.getApiVersionResult = expectedResult;
|
||||
result = zeDriverGetApiVersion(driverHandle.toHandle(), &version);
|
||||
EXPECT_EQ(expectedResult, result);
|
||||
EXPECT_EQ(1u, driverHandle.getApiVersionCalled);
|
||||
TEST_F(DriverHandleTest, whenZeDriverGetApiIsCalledThenSuccessIsReturned) {
|
||||
ze_api_version_t version = {};
|
||||
ze_result_t result = zeDriverGetApiVersion(driverHandle->toHandle(), &version);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST(zeDriverGetIpcProperties, whenZeDriverGetIpcPropertiesIsCalledThenGetIPCPropertiesIsCalled) {
|
||||
ze_result_t result;
|
||||
Mock<DriverHandle> driverHandle;
|
||||
ze_driver_ipc_properties_t ipcProperties;
|
||||
ze_result_t expectedResult = ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
|
||||
driverHandle.getIPCPropertiesResult = expectedResult;
|
||||
result = zeDriverGetIpcProperties(driverHandle.toHandle(), &ipcProperties);
|
||||
EXPECT_EQ(expectedResult, result);
|
||||
EXPECT_EQ(1u, driverHandle.getIPCPropertiesCalled);
|
||||
TEST_F(DriverHandleTest, whenGettingApiVersionThenCorrectApiVersionIsReturned) {
|
||||
ze_api_version_t version = {};
|
||||
ze_result_t result = driverHandle->getApiVersion(&version);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(ZE_API_VERSION_1_1, version);
|
||||
}
|
||||
|
||||
TEST_F(DriverHandleTest, whenZeDriverGetIpcPropertiesIsCalledThenSuccessIsReturned) {
|
||||
ze_driver_ipc_properties_t ipcProperties = {};
|
||||
ze_result_t result = zeDriverGetIpcProperties(driverHandle->toHandle(), &ipcProperties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST_F(DriverHandleTest, whenGettingIpcPropertiesThenCorrectPropertiesAreReturned) {
|
||||
ze_driver_ipc_properties_t ipcProperties = {};
|
||||
ze_result_t result = driverHandle->getIPCProperties(&ipcProperties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(ZE_IPC_PROPERTY_FLAG_MEMORY, ipcProperties.flags);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -70,21 +70,32 @@ struct EventPoolFailTests : public ::testing::Test {
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<DriverHandleImp>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
prevMemoryManager = driverHandle->getMemoryManager();
|
||||
currMemoryManager = new MemoryManagerEventPoolFailMock(*neoDevice->executionEnvironment);
|
||||
driverHandle->setMemoryManager(currMemoryManager);
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
context = std::make_unique<ContextImp>(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
|
||||
{
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
}
|
||||
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
|
||||
prevMemoryManager = context->getMemoryManager();
|
||||
currMemoryManager = new MemoryManagerEventPoolFailMock(*neoDevice->executionEnvironment);
|
||||
context->setMemoryManager(currMemoryManager);
|
||||
|
||||
driverHandle->mainContext = context.get();
|
||||
|
||||
driverHandle->setMemoryManager(context->getMemoryManager());
|
||||
driverHandle->setSvmAllocsManager(context->getSvmAllocsManager());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
driverHandle->setMemoryManager(prevMemoryManager);
|
||||
context->setMemoryManager(prevMemoryManager);
|
||||
delete currMemoryManager;
|
||||
}
|
||||
NEO::MemoryManager *prevMemoryManager = nullptr;
|
||||
@@ -315,18 +326,20 @@ class EventSynchronizeTest : public Test<DeviceFixture> {
|
||||
eventDesc.signal = 0;
|
||||
eventDesc.wait = 0;
|
||||
|
||||
eventPool = std::unique_ptr<L0::EventPool>(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc));
|
||||
eventPool = L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc);
|
||||
ASSERT_NE(nullptr, eventPool);
|
||||
event = std::unique_ptr<L0::Event>(L0::Event::create(eventPool.get(), &eventDesc, device));
|
||||
event = L0::Event::create(eventPool, &eventDesc, device);
|
||||
ASSERT_NE(nullptr, event);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
event->destroy();
|
||||
eventPool->destroy();
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
std::unique_ptr<L0::EventPool> eventPool = nullptr;
|
||||
std::unique_ptr<L0::Event> event;
|
||||
L0::EventPool *eventPool = nullptr;
|
||||
L0::Event *event = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(EventSynchronizeTest, givenCallToEventHostSynchronizeWithTimeoutZeroAndStateInitialHostSynchronizeReturnsNotReady) {
|
||||
@@ -368,13 +381,17 @@ HWTEST_F(EventAubCsrTest, givenCallToEventHostSynchronizeWithAubModeCsrReturnsSu
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
L0::ContextImp *context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
int32_t tag;
|
||||
auto aubCsr = new MockCsrAub<FamilyType>(tag, *neoDevice->executionEnvironment, neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield());
|
||||
neoDevice->resetCommandStreamReceiver(aubCsr);
|
||||
|
||||
std::unique_ptr<L0::EventPool> eventPool = nullptr;
|
||||
std::unique_ptr<L0::Event> event;
|
||||
|
||||
ze_event_pool_desc_t eventPoolDesc = {};
|
||||
eventPoolDesc.count = 1;
|
||||
eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE;
|
||||
@@ -384,13 +401,17 @@ HWTEST_F(EventAubCsrTest, givenCallToEventHostSynchronizeWithAubModeCsrReturnsSu
|
||||
eventDesc.signal = 0;
|
||||
eventDesc.wait = 0;
|
||||
|
||||
eventPool = std::unique_ptr<L0::EventPool>(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc));
|
||||
L0::EventPool *eventPool = L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc);
|
||||
ASSERT_NE(nullptr, eventPool);
|
||||
event = std::unique_ptr<L0::Event>(L0::Event::create(eventPool.get(), &eventDesc, device));
|
||||
L0::Event *event = L0::Event::create(eventPool, &eventDesc, device);
|
||||
ASSERT_NE(nullptr, event);
|
||||
|
||||
ze_result_t result = event->hostSynchronize(10);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
event->destroy();
|
||||
eventPool->destroy();
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
struct EventCreateAllocationResidencyTest : public ::testing::Test {
|
||||
@@ -428,18 +449,20 @@ class TimestampEventCreate : public Test<DeviceFixture> {
|
||||
eventDesc.signal = 0;
|
||||
eventDesc.wait = 0;
|
||||
|
||||
eventPool = std::unique_ptr<L0::EventPool>(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc));
|
||||
eventPool = L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc);
|
||||
ASSERT_NE(nullptr, eventPool);
|
||||
event = std::unique_ptr<L0::Event>(L0::Event::create(eventPool.get(), &eventDesc, device));
|
||||
event = L0::Event::create(eventPool, &eventDesc, device);
|
||||
ASSERT_NE(nullptr, event);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
event->destroy();
|
||||
eventPool->destroy();
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
std::unique_ptr<L0::EventPool> eventPool;
|
||||
std::unique_ptr<L0::Event> event;
|
||||
L0::EventPool *eventPool = nullptr;
|
||||
L0::Event *event = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(TimestampEventCreate, givenEventCreatedWithTimestampThenIsTimestampEventFlagSet) {
|
||||
@@ -553,7 +576,7 @@ TEST_F(TimestampEventCreate, givenEventWhenQueryKernelTimestampThenNotReadyRetur
|
||||
}
|
||||
};
|
||||
|
||||
auto mockEvent = std::make_unique<MockEventQuery>(eventPool.get(), 1u, device);
|
||||
auto mockEvent = std::make_unique<MockEventQuery>(eventPool, 1u, device);
|
||||
|
||||
ze_kernel_timestamp_result_t resultTimestamp = {};
|
||||
|
||||
@@ -583,11 +606,11 @@ TEST_F(EventPoolCreateMultiDevice, whenCreatingEventPoolWithMultipleDevicesThenE
|
||||
result = zeDeviceGet(driverHandle.get(), &deviceCount, devices);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
std::unique_ptr<L0::EventPool> eventPool(EventPool::create(driverHandle.get(),
|
||||
L0::EventPool *eventPool = EventPool::create(driverHandle.get(),
|
||||
context,
|
||||
deviceCount,
|
||||
devices,
|
||||
&eventPoolDesc));
|
||||
&eventPoolDesc);
|
||||
EXPECT_NE(nullptr, eventPool);
|
||||
|
||||
auto allocation = &eventPool->getAllocation();
|
||||
@@ -596,6 +619,8 @@ TEST_F(EventPoolCreateMultiDevice, whenCreatingEventPoolWithMultipleDevicesThenE
|
||||
EXPECT_EQ(allocation->getGraphicsAllocations().size(), numRootDevices);
|
||||
|
||||
delete[] devices;
|
||||
|
||||
eventPool->destroy();
|
||||
}
|
||||
|
||||
TEST_F(EventPoolCreateMultiDevice, whenCreatingEventPoolWithNoDevicesThenEventPoolCreateSucceedsAndAllDeviceAreUsed) {
|
||||
@@ -655,15 +680,16 @@ struct EventPoolCreateNegativeTest : public ::testing::Test {
|
||||
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
static_cast<MockMemoryManager *>(driverHandle.get()->getMemoryManager())->isMockEventPoolCreateMemoryManager = true;
|
||||
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
static_cast<MockMemoryManager *>(driverHandle.get()->getMemoryManager())->isMockEventPoolCreateMemoryManager = true;
|
||||
|
||||
device = driverHandle->devices[0];
|
||||
}
|
||||
void TearDown() override {
|
||||
context->destroy();
|
||||
|
||||
@@ -136,6 +136,13 @@ HWTEST_F(FenceAubCsrTest, givenCallToFenceHostSynchronizeWithAubModeCsrReturnsSu
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
L0::ContextImp *context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
device = driverHandle->devices[0];
|
||||
int32_t tag;
|
||||
auto aubCsr = new MockCsrAub<FamilyType>(tag, *neoDevice->executionEnvironment, neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield());
|
||||
@@ -147,6 +154,8 @@ HWTEST_F(FenceAubCsrTest, givenCallToFenceHostSynchronizeWithAubModeCsrReturnsSu
|
||||
ze_result_t result = fence->hostSynchronize(10);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
fence->destroy();
|
||||
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
|
||||
@@ -44,14 +44,15 @@ TEST_F(KernelInitTest, givenKernelToInitWhenItHasUnknownArgThenUnknowKernelArgHa
|
||||
std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, false, mockKernelImmData.get());
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
ModuleImmutableDataFixture::MockKernel *kernel = new ModuleImmutableDataFixture::MockKernel(module);
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
mockKernelImmData->resizeExplicitArgs(1);
|
||||
kernel->initialize(&desc);
|
||||
EXPECT_EQ(kernel->kernelArgHandlers[0], &KernelImp::setArgUnknown);
|
||||
EXPECT_EQ(mockKernelImmData->getDescriptor().payloadMappings.explicitArgs[0].type, NEO::ArgDescriptor::ArgTUnknown);
|
||||
|
||||
delete kernel;
|
||||
}
|
||||
|
||||
TEST(KernelArgTest, givenKernelWhenSetArgUnknownCalledThenSuccessRteurned) {
|
||||
@@ -258,7 +259,7 @@ HWTEST_F(KernelImmutableDataTests, givenKernelInitializedWithNoPrivateMemoryThen
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module);
|
||||
|
||||
createKernel(kernel.get());
|
||||
|
||||
@@ -274,7 +275,7 @@ HWTEST_F(KernelImmutableDataTests, givenKernelInitializedWithPrivateMemoryThenPr
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module);
|
||||
|
||||
createKernel(kernel.get());
|
||||
|
||||
@@ -309,7 +310,7 @@ HWTEST_F(KernelImmutableDataIsaCopyTests, whenUserKernelIsCreatedThenIsaIsaCopie
|
||||
mockMemoryManager->copyMemoryToAllocationCalledTimes);
|
||||
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module);
|
||||
|
||||
createKernel(kernel.get());
|
||||
|
||||
@@ -339,7 +340,7 @@ HWTEST_F(KernelImmutableDataIsaCopyTests, whenInternalKernelIsCreatedThenIsaIsCo
|
||||
mockMemoryManager->copyMemoryToAllocationCalledTimes);
|
||||
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module);
|
||||
|
||||
createKernel(kernel.get());
|
||||
|
||||
@@ -364,8 +365,8 @@ HWTEST_F(KernelImmutableDataIsaCopyTests, whenImmutableDataIsInitializedForUserK
|
||||
|
||||
mockKernelImmData->initialize(mockKernelImmData->mockKernelInfo, device,
|
||||
device->getNEODevice()->getDeviceInfo().computeUnitsUsedForScratch,
|
||||
module.get()->translationUnit->globalConstBuffer,
|
||||
module.get()->translationUnit->globalVarBuffer,
|
||||
module->translationUnit->globalConstBuffer,
|
||||
module->translationUnit->globalVarBuffer,
|
||||
isInternal);
|
||||
|
||||
EXPECT_EQ(previouscopyMemoryToAllocationCalledTimes + 1u,
|
||||
@@ -387,8 +388,8 @@ HWTEST_F(KernelImmutableDataIsaCopyTests, whenImmutableDataIsInitializedForInter
|
||||
|
||||
mockKernelImmData->initialize(mockKernelImmData->mockKernelInfo, device,
|
||||
device->getNEODevice()->getDeviceInfo().computeUnitsUsedForScratch,
|
||||
module.get()->translationUnit->globalConstBuffer,
|
||||
module.get()->translationUnit->globalVarBuffer,
|
||||
module->translationUnit->globalConstBuffer,
|
||||
module->translationUnit->globalVarBuffer,
|
||||
isInternal);
|
||||
|
||||
EXPECT_EQ(previouscopyMemoryToAllocationCalledTimes,
|
||||
@@ -415,8 +416,8 @@ HWTEST_F(KernelImmutableDataWithNullHeapTests, whenImmutableDataIsInitializedFor
|
||||
|
||||
mockKernelImmData->initialize(mockKernelImmData->mockKernelInfo, device,
|
||||
device->getNEODevice()->getDeviceInfo().computeUnitsUsedForScratch,
|
||||
module.get()->translationUnit->globalConstBuffer,
|
||||
module.get()->translationUnit->globalVarBuffer,
|
||||
module->translationUnit->globalConstBuffer,
|
||||
module->translationUnit->globalVarBuffer,
|
||||
isInternal);
|
||||
|
||||
EXPECT_EQ(previouscopyMemoryToAllocationCalledTimes,
|
||||
@@ -443,8 +444,8 @@ HWTEST_F(KernelImmutableDataWithNullHeapTests, whenImmutableDataIsInitializedFor
|
||||
|
||||
mockKernelImmData->initialize(mockKernelImmData->mockKernelInfo, device,
|
||||
device->getNEODevice()->getDeviceInfo().computeUnitsUsedForScratch,
|
||||
module.get()->translationUnit->globalConstBuffer,
|
||||
module.get()->translationUnit->globalVarBuffer,
|
||||
module->translationUnit->globalConstBuffer,
|
||||
module->translationUnit->globalVarBuffer,
|
||||
isInternal);
|
||||
|
||||
EXPECT_EQ(previouscopyMemoryToAllocationCalledTimes,
|
||||
@@ -475,7 +476,7 @@ HWTEST_F(KernelImmutableDataWithNullHeapTests, whenInternalKernelIsCreatedWithNu
|
||||
mockMemoryManager->copyMemoryToAllocationCalledTimes);
|
||||
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module);
|
||||
|
||||
auto previousKernelHeap = mockKernelImmData->kernelInfo->heapInfo.pKernelHeap;
|
||||
mockKernelImmData->kernelInfo->heapInfo.pKernelHeap = nullptr;
|
||||
@@ -559,7 +560,7 @@ HWTEST_F(KernelIndirectPropertiesFromIGCTests, whenInitializingKernelWithNoKerne
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module);
|
||||
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
@@ -587,7 +588,7 @@ HWTEST_F(KernelIndirectPropertiesFromIGCTests, whenInitializingKernelWithKernelL
|
||||
|
||||
{
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module);
|
||||
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
@@ -603,7 +604,7 @@ HWTEST_F(KernelIndirectPropertiesFromIGCTests, whenInitializingKernelWithKernelL
|
||||
|
||||
{
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module);
|
||||
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
@@ -619,7 +620,7 @@ HWTEST_F(KernelIndirectPropertiesFromIGCTests, whenInitializingKernelWithKernelL
|
||||
|
||||
{
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module);
|
||||
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
@@ -932,7 +933,7 @@ HWTEST_F(KernelPropertiesTests, givenValidKernelAndNoMediavfestateThenSpillMemSi
|
||||
ze_result_t res = kernel->getProperties(&kernelProperties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
L0::ModuleImp *moduleImp = reinterpret_cast<L0::ModuleImp *>(module.get());
|
||||
L0::ModuleImp *moduleImp = reinterpret_cast<L0::ModuleImp *>(module);
|
||||
NEO::KernelInfo *ki = nullptr;
|
||||
for (uint32_t i = 0; i < moduleImp->getTranslationUnit()->programInfo.kernelInfos.size(); i++) {
|
||||
ki = moduleImp->getTranslationUnit()->programInfo.kernelInfos[i];
|
||||
@@ -955,7 +956,7 @@ HWTEST_F(KernelPropertiesTests, givenValidKernelAndNollocateStatelessPrivateSurf
|
||||
ze_result_t res = kernel->getProperties(&kernelProperties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
L0::ModuleImp *moduleImp = reinterpret_cast<L0::ModuleImp *>(module.get());
|
||||
L0::ModuleImp *moduleImp = reinterpret_cast<L0::ModuleImp *>(module);
|
||||
NEO::KernelInfo *ki = nullptr;
|
||||
for (uint32_t i = 0; i < moduleImp->getTranslationUnit()->programInfo.kernelInfos.size(); i++) {
|
||||
ki = moduleImp->getTranslationUnit()->programInfo.kernelInfos[i];
|
||||
@@ -1222,7 +1223,7 @@ HWTEST2_F(KernelImpPatchBindlessTest, GivenKernelImpWhenSetSurfaceStateBindlessT
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
|
||||
WhiteBoxKernelHw<gfxCoreFamily> mockKernel;
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.module = module;
|
||||
mockKernel.initialize(&desc);
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].template as<NEO::ArgDescPointer>());
|
||||
arg.bindless = 0x40;
|
||||
@@ -1253,7 +1254,7 @@ HWTEST2_F(KernelImpPatchBindlessTest, GivenKernelImpWhenSetSurfaceStateBindfulTh
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
|
||||
WhiteBoxKernelHw<gfxCoreFamily> mockKernel;
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.module = module;
|
||||
mockKernel.initialize(&desc);
|
||||
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].template as<NEO::ArgDescPointer>());
|
||||
@@ -1293,7 +1294,7 @@ TEST_F(KernelImpPatchBindlessTest, GivenValidBindlessOffsetWhenSetArgBufferWithA
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
MyMockKernel mockKernel;
|
||||
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.module = module;
|
||||
mockKernel.initialize(&desc);
|
||||
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>());
|
||||
@@ -1312,7 +1313,7 @@ TEST_F(KernelImpPatchBindlessTest, GivenValidBindfulOffsetWhenSetArgBufferWithAl
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
MyMockKernel mockKernel;
|
||||
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.module = module;
|
||||
mockKernel.initialize(&desc);
|
||||
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>());
|
||||
@@ -1331,7 +1332,7 @@ TEST_F(KernelImpPatchBindlessTest, GivenUndefiedBidfulAndBindlesstOffsetWhenSetA
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
MyMockKernel mockKernel;
|
||||
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.module = module;
|
||||
mockKernel.initialize(&desc);
|
||||
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>());
|
||||
@@ -1352,7 +1353,7 @@ TEST_F(KernelBindlessUncachedMemoryTests, givenBindlessKernelAndAllocDataNoTfoun
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
MyMockKernel mockKernel;
|
||||
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.module = module;
|
||||
mockKernel.initialize(&desc);
|
||||
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>());
|
||||
@@ -1371,7 +1372,7 @@ TEST_F(KernelBindlessUncachedMemoryTests,
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
MyMockKernel mockKernel;
|
||||
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.module = module;
|
||||
mockKernel.initialize(&desc);
|
||||
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>());
|
||||
@@ -1421,7 +1422,7 @@ TEST_F(KernelBindlessUncachedMemoryTests,
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
MyMockKernel mockKernel;
|
||||
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.module = module;
|
||||
mockKernel.initialize(&desc);
|
||||
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>());
|
||||
@@ -1473,7 +1474,7 @@ TEST_F(KernelBindlessUncachedMemoryTests,
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
MyMockKernel mockKernel;
|
||||
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.module = module;
|
||||
mockKernel.initialize(&desc);
|
||||
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>());
|
||||
@@ -1657,8 +1658,8 @@ TEST_F(KernelPrintHandlerTest, whenPrintPrintfOutputIsCalledThenPrintfBufferIsUs
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
|
||||
kernel = std::make_unique<WhiteBox<::L0::Kernel>>();
|
||||
kernel->module = module.get();
|
||||
kernel = new WhiteBox<::L0::Kernel>();
|
||||
kernel->module = module;
|
||||
kernel->initialize(&desc);
|
||||
|
||||
EXPECT_FALSE(kernel->printfBuffer == nullptr);
|
||||
|
||||
@@ -122,21 +122,26 @@ struct OutOfMemoryTests : public ::testing::Test {
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<DriverHandleOutOfMemoryMock>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
prevSvmAllocsManager = driverHandle->svmAllocsManager;
|
||||
currSvmAllocsManager = new SVMAllocsManagerOutOFMemoryMock(driverHandle->memoryManager);
|
||||
driverHandle->svmAllocsManager = currSvmAllocsManager;
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
context = std::make_unique<ContextImp>(driverHandle.get());
|
||||
context = new ContextImp(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), false));
|
||||
driverHandle->mainContext = context;
|
||||
|
||||
prevSvmAllocsManager = context->getSvmAllocsManager();
|
||||
currSvmAllocsManager = new SVMAllocsManagerOutOFMemoryMock(context->getMemoryManager());
|
||||
context->setSvmAllocsManager(currSvmAllocsManager);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
driverHandle->svmAllocsManager = prevSvmAllocsManager;
|
||||
context->setSvmAllocsManager(prevSvmAllocsManager);
|
||||
context->destroy();
|
||||
delete currSvmAllocsManager;
|
||||
}
|
||||
NEO::SVMAllocsManager *prevSvmAllocsManager;
|
||||
@@ -144,7 +149,7 @@ struct OutOfMemoryTests : public ::testing::Test {
|
||||
std::unique_ptr<DriverHandleOutOfMemoryMock> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
std::unique_ptr<ContextImp> context;
|
||||
L0::ContextImp *context = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(OutOfMemoryTests,
|
||||
@@ -198,21 +203,26 @@ struct MemoryRelaxedSizeTests : public ::testing::Test {
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<DriverHandleImp>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
prevSvmAllocsManager = driverHandle->svmAllocsManager;
|
||||
currSvmAllocsManager = new SVMAllocsManagerRelaxedSizeMock(driverHandle->memoryManager);
|
||||
driverHandle->svmAllocsManager = currSvmAllocsManager;
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
context = std::make_unique<ContextRelaxedSizeMock>(driverHandle.get());
|
||||
context = new ContextRelaxedSizeMock(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), false));
|
||||
driverHandle->mainContext = context;
|
||||
|
||||
prevSvmAllocsManager = context->getSvmAllocsManager();
|
||||
currSvmAllocsManager = new SVMAllocsManagerRelaxedSizeMock(context->getMemoryManager());
|
||||
context->setSvmAllocsManager(currSvmAllocsManager);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
driverHandle->svmAllocsManager = prevSvmAllocsManager;
|
||||
context->setSvmAllocsManager(prevSvmAllocsManager);
|
||||
context->destroy();
|
||||
delete currSvmAllocsManager;
|
||||
}
|
||||
NEO::SVMAllocsManager *prevSvmAllocsManager;
|
||||
@@ -220,7 +230,7 @@ struct MemoryRelaxedSizeTests : public ::testing::Test {
|
||||
std::unique_ptr<DriverHandleImp> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
std::unique_ptr<ContextRelaxedSizeMock> context;
|
||||
L0::ContextImp *context = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(MemoryRelaxedSizeTests,
|
||||
@@ -549,21 +559,29 @@ struct MemoryExportImportFailTest : public ::testing::Test {
|
||||
driverHandle->initialize(std::move(devices));
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
context = std::make_unique<ContextFailFdMock>(driverHandle.get());
|
||||
context = new ContextFailFdMock(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), false));
|
||||
driverHandle->mainContext = context;
|
||||
|
||||
driverHandle->setMemoryManager(context->getMemoryManager());
|
||||
driverHandle->setSvmAllocsManager(context->getSvmAllocsManager());
|
||||
driverHandle->mainContext = context;
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
context->destroy();
|
||||
}
|
||||
std::unique_ptr<DriverHandleFailGetFdMock> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
ze_context_handle_t hContext;
|
||||
std::unique_ptr<ContextFailFdMock> context;
|
||||
ContextFailFdMock *context = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(MemoryExportImportFailTest,
|
||||
@@ -667,21 +685,27 @@ struct MemoryExportImportTest : public ::testing::Test {
|
||||
driverHandle->initialize(std::move(devices));
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
context = std::make_unique<ContextFdMock>(driverHandle.get());
|
||||
context = new ContextFdMock(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), false));
|
||||
driverHandle->mainContext = context;
|
||||
driverHandle->setMemoryManager(context->getMemoryManager());
|
||||
driverHandle->setSvmAllocsManager(context->getSvmAllocsManager());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
context->destroy();
|
||||
}
|
||||
std::unique_ptr<DriverHandleGetFdMock> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
ze_context_handle_t hContext;
|
||||
std::unique_ptr<ContextFdMock> context;
|
||||
ContextFdMock *context = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(MemoryExportImportTest,
|
||||
@@ -1087,21 +1111,27 @@ struct MemoryGetIpcHandleTest : public ::testing::Test {
|
||||
driverHandle->initialize(std::move(devices));
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
context = std::make_unique<ContextGetIpcHandleMock>(driverHandle.get());
|
||||
context = new ContextGetIpcHandleMock(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), false));
|
||||
driverHandle->mainContext = context;
|
||||
driverHandle->setMemoryManager(context->getMemoryManager());
|
||||
driverHandle->setSvmAllocsManager(context->getSvmAllocsManager());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
std::unique_ptr<DriverHandleGetIpcHandleMock> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
std::unique_ptr<ContextGetIpcHandleMock> context;
|
||||
ContextGetIpcHandleMock *context = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(MemoryGetIpcHandleTest,
|
||||
@@ -1209,21 +1239,31 @@ struct MemoryOpenIpcHandleTest : public ::testing::Test {
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<DriverHandleImp>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
prevMemoryManager = driverHandle->getMemoryManager();
|
||||
currMemoryManager = new MemoryManagerOpenIpcMock(*neoDevice->executionEnvironment);
|
||||
driverHandle->setMemoryManager(currMemoryManager);
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
context = std::make_unique<ContextIpcMock>(driverHandle.get());
|
||||
context = new ContextIpcMock(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
{
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
}
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), false));
|
||||
driverHandle->mainContext = context;
|
||||
|
||||
prevMemoryManager = context->getMemoryManager();
|
||||
currMemoryManager = new MemoryManagerOpenIpcMock(*neoDevice->executionEnvironment);
|
||||
context->setMemoryManager(currMemoryManager);
|
||||
|
||||
driverHandle->setMemoryManager(context->getMemoryManager());
|
||||
driverHandle->setSvmAllocsManager(context->getSvmAllocsManager());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
driverHandle->setMemoryManager(prevMemoryManager);
|
||||
context->setMemoryManager(prevMemoryManager);
|
||||
context->destroy();
|
||||
delete currMemoryManager;
|
||||
}
|
||||
NEO::MemoryManager *prevMemoryManager = nullptr;
|
||||
@@ -1231,7 +1271,7 @@ struct MemoryOpenIpcHandleTest : public ::testing::Test {
|
||||
std::unique_ptr<DriverHandleImp> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
std::unique_ptr<ContextIpcMock> context;
|
||||
ContextIpcMock *context = nullptr;
|
||||
};
|
||||
|
||||
struct MultipleDevicePeerAllocationTest : public ::testing::Test {
|
||||
@@ -1254,7 +1294,7 @@ struct MultipleDevicePeerAllocationTest : public ::testing::Test {
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
module.reset(Module::create(device, &moduleDesc, moduleBuildLog, type));
|
||||
module = Module::create(device, &moduleDesc, moduleBuildLog, type);
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
@@ -1276,11 +1316,9 @@ struct MultipleDevicePeerAllocationTest : public ::testing::Test {
|
||||
}
|
||||
driverHandle = std::make_unique<DriverHandleImp>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
prevMemoryManager = driverHandle->getMemoryManager();
|
||||
currMemoryManager = new MemoryManagerOpenIpcMock(*executionEnvironment);
|
||||
driverHandle->setMemoryManager(currMemoryManager);
|
||||
|
||||
context = std::make_unique<ContextImp>(driverHandle.get());
|
||||
context = new ContextImp(driverHandle.get());
|
||||
bool multiOsContextDriver = false;
|
||||
EXPECT_NE(context, nullptr);
|
||||
for (auto i = 0u; i < numRootDevices; i++) {
|
||||
auto device = driverHandle->devices[i];
|
||||
@@ -1288,20 +1326,39 @@ struct MultipleDevicePeerAllocationTest : public ::testing::Test {
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
multiOsContextDriver |= device->isMultiDeviceCapable();
|
||||
}
|
||||
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), multiOsContextDriver));
|
||||
driverHandle->mainContext = context;
|
||||
|
||||
prevMemoryManager = context->getMemoryManager();
|
||||
currMemoryManager = new MemoryManagerOpenIpcMock(*executionEnvironment);
|
||||
context->setMemoryManager(currMemoryManager);
|
||||
|
||||
driverHandle->setMemoryManager(context->getMemoryManager());
|
||||
driverHandle->setSvmAllocsManager(context->getSvmAllocsManager());
|
||||
}
|
||||
|
||||
void createKernel() {
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
|
||||
kernel = std::make_unique<WhiteBox<::L0::Kernel>>();
|
||||
kernel->module = module.get();
|
||||
kernel = new WhiteBox<::L0::Kernel>();
|
||||
kernel->module = module;
|
||||
kernel->initialize(&desc);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
driverHandle->setMemoryManager(prevMemoryManager);
|
||||
if (kernel) {
|
||||
kernel->destroy();
|
||||
}
|
||||
if (module) {
|
||||
module->destroy();
|
||||
}
|
||||
context->setMemoryManager(prevMemoryManager);
|
||||
context->destroy();
|
||||
delete currMemoryManager;
|
||||
}
|
||||
|
||||
@@ -1311,13 +1368,13 @@ struct MultipleDevicePeerAllocationTest : public ::testing::Test {
|
||||
std::unique_ptr<DriverHandleImp> driverHandle;
|
||||
|
||||
std::unique_ptr<UltDeviceFactory> deviceFactory;
|
||||
std::unique_ptr<ContextImp> context;
|
||||
L0::ContextImp *context = nullptr;
|
||||
|
||||
const std::string binaryFilename = "test_kernel";
|
||||
const std::string kernelName = "test";
|
||||
const uint32_t numKernelArguments = 6;
|
||||
std::unique_ptr<L0::Module> module;
|
||||
std::unique_ptr<WhiteBox<::L0::Kernel>> kernel;
|
||||
L0::Module *module = nullptr;
|
||||
WhiteBox<::L0::Kernel> *kernel = nullptr;
|
||||
|
||||
const uint32_t numRootDevices = 2u;
|
||||
const uint32_t numSubDevices = 2u;
|
||||
@@ -1738,21 +1795,31 @@ struct MemoryFailedOpenIpcHandleTest : public ::testing::Test {
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<DriverHandleImp>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
prevMemoryManager = driverHandle->getMemoryManager();
|
||||
currMemoryManager = new MemoryManagerIpcMock(*neoDevice->executionEnvironment);
|
||||
driverHandle->setMemoryManager(currMemoryManager);
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
context = std::make_unique<ContextImp>(driverHandle.get());
|
||||
context = new ContextImp(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
{
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
}
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), false));
|
||||
driverHandle->mainContext = context;
|
||||
|
||||
prevMemoryManager = context->getMemoryManager();
|
||||
currMemoryManager = new MemoryManagerIpcMock(*neoDevice->executionEnvironment);
|
||||
context->setMemoryManager(currMemoryManager);
|
||||
|
||||
driverHandle->setMemoryManager(context->getMemoryManager());
|
||||
driverHandle->setSvmAllocsManager(context->getSvmAllocsManager());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
driverHandle->setMemoryManager(prevMemoryManager);
|
||||
context->setMemoryManager(prevMemoryManager);
|
||||
context->destroy();
|
||||
delete currMemoryManager;
|
||||
}
|
||||
NEO::MemoryManager *prevMemoryManager = nullptr;
|
||||
@@ -1760,7 +1827,7 @@ struct MemoryFailedOpenIpcHandleTest : public ::testing::Test {
|
||||
std::unique_ptr<DriverHandleImp> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
std::unique_ptr<ContextImp> context;
|
||||
L0::ContextImp *context;
|
||||
};
|
||||
|
||||
TEST_F(MemoryFailedOpenIpcHandleTest,
|
||||
@@ -1900,7 +1967,7 @@ TEST_F(MemoryTest, givenNoDeviceWhenAllocatingSharedMemoryThenDeviceInAllocation
|
||||
&deviceDesc,
|
||||
&hostDesc,
|
||||
size, alignment, &ptr);
|
||||
auto alloc = driverHandle->svmAllocsManager->getSVMAlloc(ptr);
|
||||
auto alloc = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
EXPECT_EQ(alloc->device, nullptr);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
@@ -1993,17 +2060,22 @@ struct MemoryBitfieldTest : testing::Test {
|
||||
ASSERT_NE(nullptr, driverHandle->devices[0]->toHandle());
|
||||
EXPECT_NE(neoDevice->getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield);
|
||||
|
||||
context = std::make_unique<ContextImp>(driverHandle.get());
|
||||
context = new ContextImp(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), false));
|
||||
driverHandle->mainContext = context;
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
auto result = context->freeMem(ptr);
|
||||
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||
@@ -2013,7 +2085,7 @@ struct MemoryBitfieldTest : testing::Test {
|
||||
size_t size = 10;
|
||||
size_t alignment = 1u;
|
||||
void *ptr = nullptr;
|
||||
std::unique_ptr<ContextImp> context;
|
||||
L0::ContextImp *context = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(MemoryBitfieldTest, givenDeviceWithValidBitfieldWhenAllocatingDeviceMemoryThenPassProperBitfield) {
|
||||
@@ -2051,13 +2123,15 @@ TEST(MemoryBitfieldTests, givenDeviceWithValidBitfieldWhenAllocatingSharedMemory
|
||||
driverHandle->initialize(std::move(devices));
|
||||
|
||||
auto device = driverHandle->devices[0];
|
||||
std::unique_ptr<ContextImp> context;
|
||||
context = std::make_unique<ContextImp>(driverHandle.get());
|
||||
ContextImp *context = new ContextImp(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), false));
|
||||
driverHandle->mainContext = context;
|
||||
|
||||
memoryManager->recentlyPassedDeviceBitfield = {};
|
||||
ASSERT_NE(nullptr, driverHandle->devices[1]->toHandle());
|
||||
@@ -2088,6 +2162,7 @@ TEST(MemoryBitfieldTests, givenDeviceWithValidBitfieldWhenAllocatingSharedMemory
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
result = context->freeMem(ptr);
|
||||
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
context->destroy();
|
||||
}
|
||||
|
||||
struct AllocHostMemoryTest : public ::testing::Test {
|
||||
@@ -2358,7 +2433,7 @@ TEST_F(ImportFdUncachedTests,
|
||||
void *ptr = driverHandle->importFdHandle(device->toHandle(), flags, handle, nullptr);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
|
||||
auto allocData = driverHandle->svmAllocsManager->getSVMAlloc(ptr);
|
||||
auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
EXPECT_EQ(allocData->allocationFlagsProperty.flags.locallyUncachedResource, 1u);
|
||||
|
||||
context->freeMem(ptr);
|
||||
@@ -2371,7 +2446,7 @@ TEST_F(ImportFdUncachedTests,
|
||||
void *ptr = driverHandle->importFdHandle(device->toHandle(), flags, handle, nullptr);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
|
||||
auto allocData = driverHandle->svmAllocsManager->getSVMAlloc(ptr);
|
||||
auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
EXPECT_EQ(allocData->allocationFlagsProperty.flags.locallyUncachedResource, 0u);
|
||||
|
||||
context->freeMem(ptr);
|
||||
@@ -2397,21 +2472,31 @@ struct SharedAllocFailTests : public ::testing::Test {
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<DriverHandleImp>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
prevSvmAllocsManager = driverHandle->svmAllocsManager;
|
||||
currSvmAllocsManager = new SVMAllocsManagerSharedAllocFailMock(driverHandle->memoryManager);
|
||||
driverHandle->svmAllocsManager = currSvmAllocsManager;
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
context = std::make_unique<ContextImp>(driverHandle.get());
|
||||
context = new ContextImp(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
{
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
}
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), false));
|
||||
driverHandle->mainContext = context;
|
||||
|
||||
prevSvmAllocsManager = context->getSvmAllocsManager();
|
||||
currSvmAllocsManager = new SVMAllocsManagerSharedAllocFailMock(context->getMemoryManager());
|
||||
context->setSvmAllocsManager(currSvmAllocsManager);
|
||||
|
||||
driverHandle->setMemoryManager(context->getMemoryManager());
|
||||
driverHandle->setSvmAllocsManager(context->getSvmAllocsManager());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
driverHandle->svmAllocsManager = prevSvmAllocsManager;
|
||||
context->setSvmAllocsManager(prevSvmAllocsManager);
|
||||
context->destroy();
|
||||
delete currSvmAllocsManager;
|
||||
}
|
||||
NEO::SVMAllocsManager *prevSvmAllocsManager;
|
||||
@@ -2419,7 +2504,7 @@ struct SharedAllocFailTests : public ::testing::Test {
|
||||
std::unique_ptr<DriverHandleImp> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
std::unique_ptr<ContextImp> context;
|
||||
ContextImp *context;
|
||||
};
|
||||
|
||||
TEST_F(SharedAllocFailTests, whenAllocatinSharedMemoryAndAllocationFailsThenOutOfDeviceMemoryIsReturned) {
|
||||
@@ -2446,7 +2531,7 @@ struct ContextMultiDeviceMock : public L0::ContextImp {
|
||||
ContextMultiDeviceMock(L0::DriverHandleImp *driverHandle) : L0::ContextImp(driverHandle) {}
|
||||
ze_result_t freeMem(const void *ptr) override {
|
||||
SVMAllocsManagerSharedAllocMultiDeviceMock *currSvmAllocsManager =
|
||||
static_cast<SVMAllocsManagerSharedAllocMultiDeviceMock *>(this->driverHandle->svmAllocsManager);
|
||||
static_cast<SVMAllocsManagerSharedAllocMultiDeviceMock *>(this->driverHandle->getSvmAllocsManager());
|
||||
if (currSvmAllocsManager->createHostUnifiedMemoryAllocationTimes == 0) {
|
||||
return ContextImp::freeMem(ptr);
|
||||
}
|
||||
@@ -2464,32 +2549,43 @@ struct SharedAllocMultiDeviceTests : public ::testing::Test {
|
||||
driverHandle = std::make_unique<DriverHandleImp>();
|
||||
ze_result_t res = driverHandle->initialize(std::move(devices));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
prevSvmAllocsManager = driverHandle->svmAllocsManager;
|
||||
currSvmAllocsManager = new SVMAllocsManagerSharedAllocMultiDeviceMock(driverHandle->memoryManager);
|
||||
driverHandle->svmAllocsManager = currSvmAllocsManager;
|
||||
|
||||
context = std::make_unique<ContextMultiDeviceMock>(driverHandle.get());
|
||||
context = new ContextMultiDeviceMock(driverHandle.get());
|
||||
EXPECT_NE(context, nullptr);
|
||||
|
||||
bool multiOsContextDriver = false;
|
||||
for (uint32_t i = 0; i < numRootDevices; i++) {
|
||||
auto device = driverHandle->devices[i];
|
||||
context->getDevices().insert(std::make_pair(device->toHandle(), device));
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
multiOsContextDriver |= device->isMultiDeviceCapable();
|
||||
}
|
||||
|
||||
context->setMemoryManager(context->getDevices().begin()->second->getNEODevice()->getMemoryManager());
|
||||
context->setSvmAllocsManager(new NEO::SVMAllocsManager(context->getMemoryManager(), multiOsContextDriver));
|
||||
driverHandle->mainContext = context;
|
||||
|
||||
prevSvmAllocsManager = context->getSvmAllocsManager();
|
||||
currSvmAllocsManager = new SVMAllocsManagerSharedAllocMultiDeviceMock(context->getMemoryManager());
|
||||
context->setSvmAllocsManager(currSvmAllocsManager);
|
||||
|
||||
driverHandle->setMemoryManager(context->getMemoryManager());
|
||||
driverHandle->setSvmAllocsManager(context->getSvmAllocsManager());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
driverHandle->svmAllocsManager = prevSvmAllocsManager;
|
||||
context->setSvmAllocsManager(prevSvmAllocsManager);
|
||||
context->destroy();
|
||||
delete currSvmAllocsManager;
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::SVMAllocsManager *prevSvmAllocsManager;
|
||||
SVMAllocsManagerSharedAllocMultiDeviceMock *currSvmAllocsManager;
|
||||
NEO::SVMAllocsManager *prevSvmAllocsManager = nullptr;
|
||||
SVMAllocsManagerSharedAllocMultiDeviceMock *currSvmAllocsManager = nullptr;
|
||||
std::unique_ptr<DriverHandleImp> driverHandle;
|
||||
std::unique_ptr<ContextMultiDeviceMock> context;
|
||||
ContextMultiDeviceMock *context = nullptr;
|
||||
const uint32_t numRootDevices = 4u;
|
||||
};
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ HWTEST_F(ModuleTest, givenZeroCountWhenGettingKernelNamesThenCountIsFilled) {
|
||||
uint32_t count = 0;
|
||||
auto result = module->getKernelNames(&count, nullptr);
|
||||
|
||||
auto whiteboxModule = whitebox_cast(module.get());
|
||||
auto whiteboxModule = whitebox_cast(module);
|
||||
EXPECT_EQ(whiteboxModule->kernelImmDatas.size(), count);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
@@ -576,7 +576,7 @@ TEST_F(ModulePropertyTest, givenCallToGetPropertiesWithUnresolvedSymbolsThenFlag
|
||||
NEO::Linker::RelocationInfo unresolvedRelocation;
|
||||
unresolvedRelocation.symbolName = "unresolved";
|
||||
|
||||
whitebox_cast(module.get())->unresolvedExternalsInfo.push_back({unresolvedRelocation});
|
||||
whitebox_cast(module)->unresolvedExternalsInfo.push_back({unresolvedRelocation});
|
||||
|
||||
ze_module_property_flags_t expectedFlags = 0;
|
||||
expectedFlags |= ZE_MODULE_PROPERTY_FLAG_IMPORTS;
|
||||
@@ -690,7 +690,7 @@ class DeviceModuleSetArgBufferTest : public ModuleFixture, public ::testing::Tes
|
||||
void createKernelAndAllocMemory(uint32_t rootDeviceIndex, void **ptr, ze_kernel_handle_t *kernelHandle) {
|
||||
ze_kernel_desc_t kernelDesc = {};
|
||||
kernelDesc.pKernelName = kernelName.c_str();
|
||||
ze_result_t res = module.get()->createKernel(&kernelDesc, kernelHandle);
|
||||
ze_result_t res = module->createKernel(&kernelDesc, kernelHandle);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
ze_host_mem_alloc_desc_t hostDesc = {};
|
||||
@@ -702,7 +702,6 @@ class DeviceModuleSetArgBufferTest : public ModuleFixture, public ::testing::Tes
|
||||
HWTEST_F(DeviceModuleSetArgBufferTest,
|
||||
givenValidMemoryUsedinFirstCallToSetArgBufferThenNullptrSetOnTheSecondCallThenArgBufferisUpdatedInEachCallAndSuccessIsReturned) {
|
||||
uint32_t rootDeviceIndex = 0;
|
||||
createModuleFromBinary();
|
||||
|
||||
ze_kernel_handle_t kernelHandle;
|
||||
void *validBufferPtr = nullptr;
|
||||
@@ -752,7 +751,7 @@ class MultiDeviceModuleSetArgBufferTest : public MultiDeviceModuleFixture, publi
|
||||
void createKernelAndAllocMemory(uint32_t rootDeviceIndex, void **ptr, ze_kernel_handle_t *kernelHandle) {
|
||||
ze_kernel_desc_t kernelDesc = {};
|
||||
kernelDesc.pKernelName = kernelName.c_str();
|
||||
ze_result_t res = modules[rootDeviceIndex].get()->createKernel(&kernelDesc, kernelHandle);
|
||||
ze_result_t res = modules[rootDeviceIndex]->createKernel(&kernelDesc, kernelHandle);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
ze_host_mem_alloc_desc_t hostDesc = {};
|
||||
@@ -771,10 +770,10 @@ HWTEST_F(MultiDeviceModuleSetArgBufferTest,
|
||||
void *ptr = nullptr;
|
||||
createKernelAndAllocMemory(rootDeviceIndex, &ptr, &kernelHandle);
|
||||
|
||||
L0::KernelImp *kernel = reinterpret_cast<L0::KernelImp *>(Kernel::fromHandle(kernelHandle));
|
||||
kernel->setArgBuffer(0, sizeof(ptr), &ptr);
|
||||
L0::KernelImp *pKernel = reinterpret_cast<L0::KernelImp *>(Kernel::fromHandle(kernelHandle));
|
||||
pKernel->setArgBuffer(0, sizeof(ptr), &ptr);
|
||||
|
||||
for (auto alloc : kernel->getResidencyContainer()) {
|
||||
for (auto alloc : pKernel->getResidencyContainer()) {
|
||||
if (alloc && alloc->getGpuAddress() == reinterpret_cast<uint64_t>(ptr)) {
|
||||
EXPECT_EQ(rootDeviceIndex, alloc->getRootDeviceIndex());
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "level_zero/core/source/driver/driver_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_device.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
#include "level_zero/tools/test/unit_tests/sources/metrics/mock_metric.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "level_zero/core/source/driver/driver_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_device.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
#include "level_zero/tools/test/unit_tests/sources/metrics/mock_metric.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
@@ -30,10 +30,10 @@ class ZesEngineFixture : public SysmanDeviceFixture {
|
||||
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pMemoryManagerOriginal = device->getDriverHandle()->getMemoryManager();
|
||||
pMemoryManagerOriginal = driverHandle->getMemoryManager();
|
||||
pMemoryManager = std::make_unique<::testing::NiceMock<MockMemoryManagerInEngineSysman>>(*neoDevice->getExecutionEnvironment());
|
||||
pMemoryManager->localMemorySupported[0] = false;
|
||||
device->getDriverHandle()->setMemoryManager(pMemoryManager.get());
|
||||
driverHandle->setMemoryManager(pMemoryManager.get());
|
||||
|
||||
pSysfsAccessOriginal = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<EngineSysfsAccess>>>();
|
||||
@@ -67,8 +67,8 @@ class ZesEngineFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
context->setMemoryManager(pMemoryManagerOriginal);
|
||||
SysmanDeviceFixture::TearDown();
|
||||
device->getDriverHandle()->setMemoryManager(pMemoryManagerOriginal);
|
||||
pLinuxSysmanImp->pDrm = pOriginalDrm;
|
||||
pLinuxSysmanImp->pPmuInterface = pOriginalPmuInterface;
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccessOriginal;
|
||||
|
||||
@@ -50,6 +50,7 @@ class ZesPciFixture : public ::testing::Test {
|
||||
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
L0::Context *context = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());
|
||||
@@ -61,6 +62,12 @@ class ZesPciFixture : public ::testing::Test {
|
||||
driverHandle->initialize(std::move(devices));
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique<NEO::OSInterface>();
|
||||
auto osInterface = device->getOsInterface().get();
|
||||
osInterface->setDrm(new SysmanMockDrm(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
|
||||
@@ -110,6 +117,7 @@ class ZesPciFixture : public ::testing::Test {
|
||||
unsetenv("ZES_ENABLE_SYSMAN");
|
||||
pLinuxSysmanImp->pSysfsAccess = pOriginalSysfsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pOriginalFsAccess;
|
||||
context->destroy();
|
||||
}
|
||||
SysmanDevice *pSysmanDevice = nullptr;
|
||||
SysmanDeviceImp *pSysmanDeviceImp = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user