2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2022-01-12 14:13:22 +00:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2021-10-05 12:54:33 +00:00
|
|
|
#include "shared/test/common/mocks/mock_memory_manager.h"
|
2020-03-31 07:43:07 +02:00
|
|
|
|
2020-02-22 22:50:57 +01:00
|
|
|
#include "opencl/source/command_queue/command_queue_hw.h"
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/command_queue/command_queue_fixture.h"
|
|
|
|
|
#include "opencl/test/unit_test/command_stream/command_stream_fixture.h"
|
|
|
|
|
#include "opencl/test/unit_test/fixtures/buffer_fixture.h"
|
2020-05-28 14:05:12 +02:00
|
|
|
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/fixtures/image_fixture.h"
|
2021-10-13 08:58:23 +00:00
|
|
|
#include "opencl/test/unit_test/helpers/cl_hw_parse.h"
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/indirect_heap/indirect_heap_fixture.h"
|
2020-02-22 09:28:27 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-05-28 14:05:12 +02:00
|
|
|
struct CommandDeviceFixture : public ClDeviceFixture,
|
2017-12-21 00:45:38 +01:00
|
|
|
public CommandQueueHwFixture {
|
2022-08-16 14:51:17 +00:00
|
|
|
using CommandQueueHwFixture::setUp;
|
|
|
|
|
void setUp(cl_command_queue_properties cmdQueueProperties = 0) {
|
|
|
|
|
ClDeviceFixture::setUp();
|
|
|
|
|
CommandQueueHwFixture::setUp(pClDevice, cmdQueueProperties);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-08-16 14:51:17 +00:00
|
|
|
void tearDown() {
|
|
|
|
|
CommandQueueHwFixture::tearDown();
|
|
|
|
|
ClDeviceFixture::tearDown();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct CommandEnqueueBaseFixture : CommandDeviceFixture,
|
|
|
|
|
public IndirectHeapFixture,
|
2021-10-13 08:58:23 +00:00
|
|
|
public ClHardwareParse {
|
2022-08-16 14:51:17 +00:00
|
|
|
using IndirectHeapFixture::setUp;
|
|
|
|
|
void setUp(cl_command_queue_properties cmdQueueProperties = 0) {
|
|
|
|
|
CommandDeviceFixture::setUp(cmdQueueProperties);
|
|
|
|
|
IndirectHeapFixture::setUp(pCmdQ);
|
2022-08-16 12:19:30 +00:00
|
|
|
ClHardwareParse::setUp();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-08-16 14:51:17 +00:00
|
|
|
void tearDown() {
|
2022-08-16 12:19:30 +00:00
|
|
|
ClHardwareParse::tearDown();
|
2022-08-16 14:51:17 +00:00
|
|
|
IndirectHeapFixture::tearDown();
|
|
|
|
|
CommandDeviceFixture::tearDown();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct CommandEnqueueFixture : public CommandEnqueueBaseFixture,
|
|
|
|
|
public CommandStreamFixture {
|
2022-08-16 14:51:17 +00:00
|
|
|
void setUp(cl_command_queue_properties cmdQueueProperties = 0) {
|
|
|
|
|
CommandEnqueueBaseFixture::setUp(cmdQueueProperties);
|
|
|
|
|
CommandStreamFixture::setUp(pCmdQ);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-08-16 14:51:17 +00:00
|
|
|
void tearDown() {
|
|
|
|
|
CommandEnqueueBaseFixture::tearDown();
|
|
|
|
|
CommandStreamFixture::tearDown();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
};
|
2018-02-08 22:52:58 +01:00
|
|
|
|
|
|
|
|
struct NegativeFailAllocationCommandEnqueueBaseFixture : public CommandEnqueueBaseFixture {
|
2022-08-16 14:51:17 +00:00
|
|
|
void setUp() {
|
|
|
|
|
CommandEnqueueBaseFixture::setUp();
|
2018-10-11 11:19:49 +02:00
|
|
|
failMemManager.reset(new FailMemoryManager(*pDevice->getExecutionEnvironment()));
|
2018-02-08 22:52:58 +01:00
|
|
|
|
|
|
|
|
BufferDefaults::context = context;
|
|
|
|
|
Image2dDefaults::context = context;
|
|
|
|
|
buffer.reset(BufferHelper<>::create());
|
|
|
|
|
image.reset(ImageHelper<Image2dDefaults>::create());
|
|
|
|
|
ptr = static_cast<void *>(array);
|
2018-10-11 11:19:49 +02:00
|
|
|
oldMemManager = pDevice->getExecutionEnvironment()->memoryManager.release();
|
|
|
|
|
pDevice->injectMemoryManager(failMemManager.release());
|
2018-02-08 22:52:58 +01:00
|
|
|
}
|
|
|
|
|
|
2022-08-16 14:51:17 +00:00
|
|
|
void tearDown() {
|
2018-10-11 11:19:49 +02:00
|
|
|
pDevice->injectMemoryManager(oldMemManager);
|
2018-02-08 22:52:58 +01:00
|
|
|
buffer.reset(nullptr);
|
|
|
|
|
image.reset(nullptr);
|
|
|
|
|
BufferDefaults::context = nullptr;
|
|
|
|
|
Image2dDefaults::context = nullptr;
|
2022-08-16 14:51:17 +00:00
|
|
|
CommandEnqueueBaseFixture::tearDown();
|
2018-02-08 22:52:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<Buffer> buffer;
|
|
|
|
|
std::unique_ptr<Image> image;
|
|
|
|
|
std::unique_ptr<FailMemoryManager> failMemManager;
|
|
|
|
|
char array[MemoryConstants::cacheLineSize];
|
|
|
|
|
void *ptr;
|
|
|
|
|
MemoryManager *oldMemManager;
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-16 12:46:34 +02:00
|
|
|
template <typename FamilyType>
|
|
|
|
|
struct CommandQueueStateless : public CommandQueueHw<FamilyType> {
|
2020-01-21 09:35:12 +01:00
|
|
|
CommandQueueStateless(Context *context, ClDevice *device) : CommandQueueHw<FamilyType>(context, device, nullptr, false){};
|
2019-10-16 12:46:34 +02:00
|
|
|
|
|
|
|
|
void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo) override {
|
|
|
|
|
auto kernel = dispatchInfo.begin()->getKernel();
|
2020-11-19 12:30:44 +01:00
|
|
|
|
2021-03-22 15:26:03 +00:00
|
|
|
EXPECT_TRUE(kernel->getKernelInfo().kernelDescriptor.kernelAttributes.supportsBuffersBiggerThan4Gb());
|
2021-04-08 11:05:45 +02:00
|
|
|
if (kernel->getKernelInfo().getArgDescriptorAt(0).is<ArgDescriptor::ArgTPointer>()) {
|
|
|
|
|
EXPECT_FALSE(kernel->getKernelInfo().getArgDescriptorAt(0).as<ArgDescPointer>().isPureStateful());
|
|
|
|
|
}
|
2022-07-15 19:47:17 +00:00
|
|
|
|
|
|
|
|
if (validateKernelSystemMemory) {
|
|
|
|
|
if (expectedKernelSystemMemory) {
|
|
|
|
|
EXPECT_TRUE(kernel->getDestinationAllocationInSystemMemory());
|
|
|
|
|
} else {
|
|
|
|
|
EXPECT_FALSE(kernel->getDestinationAllocationInSystemMemory());
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-16 12:46:34 +02:00
|
|
|
}
|
2022-07-15 19:47:17 +00:00
|
|
|
|
|
|
|
|
bool validateKernelSystemMemory = false;
|
|
|
|
|
bool expectedKernelSystemMemory = false;
|
2019-10-16 12:46:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename FamilyType>
|
|
|
|
|
struct CommandQueueStateful : public CommandQueueHw<FamilyType> {
|
2020-01-21 09:35:12 +01:00
|
|
|
CommandQueueStateful(Context *context, ClDevice *device) : CommandQueueHw<FamilyType>(context, device, nullptr, false){};
|
2019-10-16 12:46:34 +02:00
|
|
|
|
|
|
|
|
void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo) override {
|
|
|
|
|
auto kernel = dispatchInfo.begin()->getKernel();
|
2022-01-12 14:13:22 +00:00
|
|
|
EXPECT_FALSE(kernel->getKernelInfo().kernelDescriptor.kernelAttributes.supportsBuffersBiggerThan4Gb());
|
2021-12-28 22:17:46 +00:00
|
|
|
|
2022-07-14 01:12:22 +00:00
|
|
|
if (HwHelperHw<FamilyType>::get().isStatelessToStatefulWithOffsetSupported()) {
|
2022-01-12 14:13:22 +00:00
|
|
|
EXPECT_TRUE(kernel->allBufferArgsStateful);
|
2019-10-16 12:46:34 +02:00
|
|
|
}
|
2022-07-15 19:47:17 +00:00
|
|
|
|
|
|
|
|
if (validateKernelSystemMemory) {
|
|
|
|
|
if (expectedKernelSystemMemory) {
|
|
|
|
|
EXPECT_TRUE(kernel->getDestinationAllocationInSystemMemory());
|
|
|
|
|
} else {
|
|
|
|
|
EXPECT_FALSE(kernel->getDestinationAllocationInSystemMemory());
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-16 12:46:34 +02:00
|
|
|
}
|
2022-07-15 19:47:17 +00:00
|
|
|
|
|
|
|
|
bool validateKernelSystemMemory = false;
|
|
|
|
|
bool expectedKernelSystemMemory = false;
|
2019-10-16 12:46:34 +02:00
|
|
|
};
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|