2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-14 21:32:11 +08:00
|
|
|
* Copyright (C) 2017-2020 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/command_queue/command_queue_hw.h"
|
2020-02-23 22:20:22 +08: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"
|
|
|
|
#include "opencl/test/unit_test/fixtures/device_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/fixtures/image_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/helpers/hw_parse.h"
|
|
|
|
#include "opencl/test/unit_test/indirect_heap/indirect_heap_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
2020-02-22 16:28:27 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
struct CommandDeviceFixture : public DeviceFixture,
|
|
|
|
public CommandQueueHwFixture {
|
|
|
|
using CommandQueueHwFixture::SetUp;
|
|
|
|
void SetUp(cl_command_queue_properties cmdQueueProperties = 0) {
|
|
|
|
DeviceFixture::SetUp();
|
2020-01-14 21:32:11 +08:00
|
|
|
CommandQueueHwFixture::SetUp(pClDevice, cmdQueueProperties);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() {
|
|
|
|
CommandQueueHwFixture::TearDown();
|
|
|
|
DeviceFixture::TearDown();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CommandEnqueueBaseFixture : CommandDeviceFixture,
|
|
|
|
public IndirectHeapFixture,
|
|
|
|
public HardwareParse {
|
|
|
|
using IndirectHeapFixture::SetUp;
|
|
|
|
void SetUp(cl_command_queue_properties cmdQueueProperties = 0) {
|
|
|
|
CommandDeviceFixture::SetUp(cmdQueueProperties);
|
|
|
|
IndirectHeapFixture::SetUp(pCmdQ);
|
|
|
|
HardwareParse::SetUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() {
|
|
|
|
HardwareParse::TearDown();
|
|
|
|
IndirectHeapFixture::TearDown();
|
|
|
|
CommandDeviceFixture::TearDown();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CommandEnqueueFixture : public CommandEnqueueBaseFixture,
|
|
|
|
public CommandStreamFixture {
|
|
|
|
void SetUp(cl_command_queue_properties cmdQueueProperties = 0) {
|
|
|
|
CommandEnqueueBaseFixture::SetUp(cmdQueueProperties);
|
|
|
|
CommandStreamFixture::SetUp(pCmdQ);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() {
|
|
|
|
CommandEnqueueBaseFixture::TearDown();
|
|
|
|
CommandStreamFixture::TearDown();
|
|
|
|
}
|
|
|
|
};
|
2018-02-09 05:52:58 +08:00
|
|
|
|
|
|
|
struct NegativeFailAllocationCommandEnqueueBaseFixture : public CommandEnqueueBaseFixture {
|
|
|
|
void SetUp() override {
|
|
|
|
CommandEnqueueBaseFixture::SetUp();
|
2018-10-11 17:19:49 +08:00
|
|
|
failMemManager.reset(new FailMemoryManager(*pDevice->getExecutionEnvironment()));
|
2018-02-09 05:52:58 +08:00
|
|
|
|
|
|
|
BufferDefaults::context = context;
|
|
|
|
Image2dDefaults::context = context;
|
|
|
|
buffer.reset(BufferHelper<>::create());
|
|
|
|
image.reset(ImageHelper<Image2dDefaults>::create());
|
|
|
|
ptr = static_cast<void *>(array);
|
2018-10-11 17:19:49 +08:00
|
|
|
oldMemManager = pDevice->getExecutionEnvironment()->memoryManager.release();
|
|
|
|
pDevice->injectMemoryManager(failMemManager.release());
|
2018-02-09 05:52:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
2018-10-11 17:19:49 +08:00
|
|
|
pDevice->injectMemoryManager(oldMemManager);
|
2018-02-09 05:52:58 +08:00
|
|
|
buffer.reset(nullptr);
|
|
|
|
image.reset(nullptr);
|
|
|
|
BufferDefaults::context = nullptr;
|
|
|
|
Image2dDefaults::context = nullptr;
|
|
|
|
CommandEnqueueBaseFixture::TearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
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 18:46:34 +08:00
|
|
|
template <typename FamilyType>
|
|
|
|
struct CommandQueueStateless : public CommandQueueHw<FamilyType> {
|
2020-01-21 16:35:12 +08:00
|
|
|
CommandQueueStateless(Context *context, ClDevice *device) : CommandQueueHw<FamilyType>(context, device, nullptr, false){};
|
2019-10-16 18:46:34 +08:00
|
|
|
|
|
|
|
void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo) override {
|
|
|
|
auto kernel = dispatchInfo.begin()->getKernel();
|
|
|
|
EXPECT_TRUE(kernel->getKernelInfo().patchInfo.executionEnvironment->CompiledForGreaterThan4GBBuffers);
|
|
|
|
EXPECT_FALSE(kernel->getKernelInfo().kernelArgInfo[0].pureStatefulBufferAccess);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FamilyType>
|
|
|
|
struct CommandQueueStateful : public CommandQueueHw<FamilyType> {
|
2020-01-21 16:35:12 +08:00
|
|
|
CommandQueueStateful(Context *context, ClDevice *device) : CommandQueueHw<FamilyType>(context, device, nullptr, false){};
|
2019-10-16 18:46:34 +08:00
|
|
|
|
|
|
|
void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo) override {
|
|
|
|
auto kernel = dispatchInfo.begin()->getKernel();
|
2019-10-30 21:50:49 +08:00
|
|
|
auto &device = kernel->getDevice();
|
|
|
|
if (!device.areSharedSystemAllocationsAllowed()) {
|
2019-10-16 18:46:34 +08:00
|
|
|
EXPECT_FALSE(kernel->getKernelInfo().patchInfo.executionEnvironment->CompiledForGreaterThan4GBBuffers);
|
2019-10-30 21:50:49 +08:00
|
|
|
if (device.getHardwareCapabilities().isStatelesToStatefullWithOffsetSupported) {
|
2019-11-14 22:48:30 +08:00
|
|
|
EXPECT_TRUE(kernel->allBufferArgsStateful);
|
2019-10-30 21:50:49 +08:00
|
|
|
}
|
2019-10-16 18:46:34 +08:00
|
|
|
} else {
|
|
|
|
EXPECT_TRUE(kernel->getKernelInfo().patchInfo.executionEnvironment->CompiledForGreaterThan4GBBuffers);
|
|
|
|
EXPECT_FALSE(kernel->getKernelInfo().kernelArgInfo[0].pureStatefulBufferAccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|