mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Move aub and tbx code to shared
Related-To: NEO-3964 Change-Id: Ice978e582721498d7496f989767ce7d6f5f4caf4 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
ccd5abfbfd
commit
ca5f34133b
22
shared/source/aub/CMakeLists.txt
Normal file
22
shared/source/aub/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(NEO_CORE_AUB
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_center.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_center.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/aub_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_helper_add_mmio.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_helper_base.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_helper_bdw_plus.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_mapper_base.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_stream_provider.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_subcapture.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_subcapture.h
|
||||
)
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_AUB ${NEO_CORE_AUB})
|
||||
add_subdirectories()
|
||||
82
shared/source/aub/aub_center.cpp
Normal file
82
shared/source/aub/aub_center.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/aub/aub_center.h"
|
||||
|
||||
#include "shared/source/aub/aub_helper.h"
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
|
||||
#include "third_party/aub_stream/headers/aub_manager.h"
|
||||
#include "third_party/aub_stream/headers/aubstream.h"
|
||||
|
||||
namespace NEO {
|
||||
extern aub_stream::AubManager *createAubManager(uint32_t productFamily, uint32_t devicesCount, uint64_t memoryBankSize, uint32_t stepping, bool localMemorySupported, uint32_t streamMode, uint64_t gpuAddressSpace);
|
||||
|
||||
AubCenter::AubCenter(const HardwareInfo *pHwInfo, bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType) {
|
||||
if (DebugManager.flags.UseAubStream.get()) {
|
||||
auto devicesCount = HwHelper::getSubDevicesCount(pHwInfo);
|
||||
auto memoryBankSize = AubHelper::getMemBankSize(pHwInfo);
|
||||
CommandStreamReceiverType type = csrType;
|
||||
if (DebugManager.flags.SetCommandStreamReceiver.get() >= CommandStreamReceiverType::CSR_HW) {
|
||||
type = static_cast<CommandStreamReceiverType>(DebugManager.flags.SetCommandStreamReceiver.get());
|
||||
}
|
||||
|
||||
aubStreamMode = getAubStreamMode(aubFileName, type);
|
||||
|
||||
AubHelper::setAdditionalMmioList();
|
||||
if (DebugManager.flags.AubDumpAddMmioRegistersList.get() != "unk") {
|
||||
aub_stream::injectMMIOList(AubHelper::getAdditionalMmioList());
|
||||
}
|
||||
|
||||
AubHelper::setTbxConfiguration();
|
||||
|
||||
aubManager.reset(createAubManager(pHwInfo->platform.eProductFamily, devicesCount, memoryBankSize, pHwInfo->platform.usRevId, localMemoryEnabled, aubStreamMode, pHwInfo->capabilityTable.gpuAddressSpace));
|
||||
}
|
||||
addressMapper = std::make_unique<AddressMapper>();
|
||||
streamProvider = std::make_unique<AubFileStreamProvider>();
|
||||
subCaptureCommon = std::make_unique<AubSubCaptureCommon>();
|
||||
if (DebugManager.flags.AUBDumpSubCaptureMode.get()) {
|
||||
this->subCaptureCommon->subCaptureMode = static_cast<AubSubCaptureCommon::SubCaptureMode>(DebugManager.flags.AUBDumpSubCaptureMode.get());
|
||||
this->subCaptureCommon->subCaptureFilter.dumpKernelStartIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterKernelStartIdx.get());
|
||||
this->subCaptureCommon->subCaptureFilter.dumpKernelEndIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterKernelEndIdx.get());
|
||||
this->subCaptureCommon->subCaptureFilter.dumpNamedKernelStartIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterNamedKernelStartIdx.get());
|
||||
this->subCaptureCommon->subCaptureFilter.dumpNamedKernelEndIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterNamedKernelEndIdx.get());
|
||||
if (DebugManager.flags.AUBDumpFilterKernelName.get() != "unk") {
|
||||
this->subCaptureCommon->subCaptureFilter.dumpKernelName = DebugManager.flags.AUBDumpFilterKernelName.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AubCenter::AubCenter() {
|
||||
addressMapper = std::make_unique<AddressMapper>();
|
||||
streamProvider = std::make_unique<AubFileStreamProvider>();
|
||||
subCaptureCommon = std::make_unique<AubSubCaptureCommon>();
|
||||
}
|
||||
|
||||
uint32_t AubCenter::getAubStreamMode(const std::string &aubFileName, uint32_t csrType) {
|
||||
uint32_t mode = aub_stream::mode::aubFile;
|
||||
|
||||
switch (csrType) {
|
||||
case CommandStreamReceiverType::CSR_HW_WITH_AUB:
|
||||
case CommandStreamReceiverType::CSR_AUB:
|
||||
mode = aub_stream::mode::aubFile;
|
||||
break;
|
||||
case CommandStreamReceiverType::CSR_TBX:
|
||||
mode = aub_stream::mode::tbx;
|
||||
break;
|
||||
case CommandStreamReceiverType::CSR_TBX_WITH_AUB:
|
||||
mode = aub_stream::mode::aubFileAndTbx;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
} // namespace NEO
|
||||
62
shared/source/aub/aub_center.h
Normal file
62
shared/source/aub/aub_center.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/aub/aub_stream_provider.h"
|
||||
#include "shared/source/aub/aub_subcapture.h"
|
||||
#include "shared/source/helpers/options.h"
|
||||
#include "shared/source/memory_manager/address_mapper.h"
|
||||
#include "shared/source/memory_manager/physical_address_allocator.h"
|
||||
|
||||
#include "third_party/aub_stream/headers/aub_manager.h"
|
||||
|
||||
namespace NEO {
|
||||
struct HardwareInfo;
|
||||
|
||||
class AubCenter {
|
||||
public:
|
||||
AubCenter(const HardwareInfo *pHwInfo, bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType);
|
||||
|
||||
AubCenter();
|
||||
virtual ~AubCenter() = default;
|
||||
|
||||
void initPhysicalAddressAllocator(PhysicalAddressAllocator *pPhysicalAddressAllocator) {
|
||||
physicalAddressAllocator = std::unique_ptr<PhysicalAddressAllocator>(pPhysicalAddressAllocator);
|
||||
}
|
||||
|
||||
PhysicalAddressAllocator *getPhysicalAddressAllocator() const {
|
||||
return physicalAddressAllocator.get();
|
||||
}
|
||||
|
||||
AddressMapper *getAddressMapper() const {
|
||||
return addressMapper.get();
|
||||
}
|
||||
|
||||
AubStreamProvider *getStreamProvider() const {
|
||||
return streamProvider.get();
|
||||
}
|
||||
|
||||
AubSubCaptureCommon *getSubCaptureCommon() const {
|
||||
return subCaptureCommon.get();
|
||||
}
|
||||
|
||||
aub_stream::AubManager *getAubManager() const {
|
||||
return aubManager.get();
|
||||
}
|
||||
|
||||
static uint32_t getAubStreamMode(const std::string &aubFileName, uint32_t csrType);
|
||||
|
||||
protected:
|
||||
std::unique_ptr<PhysicalAddressAllocator> physicalAddressAllocator;
|
||||
std::unique_ptr<AddressMapper> addressMapper;
|
||||
std::unique_ptr<AubStreamProvider> streamProvider;
|
||||
|
||||
std::unique_ptr<AubSubCaptureCommon> subCaptureCommon;
|
||||
std::unique_ptr<aub_stream::AubManager> aubManager;
|
||||
uint32_t aubStreamMode = 0;
|
||||
};
|
||||
} // namespace NEO
|
||||
46
shared/source/aub/aub_helper.cpp
Normal file
46
shared/source/aub/aub_helper.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/aub/aub_helper.h"
|
||||
|
||||
#include "shared/source/aub_mem_dump/aub_mem_dump.h"
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
|
||||
#include "third_party/aub_stream/headers/aubstream.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
uint64_t AubHelper::getTotalMemBankSize() {
|
||||
return 2 * GB;
|
||||
}
|
||||
|
||||
int AubHelper::getMemTrace(uint64_t pdEntryBits) {
|
||||
return AubMemDump::AddressSpaceValues::TraceNonlocal;
|
||||
}
|
||||
|
||||
uint64_t AubHelper::getPTEntryBits(uint64_t pdEntryBits) {
|
||||
return pdEntryBits;
|
||||
}
|
||||
|
||||
uint32_t AubHelper::getMemType(uint32_t addressSpace) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t AubHelper::getMemBankSize(const HardwareInfo *pHwInfo) {
|
||||
return getTotalMemBankSize();
|
||||
}
|
||||
|
||||
void AubHelper::setAdditionalMmioList() {
|
||||
}
|
||||
|
||||
void AubHelper::setTbxConfiguration() {
|
||||
aub_stream::setTbxServerIp(DebugManager.flags.TbxServer.get());
|
||||
aub_stream::setTbxServerPort(DebugManager.flags.TbxPort.get());
|
||||
aub_stream::setTbxFrontdoorMode(DebugManager.flags.TbxFrontdoorMode.get());
|
||||
}
|
||||
} // namespace NEO
|
||||
82
shared/source/aub/aub_helper.h
Normal file
82
shared/source/aub/aub_helper.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/aub/aub_mapper_base.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class AubHelper : public NonCopyableOrMovableClass {
|
||||
public:
|
||||
static bool isOneTimeAubWritableAllocationType(const GraphicsAllocation::AllocationType &type) {
|
||||
switch (type) {
|
||||
case GraphicsAllocation::AllocationType::PIPE:
|
||||
case GraphicsAllocation::AllocationType::CONSTANT_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::GLOBAL_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::KERNEL_ISA:
|
||||
case GraphicsAllocation::AllocationType::PRIVATE_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::SCRATCH_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::BUFFER:
|
||||
case GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY:
|
||||
case GraphicsAllocation::AllocationType::BUFFER_COMPRESSED:
|
||||
case GraphicsAllocation::AllocationType::IMAGE:
|
||||
case GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER:
|
||||
case GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR:
|
||||
case GraphicsAllocation::AllocationType::MAP_ALLOCATION:
|
||||
case GraphicsAllocation::AllocationType::SVM_GPU:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t getTotalMemBankSize();
|
||||
static int getMemTrace(uint64_t pdEntryBits);
|
||||
static uint64_t getPTEntryBits(uint64_t pdEntryBits);
|
||||
static uint32_t getMemType(uint32_t addressSpace);
|
||||
static uint64_t getMemBankSize(const HardwareInfo *pHwInfo);
|
||||
static MMIOList getAdditionalMmioList();
|
||||
static void setAdditionalMmioList();
|
||||
static void setTbxConfiguration();
|
||||
|
||||
virtual int getDataHintForPml4Entry() const = 0;
|
||||
virtual int getDataHintForPdpEntry() const = 0;
|
||||
virtual int getDataHintForPdEntry() const = 0;
|
||||
virtual int getDataHintForPtEntry() const = 0;
|
||||
|
||||
virtual int getMemTraceForPml4Entry() const = 0;
|
||||
virtual int getMemTraceForPdpEntry() const = 0;
|
||||
virtual int getMemTraceForPdEntry() const = 0;
|
||||
virtual int getMemTraceForPtEntry() const = 0;
|
||||
|
||||
protected:
|
||||
static MMIOList splitMMIORegisters(const std::string ®isters, char delimiter);
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
class AubHelperHw : public AubHelper {
|
||||
public:
|
||||
AubHelperHw(bool localMemoryEnabled) : localMemoryEnabled(localMemoryEnabled){};
|
||||
|
||||
int getDataHintForPml4Entry() const override;
|
||||
int getDataHintForPdpEntry() const override;
|
||||
int getDataHintForPdEntry() const override;
|
||||
int getDataHintForPtEntry() const override;
|
||||
|
||||
int getMemTraceForPml4Entry() const override;
|
||||
int getMemTraceForPdpEntry() const override;
|
||||
int getMemTraceForPdEntry() const override;
|
||||
int getMemTraceForPtEntry() const override;
|
||||
|
||||
protected:
|
||||
bool localMemoryEnabled;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
55
shared/source/aub/aub_helper_add_mmio.cpp
Normal file
55
shared/source/aub/aub_helper_add_mmio.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/aub/aub_helper.h"
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "third_party/aub_stream/headers/aubstream.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
MMIOList AubHelper::getAdditionalMmioList() {
|
||||
return splitMMIORegisters(DebugManager.flags.AubDumpAddMmioRegistersList.get(), ';');
|
||||
}
|
||||
|
||||
MMIOList AubHelper::splitMMIORegisters(const std::string ®isters, char delimiter) {
|
||||
MMIOList result;
|
||||
bool firstElementInPair = false;
|
||||
std::string token;
|
||||
uint32_t registerOffset = 0;
|
||||
uint32_t registerValue = 0;
|
||||
std::istringstream stream("");
|
||||
|
||||
for (std::string::const_iterator i = registers.begin();; i++) {
|
||||
if (i == registers.end() || *i == delimiter) {
|
||||
if (token.size() > 0) {
|
||||
stream.str(token);
|
||||
stream.clear();
|
||||
firstElementInPair = !firstElementInPair;
|
||||
stream >> std::hex >> (firstElementInPair ? registerOffset : registerValue);
|
||||
if (stream.fail()) {
|
||||
result.clear();
|
||||
break;
|
||||
}
|
||||
token.clear();
|
||||
if (!firstElementInPair) {
|
||||
result.push_back(std::pair<uint32_t, uint32_t>(registerOffset, registerValue));
|
||||
registerValue = 0;
|
||||
registerOffset = 0;
|
||||
}
|
||||
}
|
||||
if (i == registers.end()) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
token.push_back(*i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
45
shared/source/aub/aub_helper_base.inl
Normal file
45
shared/source/aub/aub_helper_base.inl
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/aub/aub_helper.h"
|
||||
#include "shared/source/aub_mem_dump/aub_mem_dump.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename Family>
|
||||
int AubHelperHw<Family>::getMemTraceForPml4Entry() const {
|
||||
if (localMemoryEnabled) {
|
||||
return AubMemDump::AddressSpaceValues::TraceLocal;
|
||||
}
|
||||
return AubMemDump::AddressSpaceValues::TracePml4Entry;
|
||||
}
|
||||
|
||||
template <typename Family>
|
||||
int AubHelperHw<Family>::getMemTraceForPdpEntry() const {
|
||||
if (localMemoryEnabled) {
|
||||
return AubMemDump::AddressSpaceValues::TraceLocal;
|
||||
}
|
||||
return AubMemDump::AddressSpaceValues::TracePhysicalPdpEntry;
|
||||
}
|
||||
|
||||
template <typename Family>
|
||||
int AubHelperHw<Family>::getMemTraceForPdEntry() const {
|
||||
if (localMemoryEnabled) {
|
||||
return AubMemDump::AddressSpaceValues::TraceLocal;
|
||||
}
|
||||
return AubMemDump::AddressSpaceValues::TracePpgttPdEntry;
|
||||
}
|
||||
|
||||
template <typename Family>
|
||||
int AubHelperHw<Family>::getMemTraceForPtEntry() const {
|
||||
if (localMemoryEnabled) {
|
||||
return AubMemDump::AddressSpaceValues::TraceLocal;
|
||||
}
|
||||
return AubMemDump::AddressSpaceValues::TracePpgttEntry;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
32
shared/source/aub/aub_helper_bdw_plus.inl
Normal file
32
shared/source/aub/aub_helper_bdw_plus.inl
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/aub/aub_helper_base.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename GfxFamily>
|
||||
int AubHelperHw<GfxFamily>::getDataHintForPml4Entry() const {
|
||||
return AubMemDump::DataTypeHintValues::TraceNotype;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
int AubHelperHw<GfxFamily>::getDataHintForPdpEntry() const {
|
||||
return AubMemDump::DataTypeHintValues::TraceNotype;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
int AubHelperHw<GfxFamily>::getDataHintForPdEntry() const {
|
||||
return AubMemDump::DataTypeHintValues::TraceNotype;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
int AubHelperHw<GfxFamily>::getDataHintForPtEntry() const {
|
||||
return AubMemDump::DataTypeHintValues::TraceNotype;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
23
shared/source/aub/aub_mapper_base.h
Normal file
23
shared/source/aub/aub_mapper_base.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/aub_mem_dump/aub_mem_dump.h"
|
||||
#include "shared/source/helpers/completion_stamp.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct AUBFamilyMapper {
|
||||
};
|
||||
|
||||
using MMIOPair = std::pair<uint32_t, uint32_t>;
|
||||
using MMIOList = std::vector<MMIOPair>;
|
||||
|
||||
} // namespace NEO
|
||||
14
shared/source/aub/aub_stream_interface.cpp
Normal file
14
shared/source/aub/aub_stream_interface.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/aub/aub_center.h"
|
||||
using namespace aub_stream;
|
||||
namespace NEO {
|
||||
AubManager *createAubManager(uint32_t gfxFamily, uint32_t devicesCount, uint64_t memoryBankSize, uint32_t stepping, bool localMemorySupported, uint32_t streamMode, uint64_t gpuAddressSpace) {
|
||||
return AubManager::create(gfxFamily, devicesCount, memoryBankSize, stepping, localMemorySupported, streamMode, gpuAddressSpace);
|
||||
}
|
||||
} // namespace NEO
|
||||
31
shared/source/aub/aub_stream_provider.h
Normal file
31
shared/source/aub/aub_stream_provider.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/aub_mem_dump/aub_mem_dump.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class AubStreamProvider {
|
||||
public:
|
||||
virtual ~AubStreamProvider() = default;
|
||||
|
||||
virtual AubMemDump::AubFileStream *getStream() = 0;
|
||||
};
|
||||
|
||||
class AubFileStreamProvider : public AubStreamProvider {
|
||||
public:
|
||||
AubMemDump::AubFileStream *getStream() override {
|
||||
return &stream;
|
||||
};
|
||||
|
||||
protected:
|
||||
AubMemDump::AubFileStream stream;
|
||||
};
|
||||
} // namespace NEO
|
||||
167
shared/source/aub/aub_subcapture.cpp
Normal file
167
shared/source/aub/aub_subcapture.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/aub/aub_subcapture.h"
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/utilities/debug_settings_reader.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
AubSubCaptureManager::AubSubCaptureManager(const std::string &fileName, AubSubCaptureCommon &subCaptureCommon, const char *regPath)
|
||||
: initialFileName(fileName), subCaptureCommon(subCaptureCommon) {
|
||||
settingsReader.reset(SettingsReader::createOsReader(true, regPath));
|
||||
}
|
||||
|
||||
AubSubCaptureManager::~AubSubCaptureManager() = default;
|
||||
|
||||
bool AubSubCaptureManager::isSubCaptureEnabled() const {
|
||||
auto guard = this->lock();
|
||||
|
||||
return subCaptureIsActive || subCaptureWasActiveInPreviousEnqueue;
|
||||
}
|
||||
|
||||
void AubSubCaptureManager::disableSubCapture() {
|
||||
auto guard = this->lock();
|
||||
|
||||
subCaptureIsActive = subCaptureWasActiveInPreviousEnqueue = false;
|
||||
};
|
||||
|
||||
AubSubCaptureStatus AubSubCaptureManager::checkAndActivateSubCapture(const std::string &kernelName) {
|
||||
if (kernelName.empty()) {
|
||||
return {false, false};
|
||||
}
|
||||
|
||||
auto guard = this->lock();
|
||||
|
||||
kernelCurrentIdx = subCaptureCommon.getKernelCurrentIndexAndIncrement();
|
||||
|
||||
subCaptureWasActiveInPreviousEnqueue = subCaptureIsActive;
|
||||
subCaptureIsActive = false;
|
||||
|
||||
switch (subCaptureCommon.subCaptureMode) {
|
||||
case SubCaptureMode::Toggle:
|
||||
subCaptureIsActive = isSubCaptureToggleActive();
|
||||
break;
|
||||
case SubCaptureMode::Filter:
|
||||
subCaptureIsActive = isSubCaptureFilterActive(kernelName);
|
||||
break;
|
||||
default:
|
||||
DEBUG_BREAK_IF(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return {subCaptureIsActive, subCaptureWasActiveInPreviousEnqueue};
|
||||
}
|
||||
|
||||
AubSubCaptureStatus AubSubCaptureManager::getSubCaptureStatus() const {
|
||||
auto guard = this->lock();
|
||||
|
||||
return {this->subCaptureIsActive, this->subCaptureWasActiveInPreviousEnqueue};
|
||||
}
|
||||
|
||||
const std::string &AubSubCaptureManager::getSubCaptureFileName(const std::string &kernelName) {
|
||||
auto guard = this->lock();
|
||||
|
||||
if (useToggleFileName) {
|
||||
currentFileName = getToggleFileName();
|
||||
}
|
||||
|
||||
if (currentFileName.empty()) {
|
||||
currentFileName = getAubCaptureFileName();
|
||||
useToggleFileName = false;
|
||||
}
|
||||
|
||||
switch (subCaptureCommon.subCaptureMode) {
|
||||
case SubCaptureMode::Filter:
|
||||
if (currentFileName.empty()) {
|
||||
currentFileName = generateFilterFileName();
|
||||
useToggleFileName = false;
|
||||
}
|
||||
break;
|
||||
case SubCaptureMode::Toggle:
|
||||
if (currentFileName.empty()) {
|
||||
currentFileName = generateToggleFileName(kernelName);
|
||||
useToggleFileName = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DEBUG_BREAK_IF(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return currentFileName;
|
||||
}
|
||||
|
||||
bool AubSubCaptureManager::isKernelIndexInSubCaptureRange(uint32_t kernelIdx, uint32_t rangeStartIdx, uint32_t rangeEndIdx) const {
|
||||
return ((rangeStartIdx <= kernelIdx) && (kernelIdx <= rangeEndIdx));
|
||||
}
|
||||
|
||||
bool AubSubCaptureManager::isSubCaptureToggleActive() const {
|
||||
return settingsReader->getSetting("AUBDumpToggleCaptureOnOff", false);
|
||||
}
|
||||
|
||||
std::string AubSubCaptureManager::getToggleFileName() const {
|
||||
return settingsReader->getSetting("AUBDumpToggleFileName", std::string(""));
|
||||
}
|
||||
|
||||
std::string AubSubCaptureManager::getAubCaptureFileName() const {
|
||||
if (DebugManager.flags.AUBDumpCaptureFileName.get() != "unk") {
|
||||
return DebugManager.flags.AUBDumpCaptureFileName.get();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string AubSubCaptureManager::generateFilterFileName() const {
|
||||
std::string baseFileName = initialFileName.substr(0, initialFileName.length() - strlen(".aub"));
|
||||
std::string filterFileName = baseFileName + "_filter";
|
||||
filterFileName += "_from_" + std::to_string(subCaptureCommon.subCaptureFilter.dumpKernelStartIdx);
|
||||
filterFileName += "_to_" + std::to_string(subCaptureCommon.subCaptureFilter.dumpKernelEndIdx);
|
||||
if (!subCaptureCommon.subCaptureFilter.dumpKernelName.empty()) {
|
||||
filterFileName += "_" + subCaptureCommon.subCaptureFilter.dumpKernelName;
|
||||
filterFileName += "_from_" + std::to_string(subCaptureCommon.subCaptureFilter.dumpNamedKernelStartIdx);
|
||||
filterFileName += "_to_" + std::to_string(subCaptureCommon.subCaptureFilter.dumpNamedKernelEndIdx);
|
||||
}
|
||||
filterFileName += ".aub";
|
||||
return filterFileName;
|
||||
}
|
||||
|
||||
std::string AubSubCaptureManager::generateToggleFileName(const std::string &kernelName) const {
|
||||
std::string baseFileName = initialFileName.substr(0, initialFileName.length() - strlen(".aub"));
|
||||
std::string toggleFileName = baseFileName + "_toggle";
|
||||
toggleFileName += "_from_" + std::to_string(kernelCurrentIdx);
|
||||
if (!kernelName.empty()) {
|
||||
toggleFileName += "_" + kernelName;
|
||||
}
|
||||
toggleFileName += ".aub";
|
||||
return toggleFileName;
|
||||
}
|
||||
|
||||
bool AubSubCaptureManager::isSubCaptureFilterActive(const std::string &kernelName) {
|
||||
auto subCaptureIsActive = false;
|
||||
|
||||
if (subCaptureCommon.subCaptureFilter.dumpKernelName.empty()) {
|
||||
if (isKernelIndexInSubCaptureRange(kernelCurrentIdx, subCaptureCommon.subCaptureFilter.dumpKernelStartIdx, subCaptureCommon.subCaptureFilter.dumpKernelEndIdx)) {
|
||||
subCaptureIsActive = true;
|
||||
}
|
||||
} else {
|
||||
if (0 == kernelName.compare(subCaptureCommon.subCaptureFilter.dumpKernelName)) {
|
||||
kernelNameMatchesNum = subCaptureCommon.getKernelNameMatchesNumAndIncrement();
|
||||
if (isKernelIndexInSubCaptureRange(kernelNameMatchesNum, subCaptureCommon.subCaptureFilter.dumpNamedKernelStartIdx, subCaptureCommon.subCaptureFilter.dumpNamedKernelEndIdx)) {
|
||||
subCaptureIsActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return subCaptureIsActive;
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> AubSubCaptureManager::lock() const {
|
||||
return std::unique_lock<std::mutex>{mutex};
|
||||
}
|
||||
} // namespace NEO
|
||||
87
shared/source/aub/aub_subcapture.h
Normal file
87
shared/source/aub/aub_subcapture.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/command_stream/aub_subcapture_status.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class SettingsReader;
|
||||
|
||||
class AubSubCaptureCommon {
|
||||
public:
|
||||
enum class SubCaptureMode {
|
||||
Off = 0, //subcapture off
|
||||
Filter, //subcapture kernel specified by filter (static regkey)
|
||||
Toggle //toggle subcapture on/off (dynamic regkey)
|
||||
} subCaptureMode = SubCaptureMode::Off;
|
||||
|
||||
struct SubCaptureFilter {
|
||||
std::string dumpKernelName = "";
|
||||
uint32_t dumpNamedKernelStartIdx = 0;
|
||||
uint32_t dumpNamedKernelEndIdx = static_cast<uint32_t>(-1);
|
||||
uint32_t dumpKernelStartIdx = 0;
|
||||
uint32_t dumpKernelEndIdx = static_cast<uint32_t>(-1);
|
||||
} subCaptureFilter;
|
||||
|
||||
inline uint32_t getKernelCurrentIndexAndIncrement() { return kernelCurrentIdx.fetch_add(1); }
|
||||
inline uint32_t getKernelNameMatchesNumAndIncrement() { return kernelNameMatchesNum.fetch_add(1); }
|
||||
|
||||
protected:
|
||||
std::atomic<uint32_t> kernelCurrentIdx{0};
|
||||
std::atomic<uint32_t> kernelNameMatchesNum{0};
|
||||
};
|
||||
|
||||
class AubSubCaptureManager {
|
||||
public:
|
||||
using SubCaptureMode = AubSubCaptureCommon::SubCaptureMode;
|
||||
using SubCaptureFilter = AubSubCaptureCommon::SubCaptureFilter;
|
||||
|
||||
inline bool isSubCaptureMode() const {
|
||||
return subCaptureCommon.subCaptureMode > SubCaptureMode::Off;
|
||||
}
|
||||
|
||||
bool isSubCaptureEnabled() const;
|
||||
|
||||
void disableSubCapture();
|
||||
|
||||
AubSubCaptureStatus checkAndActivateSubCapture(const std::string &kernelName);
|
||||
|
||||
AubSubCaptureStatus getSubCaptureStatus() const;
|
||||
|
||||
const std::string &getSubCaptureFileName(const std::string &kernelName);
|
||||
|
||||
AubSubCaptureManager(const std::string &fileName, AubSubCaptureCommon &subCaptureCommon, const char *regPath);
|
||||
virtual ~AubSubCaptureManager();
|
||||
|
||||
protected:
|
||||
MOCKABLE_VIRTUAL bool isSubCaptureToggleActive() const;
|
||||
bool isSubCaptureFilterActive(const std::string &kernelName);
|
||||
MOCKABLE_VIRTUAL std::string getAubCaptureFileName() const;
|
||||
MOCKABLE_VIRTUAL std::string getToggleFileName() const;
|
||||
MOCKABLE_VIRTUAL std::string generateFilterFileName() const;
|
||||
MOCKABLE_VIRTUAL std::string generateToggleFileName(const std::string &kernelName) const;
|
||||
bool isKernelIndexInSubCaptureRange(uint32_t kernelIdx, uint32_t rangeStartIdx, uint32_t rangeEndIdx) const;
|
||||
MOCKABLE_VIRTUAL std::unique_lock<std::mutex> lock() const;
|
||||
|
||||
bool subCaptureIsActive = false;
|
||||
bool subCaptureWasActiveInPreviousEnqueue = false;
|
||||
uint32_t kernelCurrentIdx = 0;
|
||||
uint32_t kernelNameMatchesNum = 0;
|
||||
bool useToggleFileName = true;
|
||||
std::string initialFileName;
|
||||
std::string currentFileName;
|
||||
std::unique_ptr<SettingsReader> settingsReader;
|
||||
AubSubCaptureCommon &subCaptureCommon;
|
||||
mutable std::mutex mutex;
|
||||
};
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user