2019-10-25 23:55:22 +08:00
|
|
|
/*
|
2022-01-21 22:32:49 +08:00
|
|
|
* Copyright (C) 2019-2022 Intel Corporation
|
2019-10-25 23:55:22 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver_hw.h"
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/cmd_parse/hw_parse.h"
|
2021-10-13 00:42:24 +08:00
|
|
|
#include "shared/test/common/libult/ult_command_stream_receiver.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
2021-12-15 01:40:08 +08:00
|
|
|
#include "shared/test/common/test_macros/test.h"
|
2020-02-23 05:50:57 +08:00
|
|
|
|
2019-10-25 23:55:22 +08:00
|
|
|
using namespace NEO;
|
|
|
|
|
|
|
|
struct ComputeModeRequirements : public ::testing::Test {
|
|
|
|
template <typename FamilyType>
|
2019-12-09 16:15:34 +08:00
|
|
|
struct myCsr : public UltCommandStreamReceiver<FamilyType> {
|
2019-10-25 23:55:22 +08:00
|
|
|
using CommandStreamReceiver::commandStream;
|
2021-12-09 00:22:18 +08:00
|
|
|
using CommandStreamReceiver::streamProperties;
|
2020-10-29 22:33:35 +08:00
|
|
|
myCsr(ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield)
|
2020-10-28 23:08:37 +08:00
|
|
|
: UltCommandStreamReceiver<FamilyType>(executionEnvironment, 0, deviceBitfield){};
|
2019-10-25 23:55:22 +08:00
|
|
|
CsrSizeRequestFlags *getCsrRequestFlags() { return &this->csrSizeRequestFlags; }
|
2022-03-10 01:15:48 +08:00
|
|
|
bool hasSharedHandles() override {
|
|
|
|
if (hasSharedHandlesReturnValue) {
|
|
|
|
return *hasSharedHandlesReturnValue;
|
|
|
|
}
|
|
|
|
return UltCommandStreamReceiver<FamilyType>::hasSharedHandles();
|
|
|
|
};
|
|
|
|
std::optional<bool> hasSharedHandlesReturnValue;
|
2019-10-25 23:55:22 +08:00
|
|
|
};
|
|
|
|
void makeResidentSharedAlloc() {
|
|
|
|
csr->getResidencyAllocations().push_back(alloc);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename FamilyType>
|
2021-12-09 00:22:18 +08:00
|
|
|
void overrideComputeModeRequest(bool reqestChanged, bool requireCoherency, bool hasSharedHandles,
|
|
|
|
bool modifyThreadArbitrationPolicy = false, bool numGrfRequiredChanged = false,
|
|
|
|
uint32_t numGrfRequired = 128u) {
|
|
|
|
overrideComputeModeRequest<FamilyType>(reqestChanged, requireCoherency, hasSharedHandles, numGrfRequiredChanged, numGrfRequired);
|
2019-10-25 23:55:22 +08:00
|
|
|
if (modifyThreadArbitrationPolicy) {
|
2021-12-14 19:47:15 +08:00
|
|
|
auto &hwHelper = NEO::HwHelper::get(device->getHardwareInfo().platform.eRenderCoreFamily);
|
2021-12-09 00:22:18 +08:00
|
|
|
auto csrHw = getCsrHw<FamilyType>();
|
2021-12-14 19:47:15 +08:00
|
|
|
csrHw->streamProperties.stateComputeMode.threadArbitrationPolicy.value = hwHelper.getDefaultThreadArbitrationPolicy();
|
2021-12-09 00:22:18 +08:00
|
|
|
csrHw->streamProperties.stateComputeMode.threadArbitrationPolicy.isDirty = true;
|
2019-10-25 23:55:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename FamilyType>
|
|
|
|
void overrideComputeModeRequest(bool coherencyRequestChanged,
|
|
|
|
bool requireCoherency,
|
|
|
|
bool hasSharedHandles,
|
|
|
|
bool numGrfRequiredChanged,
|
2019-12-09 16:15:34 +08:00
|
|
|
uint32_t numGrfRequired) {
|
2019-10-25 23:55:22 +08:00
|
|
|
auto csrHw = getCsrHw<FamilyType>();
|
2022-03-10 01:15:48 +08:00
|
|
|
csrHw->hasSharedHandlesReturnValue = hasSharedHandles;
|
2019-10-25 23:55:22 +08:00
|
|
|
flags.requiresCoherency = requireCoherency;
|
2021-12-09 00:22:18 +08:00
|
|
|
csrHw->streamProperties.stateComputeMode.isCoherencyRequired.value = requireCoherency;
|
|
|
|
csrHw->streamProperties.stateComputeMode.isCoherencyRequired.isDirty = coherencyRequestChanged;
|
|
|
|
csrHw->streamProperties.stateComputeMode.largeGrfMode.value = (numGrfRequired == GrfConfig::LargeGrfNumber);
|
|
|
|
csrHw->streamProperties.stateComputeMode.largeGrfMode.isDirty = numGrfRequiredChanged;
|
2019-10-25 23:55:22 +08:00
|
|
|
if (hasSharedHandles) {
|
|
|
|
makeResidentSharedAlloc();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename FamilyType>
|
|
|
|
myCsr<FamilyType> *getCsrHw() {
|
|
|
|
return static_cast<myCsr<FamilyType> *>(csr);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename FamilyType>
|
|
|
|
void SetUpImpl() {
|
2020-06-26 21:54:40 +08:00
|
|
|
SetUpImpl<FamilyType>(defaultHwInfo.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename FamilyType>
|
|
|
|
void SetUpImpl(const NEO::HardwareInfo *hardwareInfo) {
|
|
|
|
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(hardwareInfo));
|
2021-10-19 00:47:09 +08:00
|
|
|
device->executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(hardwareInfo);
|
2020-10-28 23:08:37 +08:00
|
|
|
csr = new myCsr<FamilyType>(*device->executionEnvironment, device->getDeviceBitfield());
|
2021-10-19 00:47:09 +08:00
|
|
|
|
2019-10-25 23:55:22 +08:00
|
|
|
device->resetCommandStreamReceiver(csr);
|
2022-02-04 21:59:01 +08:00
|
|
|
AllocationProperties properties(device->getRootDeviceIndex(), false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
2019-10-25 23:55:22 +08:00
|
|
|
|
2021-12-27 21:49:29 +08:00
|
|
|
alloc = device->getMemoryManager()->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(123), properties, false, false);
|
2019-10-25 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
|
|
|
device->getMemoryManager()->freeGraphicsMemory(alloc);
|
|
|
|
}
|
|
|
|
|
|
|
|
CommandStreamReceiver *csr = nullptr;
|
|
|
|
std::unique_ptr<MockDevice> device;
|
2021-12-06 18:01:46 +08:00
|
|
|
DispatchFlags flags{{}, nullptr, {}, nullptr, QueueThrottle::MEDIUM, PreemptionMode::Disabled, GrfConfig::DefaultGrfNumber, L3CachingSettings::l3CacheOn, ThreadArbitrationPolicy::NotPresent, AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable, MemoryCompressionState::NotApplicable, QueueSliceCount::defaultSliceCount, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
|
2019-10-25 23:55:22 +08:00
|
|
|
GraphicsAllocation *alloc = nullptr;
|
|
|
|
};
|