2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-01-26 22:05:22 +08:00
|
|
|
* Copyright (C) 2017-2021 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/context/context.h"
|
|
|
|
#include "opencl/source/sharings/sharing_factory.h"
|
2020-04-02 16:52:00 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/ult_cl_device_factory.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2020-03-17 19:37:38 +08:00
|
|
|
|
|
|
|
class AsyncEventsHandler;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
class MockContext : public Context {
|
|
|
|
public:
|
2019-10-16 16:59:10 +08:00
|
|
|
using Context::contextType;
|
2020-09-28 19:11:58 +08:00
|
|
|
using Context::deviceBitfields;
|
2021-01-26 22:05:22 +08:00
|
|
|
using Context::devices;
|
2019-10-16 16:59:10 +08:00
|
|
|
using Context::driverDiagnostics;
|
2020-09-28 19:11:58 +08:00
|
|
|
using Context::maxRootDeviceIndex;
|
2019-10-16 16:59:10 +08:00
|
|
|
using Context::memoryManager;
|
|
|
|
using Context::preferD3dSharedResources;
|
2020-09-26 05:01:34 +08:00
|
|
|
using Context::resolvesRequiredInKernels;
|
2020-09-28 19:11:58 +08:00
|
|
|
using Context::rootDeviceIndices;
|
2020-05-04 20:38:11 +08:00
|
|
|
using Context::setupContextType;
|
2018-03-23 22:55:13 +08:00
|
|
|
using Context::sharingFunctions;
|
2020-11-04 23:50:54 +08:00
|
|
|
using Context::specialQueues;
|
2019-06-26 22:21:45 +08:00
|
|
|
using Context::svmAllocsManager;
|
2020-09-28 19:11:58 +08:00
|
|
|
|
2020-04-02 16:52:00 +08:00
|
|
|
MockContext(ClDevice *pDevice, bool noSpecialQueue = false);
|
2020-11-04 23:50:54 +08:00
|
|
|
MockContext(const ClDeviceVector &clDeviceVector, bool noSpecialQueue = true);
|
2017-12-21 07:45:38 +08:00
|
|
|
MockContext(
|
|
|
|
void(CL_CALLBACK *funcNotify)(const char *, const void *, size_t, void *),
|
|
|
|
void *data);
|
|
|
|
MockContext();
|
2020-03-13 16:17:01 +08:00
|
|
|
~MockContext() override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
void clearSharingFunctions();
|
|
|
|
void setSharingFunctions(SharingFunctions *sharingFunctions);
|
|
|
|
void releaseSharingFunctions(SharingType sharing);
|
2019-01-28 15:27:26 +08:00
|
|
|
void resetSharingFunctions(SharingType sharing);
|
2018-08-06 15:22:04 +08:00
|
|
|
void registerSharingWithId(SharingFunctions *sharing, SharingType sharingId);
|
2020-03-17 19:37:38 +08:00
|
|
|
std::unique_ptr<AsyncEventsHandler> &getAsyncEventsHandlerUniquePtr();
|
2020-04-02 16:52:00 +08:00
|
|
|
void initializeWithDevices(const ClDeviceVector &devices, bool noSpecialQueue);
|
|
|
|
|
2020-12-10 21:22:10 +08:00
|
|
|
SchedulerKernel &getSchedulerKernel() override;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
private:
|
2020-04-02 16:52:00 +08:00
|
|
|
ClDevice *pDevice = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MockDefaultContext : MockContext {
|
|
|
|
MockDefaultContext();
|
|
|
|
|
2020-08-28 20:44:18 +08:00
|
|
|
UltClDeviceFactory ultClDeviceFactory{3, 0};
|
2020-04-02 16:52:00 +08:00
|
|
|
MockClDevice *pRootDevice0;
|
|
|
|
MockClDevice *pRootDevice1;
|
2020-08-28 20:44:18 +08:00
|
|
|
MockClDevice *pRootDevice2;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2020-04-02 16:52:00 +08:00
|
|
|
|
|
|
|
struct MockSpecializedContext : MockContext {
|
|
|
|
MockSpecializedContext();
|
|
|
|
|
|
|
|
UltClDeviceFactory ultClDeviceFactory{1, 2};
|
|
|
|
MockClDevice *pRootDevice;
|
|
|
|
ClDevice *pSubDevice0 = nullptr;
|
|
|
|
ClDevice *pSubDevice1 = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MockUnrestrictiveContext : MockContext {
|
|
|
|
MockUnrestrictiveContext();
|
|
|
|
|
|
|
|
UltClDeviceFactory ultClDeviceFactory{1, 2};
|
|
|
|
MockClDevice *pRootDevice;
|
|
|
|
ClDevice *pSubDevice0 = nullptr;
|
|
|
|
ClDevice *pSubDevice1 = nullptr;
|
|
|
|
};
|
|
|
|
|
2020-06-15 04:18:42 +08:00
|
|
|
struct MockUnrestrictiveContextMultiGPU : MockContext {
|
|
|
|
MockUnrestrictiveContextMultiGPU();
|
|
|
|
|
|
|
|
UltClDeviceFactory ultClDeviceFactory{2, 2};
|
|
|
|
MockClDevice *pRootDevice0;
|
|
|
|
ClDevice *pSubDevice00 = nullptr;
|
|
|
|
ClDevice *pSubDevice01 = nullptr;
|
|
|
|
MockClDevice *pRootDevice1;
|
|
|
|
ClDevice *pSubDevice10 = nullptr;
|
|
|
|
ClDevice *pSubDevice11 = nullptr;
|
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|