mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
Add diagnostic mode to direct submission
Related-To: NEO-4338 Change-Id: Ibcdc1b6a1762827337e4ff5364a972702130195a Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
@@ -87,6 +87,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionBufferAddressing, -1, "-1: do no
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionSemaphoreAddressing, -1, "-1: do not override, 0: not use 48bit, 1: use 48bit")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDisableCpuCacheFlush, -1, "-1: do not override, 0: disable, 1: enable")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionEnableDebugBuffer, 0, "0: diagnostic feature disabled - dispatch regular workload, 1: dispatch diagnostic buffer - mode 1 - single SDI command, 2: dispatch diagnostic buffer - mode 2 - no command")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDiagnosticExecutionCount, 30, "Number of executions of EnableDebugBuffer modes within diagnostic run")
|
||||
DECLARE_DEBUG_VARIABLE(bool, DirectSubmissionDisableCacheFlush, false, "Disable dispatching cache flush commands")
|
||||
DECLARE_DEBUG_VARIABLE(bool, DirectSubmissionDisableMonitorFence, false, "Disable dispatching monitor fence commands")
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ set(NEO_CORE_DIRECT_SUBMISSION
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/direct_submission_hw.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/direct_submission_hw.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/direct_submission_hw_diagnostic_mode.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/direct_submission_hw_diagnostic_mode.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/direct_submission_properties.h
|
||||
)
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ struct TagData {
|
||||
};
|
||||
|
||||
struct BatchBuffer;
|
||||
class DirectSubmissionDiagnosticsCollector;
|
||||
class FlushStampTracker;
|
||||
class GraphicsAllocation;
|
||||
struct HardwareInfo;
|
||||
@@ -60,6 +61,7 @@ class DirectSubmissionHw {
|
||||
|
||||
protected:
|
||||
static constexpr size_t prefetchSize = 8 * MemoryConstants::cacheLineSize;
|
||||
static constexpr size_t prefetchNoops = prefetchSize / sizeof(uint32_t);
|
||||
bool allocateResources();
|
||||
void deallocateResources();
|
||||
virtual bool allocateOsResources(DirectSubmissionAllocations &allocations) = 0;
|
||||
@@ -72,7 +74,7 @@ class DirectSubmissionHw {
|
||||
|
||||
void cpuCachelineFlush(void *ptr, size_t size);
|
||||
|
||||
void *dispatchSemaphoreSection(uint32_t value);
|
||||
void dispatchSemaphoreSection(uint32_t value);
|
||||
size_t getSizeSemaphoreSection();
|
||||
|
||||
void dispatchStartSection(uint64_t gpuStartAddress);
|
||||
@@ -81,27 +83,19 @@ class DirectSubmissionHw {
|
||||
void dispatchSwitchRingBufferSection(uint64_t nextBufferGpuAddress);
|
||||
size_t getSizeSwitchRingBufferSection();
|
||||
|
||||
void *dispatchFlushSection();
|
||||
size_t getSizeFlushSection();
|
||||
|
||||
void *dispatchTagUpdateSection(uint64_t address, uint64_t value);
|
||||
size_t getSizeTagUpdateSection();
|
||||
|
||||
void dispatchEndingSection();
|
||||
size_t getSizeEndingSection();
|
||||
|
||||
void setReturnAddress(void *returnCmd, uint64_t returnAddress);
|
||||
|
||||
void *dispatchWorkloadSection(BatchBuffer &batchBuffer);
|
||||
size_t getSizeDispatch();
|
||||
|
||||
void dispatchStoreDataSection(uint64_t gpuVa, uint32_t value);
|
||||
size_t getSizeStoraDataSection();
|
||||
|
||||
size_t getSizeEnd();
|
||||
|
||||
uint64_t getCommandBufferPositionGpuAddress(void *position);
|
||||
|
||||
void createDiagnostic();
|
||||
void initDiagnostic(bool &submitOnInit);
|
||||
MOCKABLE_VIRTUAL void performDiagnosticMode();
|
||||
|
||||
enum RingBufferUse : uint32_t {
|
||||
FirstBuffer,
|
||||
SecondBuffer,
|
||||
@@ -110,6 +104,7 @@ class DirectSubmissionHw {
|
||||
|
||||
LinearStream ringCommandStream;
|
||||
FlushStamp completionRingBuffers[RingBufferUse::MaxBuffers] = {0ull, 0ull};
|
||||
std::unique_ptr<DirectSubmissionDiagnosticsCollector> diagnostic;
|
||||
|
||||
uint64_t semaphoreGpuVa = 0u;
|
||||
|
||||
@@ -121,10 +116,15 @@ class DirectSubmissionHw {
|
||||
GraphicsAllocation *semaphores = nullptr;
|
||||
void *semaphorePtr = nullptr;
|
||||
volatile RingSemaphoreData *semaphoreData = nullptr;
|
||||
volatile void *workloadModeOneStoreAddress = nullptr;
|
||||
|
||||
uint32_t currentQueueWorkCount = 1u;
|
||||
RingBufferUse currentRingBuffer = RingBufferUse::FirstBuffer;
|
||||
uint32_t workloadMode = 0;
|
||||
uint32_t workloadModeOneExpectedValue = 0u;
|
||||
|
||||
static constexpr bool defaultDisableCacheFlush = false;
|
||||
static constexpr bool defaultDisableMonitorFence = false;
|
||||
|
||||
bool ringStart = false;
|
||||
bool disableCpuCacheFlush = false;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/direct_submission/direct_submission_hw.h"
|
||||
#include "shared/source/direct_submission/direct_submission_hw_diagnostic_mode.h"
|
||||
#include "shared/source/helpers/flush_stamp.h"
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/memory_manager/allocation_properties.h"
|
||||
@@ -29,19 +30,19 @@ DirectSubmissionHw<GfxFamily, Dispatcher>::DirectSubmissionHw(Device &device,
|
||||
: device(device), osContext(osContext) {
|
||||
UNRECOVERABLE_IF(!CpuInfo::getInstance().isFeatureSupported(CpuInfo::featureClflush));
|
||||
|
||||
disableCacheFlush = defaultDisableCacheFlush;
|
||||
disableMonitorFence = defaultDisableMonitorFence;
|
||||
|
||||
int32_t disableCacheFlushKey = DebugManager.flags.DirectSubmissionDisableCpuCacheFlush.get();
|
||||
if (disableCacheFlushKey != -1) {
|
||||
disableCpuCacheFlush = disableCacheFlushKey == 1 ? true : false;
|
||||
}
|
||||
workloadMode = DebugManager.flags.DirectSubmissionEnableDebugBuffer.get();
|
||||
disableCacheFlush = DebugManager.flags.DirectSubmissionDisableCacheFlush.get();
|
||||
disableMonitorFence = DebugManager.flags.DirectSubmissionDisableMonitorFence.get();
|
||||
hwInfo = &device.getHardwareInfo();
|
||||
createDiagnostic();
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
DirectSubmissionHw<GfxFamily, Dispatcher>::~DirectSubmissionHw() {
|
||||
}
|
||||
DirectSubmissionHw<GfxFamily, Dispatcher>::~DirectSubmissionHw() = default;
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
bool DirectSubmissionHw<GfxFamily, Dispatcher>::allocateResources() {
|
||||
@@ -84,7 +85,8 @@ bool DirectSubmissionHw<GfxFamily, Dispatcher>::allocateResources() {
|
||||
memset(semaphorePtr, 0, sizeof(RingSemaphoreData));
|
||||
semaphoreData->QueueWorkCount = 0;
|
||||
cpuCachelineFlush(semaphorePtr, MemoryConstants::cacheLineSize);
|
||||
|
||||
workloadModeOneStoreAddress = static_cast<volatile void *>(&semaphoreData->Reserved1Uint32);
|
||||
*static_cast<volatile uint32_t *>(workloadModeOneStoreAddress) = 0u;
|
||||
return allocateOsResources(allocations);
|
||||
}
|
||||
|
||||
@@ -110,6 +112,8 @@ inline void DirectSubmissionHw<GfxFamily, Dispatcher>::cpuCachelineFlush(void *p
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
bool DirectSubmissionHw<GfxFamily, Dispatcher>::initialize(bool submitOnInit) {
|
||||
bool ret = allocateResources();
|
||||
|
||||
initDiagnostic(submitOnInit);
|
||||
if (ret && submitOnInit) {
|
||||
size_t startBufferSize = Dispatcher::getSizePreemption() +
|
||||
getSizeSemaphoreSection();
|
||||
@@ -117,6 +121,7 @@ bool DirectSubmissionHw<GfxFamily, Dispatcher>::initialize(bool submitOnInit) {
|
||||
dispatchSemaphoreSection(currentQueueWorkCount);
|
||||
|
||||
ringStart = submit(ringCommandStream.getGraphicsAllocation()->getGpuAddress(), startBufferSize);
|
||||
performDiagnosticMode();
|
||||
return ringStart;
|
||||
}
|
||||
return ret;
|
||||
@@ -145,13 +150,13 @@ bool DirectSubmissionHw<GfxFamily, Dispatcher>::startRingBuffer() {
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
bool DirectSubmissionHw<GfxFamily, Dispatcher>::stopRingBuffer() {
|
||||
void *flushPtr = ringCommandStream.getSpace(0);
|
||||
dispatchFlushSection();
|
||||
Dispatcher::dispatchCacheFlush(ringCommandStream, *hwInfo);
|
||||
if (disableMonitorFence) {
|
||||
TagData currentTagData = {};
|
||||
getTagAddressValue(currentTagData);
|
||||
dispatchTagUpdateSection(currentTagData.tagAddress, currentTagData.tagValue);
|
||||
Dispatcher::dispatchMonitorFence(ringCommandStream, currentTagData.tagAddress, currentTagData.tagValue, *hwInfo);
|
||||
}
|
||||
dispatchEndingSection();
|
||||
Dispatcher::dispatchStopCommandBuffer(ringCommandStream);
|
||||
cpuCachelineFlush(flushPtr, getSizeEnd());
|
||||
|
||||
semaphoreData->QueueWorkCount = currentQueueWorkCount;
|
||||
@@ -161,19 +166,21 @@ bool DirectSubmissionHw<GfxFamily, Dispatcher>::stopRingBuffer() {
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline void *DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchSemaphoreSection(uint32_t value) {
|
||||
inline void DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchSemaphoreSection(uint32_t value) {
|
||||
using MI_SEMAPHORE_WAIT = typename GfxFamily::MI_SEMAPHORE_WAIT;
|
||||
using COMPARE_OPERATION = typename GfxFamily::MI_SEMAPHORE_WAIT::COMPARE_OPERATION;
|
||||
|
||||
void *semaphorePosition = ringCommandStream.getSpace(0);
|
||||
|
||||
EncodeSempahore<GfxFamily>::addMiSemaphoreWaitCommand(ringCommandStream,
|
||||
semaphoreGpuVa,
|
||||
value,
|
||||
COMPARE_OPERATION::COMPARE_OPERATION_SAD_GREATER_THAN_OR_EQUAL_SDD);
|
||||
void *prefetchSpace = ringCommandStream.getSpace(prefetchSize);
|
||||
memset(prefetchSpace, 0, prefetchSize);
|
||||
return semaphorePosition;
|
||||
uint32_t *prefetchNoop = static_cast<uint32_t *>(ringCommandStream.getSpace(prefetchSize));
|
||||
size_t i = 0u;
|
||||
while (i < prefetchNoops) {
|
||||
*prefetchNoop = 0u;
|
||||
prefetchNoop++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
@@ -202,57 +209,12 @@ inline size_t DirectSubmissionHw<GfxFamily, Dispatcher>::getSizeSwitchRingBuffer
|
||||
return Dispatcher::getSizeStartCommandBuffer();
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline void *DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchFlushSection() {
|
||||
void *currentPosition = ringCommandStream.getSpace(0);
|
||||
Dispatcher::dispatchCacheFlush(ringCommandStream, *hwInfo);
|
||||
return currentPosition;
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline size_t DirectSubmissionHw<GfxFamily, Dispatcher>::getSizeFlushSection() {
|
||||
return Dispatcher::getSizeCacheFlush(*hwInfo);
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline void *DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchTagUpdateSection(uint64_t address, uint64_t value) {
|
||||
void *currentPosition = ringCommandStream.getSpace(0);
|
||||
Dispatcher::dispatchMonitorFence(ringCommandStream, address, value, *hwInfo);
|
||||
return currentPosition;
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline size_t DirectSubmissionHw<GfxFamily, Dispatcher>::getSizeTagUpdateSection() {
|
||||
size_t size = Dispatcher::getSizeMonitorFence(*hwInfo);
|
||||
return size;
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline void DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchEndingSection() {
|
||||
Dispatcher::dispatchStopCommandBuffer(ringCommandStream);
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline size_t DirectSubmissionHw<GfxFamily, Dispatcher>::getSizeEndingSection() {
|
||||
return Dispatcher::getSizeStopCommandBuffer();
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline void DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchStoreDataSection(uint64_t gpuVa, uint32_t value) {
|
||||
Dispatcher::dispatchStoreDwordCommand(ringCommandStream, gpuVa, value);
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline size_t DirectSubmissionHw<GfxFamily, Dispatcher>::getSizeStoraDataSection() {
|
||||
return Dispatcher::getSizeStoreDwordCommand();
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
inline size_t DirectSubmissionHw<GfxFamily, Dispatcher>::getSizeEnd() {
|
||||
size_t size = getSizeEndingSection() +
|
||||
getSizeFlushSection();
|
||||
size_t size = Dispatcher::getSizeStopCommandBuffer() +
|
||||
Dispatcher::getSizeCacheFlush(*hwInfo);
|
||||
if (disableMonitorFence) {
|
||||
size += getSizeTagUpdateSection();
|
||||
size += Dispatcher::getSizeMonitorFence(*hwInfo);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
@@ -271,15 +233,15 @@ inline size_t DirectSubmissionHw<GfxFamily, Dispatcher>::getSizeDispatch() {
|
||||
if (workloadMode == 0) {
|
||||
size += getSizeStartSection();
|
||||
} else if (workloadMode == 1) {
|
||||
size += getSizeStoraDataSection();
|
||||
size += Dispatcher::getSizeStoreDwordCommand();
|
||||
}
|
||||
//mode 2 does not dispatch any commands
|
||||
|
||||
if (!disableCacheFlush) {
|
||||
size += getSizeFlushSection();
|
||||
size += Dispatcher::getSizeCacheFlush(*hwInfo);
|
||||
}
|
||||
if (!disableMonitorFence) {
|
||||
size += getSizeTagUpdateSection();
|
||||
size += Dispatcher::getSizeMonitorFence(*hwInfo);
|
||||
}
|
||||
|
||||
return size;
|
||||
@@ -298,20 +260,22 @@ void *DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchWorkloadSection(BatchBu
|
||||
|
||||
setReturnAddress(returnCmd, getCommandBufferPositionGpuAddress(returnPosition));
|
||||
} else if (workloadMode == 1) {
|
||||
workloadModeOneExpectedValue++;
|
||||
uint64_t storeAddress = semaphoreGpuVa;
|
||||
storeAddress += ptrDiff(&static_cast<RingSemaphoreData *>(semaphorePtr)->Reserved1Uint32, semaphorePtr);
|
||||
dispatchStoreDataSection(storeAddress, currentQueueWorkCount);
|
||||
storeAddress += ptrDiff(workloadModeOneStoreAddress, semaphorePtr);
|
||||
DirectSubmissionDiagnostics::diagnosticModeOneDispatch(diagnostic.get());
|
||||
Dispatcher::dispatchStoreDwordCommand(ringCommandStream, storeAddress, workloadModeOneExpectedValue);
|
||||
}
|
||||
//mode 2 does not dispatch any commands
|
||||
|
||||
if (!disableCacheFlush) {
|
||||
dispatchFlushSection();
|
||||
Dispatcher::dispatchCacheFlush(ringCommandStream, *hwInfo);
|
||||
}
|
||||
|
||||
if (!disableMonitorFence) {
|
||||
TagData currentTagData = {};
|
||||
getTagAddressValue(currentTagData);
|
||||
dispatchTagUpdateSection(currentTagData.tagAddress, currentTagData.tagValue);
|
||||
Dispatcher::dispatchMonitorFence(ringCommandStream, currentTagData.tagAddress, currentTagData.tagValue, *hwInfo);
|
||||
}
|
||||
|
||||
dispatchSemaphoreSection(currentQueueWorkCount + 1);
|
||||
@@ -346,7 +310,7 @@ bool DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchCommandBuffer(BatchBuffe
|
||||
semaphoreData->QueueWorkCount = currentQueueWorkCount;
|
||||
cpuCachelineFlush(semaphorePtr, MemoryConstants::cacheLineSize);
|
||||
currentQueueWorkCount++;
|
||||
|
||||
DirectSubmissionDiagnostics::diagnosticModeOneSubmit(diagnostic.get());
|
||||
//when ring buffer is not started at init or being restarted
|
||||
if (!ringStart) {
|
||||
size_t submitSize = dispatchSize;
|
||||
@@ -355,7 +319,6 @@ bool DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchCommandBuffer(BatchBuffe
|
||||
}
|
||||
ringStart = submit(startGpuVa, submitSize);
|
||||
}
|
||||
|
||||
uint64_t flushValue = updateTagValue();
|
||||
flushStamp.setStamp(flushValue);
|
||||
|
||||
@@ -401,4 +364,48 @@ void DirectSubmissionHw<GfxFamily, Dispatcher>::deallocateResources() {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
void DirectSubmissionHw<GfxFamily, Dispatcher>::createDiagnostic() {
|
||||
if (directSubmissionDiagnosticAvailable) {
|
||||
workloadMode = DebugManager.flags.DirectSubmissionEnableDebugBuffer.get();
|
||||
if (workloadMode > 0) {
|
||||
disableCacheFlush = DebugManager.flags.DirectSubmissionDisableCacheFlush.get();
|
||||
disableMonitorFence = DebugManager.flags.DirectSubmissionDisableMonitorFence.get();
|
||||
uint32_t executions = static_cast<uint32_t>(DebugManager.flags.DirectSubmissionDiagnosticExecutionCount.get());
|
||||
diagnostic = std::make_unique<DirectSubmissionDiagnosticsCollector>(executions, workloadMode == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
void DirectSubmissionHw<GfxFamily, Dispatcher>::initDiagnostic(bool &submitOnInit) {
|
||||
if (directSubmissionDiagnosticAvailable) {
|
||||
if (diagnostic.get()) {
|
||||
submitOnInit = true;
|
||||
diagnostic->diagnosticModeAllocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
void DirectSubmissionHw<GfxFamily, Dispatcher>::performDiagnosticMode() {
|
||||
if (directSubmissionDiagnosticAvailable) {
|
||||
if (diagnostic.get()) {
|
||||
diagnostic->diagnosticModeDiagnostic();
|
||||
BatchBuffer dummyBuffer = {};
|
||||
FlushStampTracker dummyTracker(true);
|
||||
for (uint32_t execution = 0; execution < diagnostic->getExecutionsCount(); execution++) {
|
||||
dispatchCommandBuffer(dummyBuffer, dummyTracker);
|
||||
if (workloadMode == 1) {
|
||||
diagnostic->diagnosticModeOneWait(execution, workloadModeOneStoreAddress, workloadModeOneExpectedValue);
|
||||
}
|
||||
}
|
||||
workloadMode = 0;
|
||||
disableCacheFlush = defaultDisableCacheFlush;
|
||||
disableMonitorFence = defaultDisableMonitorFence;
|
||||
diagnostic.reset(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/direct_submission/direct_submission_hw_diagnostic_mode.h"
|
||||
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
|
||||
namespace NEO {
|
||||
DirectSubmissionDiagnosticsCollector::DirectSubmissionDiagnosticsCollector(uint32_t executions, bool storeExecutions)
|
||||
: storeExecutions(storeExecutions) {
|
||||
UNRECOVERABLE_IF(executions == 0);
|
||||
executionList.resize(executions);
|
||||
executionsCount = executions;
|
||||
|
||||
std::chrono::system_clock::time_point timeStamp = std::chrono::system_clock::now();
|
||||
std::time_t dateTime = std::chrono::system_clock::to_time_t(timeStamp);
|
||||
|
||||
std::stringstream value;
|
||||
value << std::dec << "executions-" << executions;
|
||||
value << "_time-" << std::put_time(std::localtime(&dateTime), "%F-%T");
|
||||
std::stringstream filename;
|
||||
filename << "ulls_diagnostic_" << value.str() << ".log";
|
||||
logFile = IoFunctions::fopenPtr(filename.str().c_str(), "at");
|
||||
UNRECOVERABLE_IF(logFile == nullptr);
|
||||
IoFunctions::fprintf(logFile, "%s\n", value.str().c_str());
|
||||
}
|
||||
|
||||
void DirectSubmissionDiagnosticsCollector::storeData() {
|
||||
auto initDelta = diagnosticModeDiagnosticTime - diagnosticModeAllocationTime;
|
||||
int64_t initTimeDiff =
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(initDelta).count();
|
||||
|
||||
IoFunctions::fprintf(logFile, "From allocations ready to exit of OS submit function %lld\n", initTimeDiff);
|
||||
|
||||
if (storeExecutions) {
|
||||
for (uint32_t execution = 0; execution < executionsCount; execution++) {
|
||||
DirectSubmissionSingleDelta delta = executionList.at(execution);
|
||||
std::stringstream value;
|
||||
value << std::dec << " execution: " << execution;
|
||||
value << " total diff: " << delta.totalTimeDiff
|
||||
<< " dispatch-submit: " << delta.dispatchSubmitTimeDiff << " submit-wait: " << delta.submitWaitTimeDiff;
|
||||
IoFunctions::fprintf(logFile, "%s\n", value.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/utilities/io_functions.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
#if defined(_RELEASE_INTERNAL) || (_DEBUG)
|
||||
constexpr bool directSubmissionDiagnosticAvailable = true;
|
||||
#else
|
||||
constexpr bool directSubmissionDiagnosticAvailable = false;
|
||||
#endif
|
||||
|
||||
struct DirectSubmissionSingleDelta {
|
||||
int64_t dispatchSubmitTimeDiff = 0;
|
||||
int64_t submitWaitTimeDiff = 0;
|
||||
int64_t totalTimeDiff = 0;
|
||||
};
|
||||
|
||||
using DirectSubmissionExecution = std::vector<DirectSubmissionSingleDelta>;
|
||||
|
||||
class DirectSubmissionDiagnosticsCollector {
|
||||
public:
|
||||
DirectSubmissionDiagnosticsCollector(uint32_t executions, bool storeExecutions);
|
||||
|
||||
~DirectSubmissionDiagnosticsCollector() {
|
||||
storeData();
|
||||
IoFunctions::fclosePtr(logFile);
|
||||
}
|
||||
void diagnosticModeAllocation() {
|
||||
diagnosticModeAllocationTime = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
void diagnosticModeDiagnostic() {
|
||||
diagnosticModeDiagnosticTime = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
void diagnosticModeOneDispatch() {
|
||||
diagnosticModeOneDispatchTime = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
void diagnosticModeOneSubmit() {
|
||||
diagnosticModeOneSubmitTime = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
void diagnosticModeOneWait(uint32_t execution,
|
||||
volatile void *waitLocation,
|
||||
uint32_t waitValue) {
|
||||
volatile uint32_t *waitAddress = static_cast<volatile uint32_t *>(waitLocation);
|
||||
while (waitValue >= *waitAddress)
|
||||
;
|
||||
diagnosticModeOneWaitTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto timeStamp = executionList.at(execution);
|
||||
auto delta = diagnosticModeOneWaitTime - diagnosticModeOneDispatchTime;
|
||||
timeStamp.totalTimeDiff =
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(delta).count();
|
||||
|
||||
delta = diagnosticModeOneSubmitTime - diagnosticModeOneDispatchTime;
|
||||
timeStamp.dispatchSubmitTimeDiff =
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(delta).count();
|
||||
|
||||
delta = diagnosticModeOneWaitTime - diagnosticModeOneSubmitTime;
|
||||
timeStamp.dispatchSubmitTimeDiff =
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(delta).count();
|
||||
}
|
||||
|
||||
uint32_t getExecutionsCount() const {
|
||||
return executionsCount;
|
||||
}
|
||||
|
||||
void storeData();
|
||||
|
||||
protected:
|
||||
std::chrono::high_resolution_clock::time_point diagnosticModeOneDispatchTime;
|
||||
std::chrono::high_resolution_clock::time_point diagnosticModeOneSubmitTime;
|
||||
std::chrono::high_resolution_clock::time_point diagnosticModeOneWaitTime;
|
||||
std::chrono::high_resolution_clock::time_point diagnosticModeAllocationTime;
|
||||
std::chrono::high_resolution_clock::time_point diagnosticModeDiagnosticTime;
|
||||
DirectSubmissionExecution executionList;
|
||||
|
||||
FILE *logFile = nullptr;
|
||||
|
||||
uint32_t executionsCount = 0;
|
||||
bool storeExecutions = true;
|
||||
};
|
||||
|
||||
namespace DirectSubmissionDiagnostics {
|
||||
inline void diagnosticModeOneDispatch(DirectSubmissionDiagnosticsCollector *collect) {
|
||||
if (directSubmissionDiagnosticAvailable) {
|
||||
if (collect) {
|
||||
collect->diagnosticModeOneDispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
inline void diagnosticModeOneSubmit(DirectSubmissionDiagnosticsCollector *collect) {
|
||||
if (directSubmissionDiagnosticAvailable) {
|
||||
if (collect) {
|
||||
collect->diagnosticModeOneSubmit();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace DirectSubmissionDiagnostics
|
||||
} // namespace NEO
|
||||
@@ -12,34 +12,34 @@
|
||||
namespace NEO {
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitterDispatcher<GfxFamily>::dispatchPreemption(LinearStream &cmdBuffer) {
|
||||
inline void BlitterDispatcher<GfxFamily>::dispatchPreemption(LinearStream &cmdBuffer) {
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
size_t BlitterDispatcher<GfxFamily>::getSizePreemption() {
|
||||
inline size_t BlitterDispatcher<GfxFamily>::getSizePreemption() {
|
||||
size_t size = 0;
|
||||
return size;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitterDispatcher<GfxFamily>::dispatchMonitorFence(LinearStream &cmdBuffer,
|
||||
uint64_t gpuAddress,
|
||||
uint64_t immediateData,
|
||||
const HardwareInfo &hwInfo) {
|
||||
inline void BlitterDispatcher<GfxFamily>::dispatchMonitorFence(LinearStream &cmdBuffer,
|
||||
uint64_t gpuAddress,
|
||||
uint64_t immediateData,
|
||||
const HardwareInfo &hwInfo) {
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
size_t BlitterDispatcher<GfxFamily>::getSizeMonitorFence(const HardwareInfo &hwInfo) {
|
||||
inline size_t BlitterDispatcher<GfxFamily>::getSizeMonitorFence(const HardwareInfo &hwInfo) {
|
||||
size_t size = 0;
|
||||
return size;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitterDispatcher<GfxFamily>::dispatchCacheFlush(LinearStream &cmdBuffer, const HardwareInfo &hwInfo) {
|
||||
inline void BlitterDispatcher<GfxFamily>::dispatchCacheFlush(LinearStream &cmdBuffer, const HardwareInfo &hwInfo) {
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
size_t BlitterDispatcher<GfxFamily>::getSizeCacheFlush(const HardwareInfo &hwInfo) {
|
||||
inline size_t BlitterDispatcher<GfxFamily>::getSizeCacheFlush(const HardwareInfo &hwInfo) {
|
||||
size_t size = 0;
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm_defs.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm_residency_logger.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm_residency_logger_defs.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_memory_manager_allocate_in_device_pool.cpp
|
||||
|
||||
@@ -11,11 +11,4 @@ namespace NEO {
|
||||
Wddm *Wddm::createWddm(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
return new Wddm(std::move(hwDeviceId), rootDeviceEnvironment);
|
||||
}
|
||||
|
||||
namespace ResLog {
|
||||
fopenFuncPtr fopenPtr = &fopen;
|
||||
vfprintfFuncPtr vfprintfPtr = &vfprintf;
|
||||
fcloseFuncPtr fclosePtr = &fclose;
|
||||
} // namespace ResLog
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -8,13 +8,19 @@
|
||||
#pragma once
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/os_interface/windows/wddm/wddm_defs.h"
|
||||
#include "shared/source/os_interface/windows/wddm/wddm_residency_logger_defs.h"
|
||||
#include "shared/source/utilities/io_functions.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
#if defined(_RELEASE_INTERNAL) || (_DEBUG)
|
||||
constexpr bool wddmResidencyLoggingAvailable = true;
|
||||
#else
|
||||
constexpr bool wddmResidencyLoggingAvailable = false;
|
||||
#endif
|
||||
|
||||
class WddmResidencyLogger {
|
||||
public:
|
||||
WddmResidencyLogger(D3DKMT_HANDLE device, VOID *fenceValueCpuVirtualAddress) {
|
||||
@@ -24,17 +30,17 @@ class WddmResidencyLogger {
|
||||
<< "pfencecpu-0x" << fenceValueCpuVirtualAddress;
|
||||
std::stringstream filename;
|
||||
filename << "pagingfence_" << id.str() << ".log";
|
||||
pagingLog = ResLog::fopenPtr(filename.str().c_str(), "at");
|
||||
pagingLog = IoFunctions::fopenPtr(filename.str().c_str(), "at");
|
||||
UNRECOVERABLE_IF(pagingLog == nullptr);
|
||||
fPagingLog("%s\n", id.str().c_str());
|
||||
IoFunctions::fprintf(pagingLog, "%s\n", id.str().c_str());
|
||||
}
|
||||
|
||||
~WddmResidencyLogger() {
|
||||
ResLog::fclosePtr(pagingLog);
|
||||
IoFunctions::fclosePtr(pagingLog);
|
||||
}
|
||||
|
||||
void reportAllocations(uint32_t count, size_t size) {
|
||||
fPagingLog("residency for: handles %u size %zu\n", count, size);
|
||||
IoFunctions::fprintf(pagingLog, "residency for: handles %u size %zu\n", count, size);
|
||||
}
|
||||
|
||||
void makeResidentLog(bool pendingMakeResident, UINT64 makeResidentPagingFence) {
|
||||
@@ -57,19 +63,19 @@ class WddmResidencyLogger {
|
||||
endTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
int64_t timeDiff = 0;
|
||||
fPagingLog("makeResidentPagingFence: %x startWaitPagingFence: %x stopWaitPagingFence: %lld\n",
|
||||
makeResidentPagingFence,
|
||||
startWaitPagingFence,
|
||||
stopWaitPagingFence);
|
||||
IoFunctions::fprintf(pagingLog, "makeResidentPagingFence: %x startWaitPagingFence: %x stopWaitPagingFence: %lld\n",
|
||||
makeResidentPagingFence,
|
||||
startWaitPagingFence,
|
||||
stopWaitPagingFence);
|
||||
|
||||
timeDiff = std::chrono::duration_cast<std::chrono::microseconds>(endTime - pendingTime).count();
|
||||
fPagingLog("makeResidentCall: %x pending return: %x delta time makeResident: %lld\n",
|
||||
makeResidentCall,
|
||||
pendingMakeResident,
|
||||
timeDiff);
|
||||
IoFunctions::fprintf(pagingLog, "makeResidentCall: %x pending return: %x delta time makeResident: %lld\n",
|
||||
makeResidentCall,
|
||||
pendingMakeResident,
|
||||
timeDiff);
|
||||
|
||||
timeDiff = std::chrono::duration_cast<std::chrono::microseconds>(endTime - waitStartTime).count();
|
||||
fPagingLog("waiting: %x delta time wait loop: %lld\n", enterWait, timeDiff);
|
||||
IoFunctions::fprintf(pagingLog, "waiting: %x delta time wait loop: %lld\n", enterWait, timeDiff);
|
||||
|
||||
makeResidentCall = false;
|
||||
enterWait = false;
|
||||
@@ -78,17 +84,10 @@ class WddmResidencyLogger {
|
||||
}
|
||||
|
||||
void trimRequired(UINT64 numBytesToTrim) {
|
||||
fPagingLog("trimming required: bytes to trim: %llu\n", numBytesToTrim);
|
||||
IoFunctions::fprintf(pagingLog, "trimming required: bytes to trim: %llu\n", numBytesToTrim);
|
||||
}
|
||||
|
||||
protected:
|
||||
void fPagingLog(char const *const formatStr, ...) {
|
||||
va_list args;
|
||||
va_start(args, formatStr);
|
||||
ResLog::vfprintfPtr(pagingLog, formatStr, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
std::chrono::high_resolution_clock::time_point pendingTime;
|
||||
std::chrono::high_resolution_clock::time_point waitStartTime;
|
||||
std::chrono::high_resolution_clock::time_point endTime;
|
||||
@@ -104,7 +103,7 @@ class WddmResidencyLogger {
|
||||
};
|
||||
|
||||
inline void perfLogResidencyMakeResident(WddmResidencyLogger *log, bool pendingMakeResident, UINT64 makeResidentPagingFence) {
|
||||
if (residencyLoggingAvailable) {
|
||||
if (wddmResidencyLoggingAvailable) {
|
||||
if (log) {
|
||||
log->makeResidentLog(pendingMakeResident, makeResidentPagingFence);
|
||||
}
|
||||
@@ -112,7 +111,7 @@ inline void perfLogResidencyMakeResident(WddmResidencyLogger *log, bool pendingM
|
||||
}
|
||||
|
||||
inline void perfLogResidencyReportAllocations(WddmResidencyLogger *log, uint32_t count, size_t size) {
|
||||
if (residencyLoggingAvailable) {
|
||||
if (wddmResidencyLoggingAvailable) {
|
||||
if (log) {
|
||||
log->reportAllocations(count, size);
|
||||
}
|
||||
@@ -120,7 +119,7 @@ inline void perfLogResidencyReportAllocations(WddmResidencyLogger *log, uint32_t
|
||||
}
|
||||
|
||||
inline void perfLogStartWaitTime(WddmResidencyLogger *log, UINT64 startWaitPagingFence) {
|
||||
if (residencyLoggingAvailable) {
|
||||
if (wddmResidencyLoggingAvailable) {
|
||||
if (log) {
|
||||
log->startWaitTime(startWaitPagingFence);
|
||||
}
|
||||
@@ -128,7 +127,7 @@ inline void perfLogStartWaitTime(WddmResidencyLogger *log, UINT64 startWaitPagin
|
||||
}
|
||||
|
||||
inline void perfLogResidencyEnteredWait(WddmResidencyLogger *log) {
|
||||
if (residencyLoggingAvailable) {
|
||||
if (wddmResidencyLoggingAvailable) {
|
||||
if (log) {
|
||||
log->enteredWait();
|
||||
}
|
||||
@@ -136,7 +135,7 @@ inline void perfLogResidencyEnteredWait(WddmResidencyLogger *log) {
|
||||
}
|
||||
|
||||
inline void perfLogResidencyWaitPagingeFenceLog(WddmResidencyLogger *log, UINT64 stopWaitPagingFence) {
|
||||
if (residencyLoggingAvailable) {
|
||||
if (wddmResidencyLoggingAvailable) {
|
||||
if (log) {
|
||||
log->waitPagingeFenceLog(stopWaitPagingFence);
|
||||
}
|
||||
@@ -144,7 +143,7 @@ inline void perfLogResidencyWaitPagingeFenceLog(WddmResidencyLogger *log, UINT64
|
||||
}
|
||||
|
||||
inline void perfLogResidencyTrimRequired(WddmResidencyLogger *log, UINT64 numBytesToTrim) {
|
||||
if (residencyLoggingAvailable) {
|
||||
if (wddmResidencyLoggingAvailable) {
|
||||
if (log) {
|
||||
log->trimRequired(numBytesToTrim);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ set(NEO_CORE_UTILITIES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/heap_allocator.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/iflist.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/idlist.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/io_functions.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/numeric.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/perf_profiler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/perf_profiler.h
|
||||
|
||||
16
shared/source/utilities/io_functions.cpp
Normal file
16
shared/source/utilities/io_functions.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/utilities/io_functions.h"
|
||||
|
||||
namespace NEO {
|
||||
namespace IoFunctions {
|
||||
fopenFuncPtr fopenPtr = &fopen;
|
||||
vfprintfFuncPtr vfprintfPtr = &vfprintf;
|
||||
fcloseFuncPtr fclosePtr = &fclose;
|
||||
} // namespace IoFunctions
|
||||
} // namespace NEO
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <cstdio>
|
||||
|
||||
namespace NEO {
|
||||
namespace ResLog {
|
||||
namespace IoFunctions {
|
||||
using fopenFuncPtr = FILE *(*)(const char *, const char *);
|
||||
using vfprintfFuncPtr = int (*)(FILE *, char const *const formatStr, va_list arg);
|
||||
using fcloseFuncPtr = int (*)(FILE *);
|
||||
@@ -18,11 +18,14 @@ using fcloseFuncPtr = int (*)(FILE *);
|
||||
extern fopenFuncPtr fopenPtr;
|
||||
extern vfprintfFuncPtr vfprintfPtr;
|
||||
extern fcloseFuncPtr fclosePtr;
|
||||
} // namespace ResLog
|
||||
|
||||
#if defined(_RELEASE_INTERNAL) || (_DEBUG)
|
||||
constexpr bool residencyLoggingAvailable = true;
|
||||
#else
|
||||
constexpr bool residencyLoggingAvailable = false;
|
||||
#endif
|
||||
inline int fprintf(FILE *fileDesc, char const *const formatStr, ...) {
|
||||
va_list args;
|
||||
va_start(args, formatStr);
|
||||
int ret = IoFunctions::vfprintfPtr(fileDesc, formatStr, args);
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
} // namespace IoFunctions
|
||||
|
||||
} // namespace NEO
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "opencl/test/unit_test/fixtures/device_fixture.h"
|
||||
#include "opencl/test/unit_test/helpers/dispatch_flags_helper.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_csr.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_io_functions.h"
|
||||
#include "test.h"
|
||||
|
||||
#include <atomic>
|
||||
@@ -273,23 +274,20 @@ HWTEST_F(DirectSubmissionTest,
|
||||
givenDirectSubmissionDisableMonitorFenceWhenStopRingIsCalledThenExpectStopCommandAndMonitorFenceDispatched) {
|
||||
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
||||
using MI_BATCH_BUFFER_END = typename FamilyType::MI_BATCH_BUFFER_END;
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> regularDirectSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> regularDirectSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
size_t regularSizeEnd = regularDirectSubmission.getSizeEnd();
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionDisableMonitorFence.set(true);
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
bool ret = directSubmission.initialize(true);
|
||||
bool ret = directSubmission.allocateResources();
|
||||
directSubmission.disableMonitorFence = true;
|
||||
EXPECT_TRUE(ret);
|
||||
size_t alreadyDispatchedSize = directSubmission.ringCommandStream.getUsed();
|
||||
uint32_t oldQueueCount = directSubmission.semaphoreData->QueueWorkCount;
|
||||
|
||||
size_t tagUpdateSize = directSubmission.getSizeTagUpdateSection();
|
||||
size_t tagUpdateSize = Dispatcher::getSizeMonitorFence(*directSubmission.hwInfo);
|
||||
|
||||
size_t disabledSizeEnd = directSubmission.getSizeEnd();
|
||||
EXPECT_EQ(disabledSizeEnd, regularSizeEnd + tagUpdateSize);
|
||||
@@ -297,13 +295,12 @@ HWTEST_F(DirectSubmissionTest,
|
||||
directSubmission.tagValueSetValue = 0x4343123ull;
|
||||
directSubmission.tagAddressSetValue = 0xBEEF00000ull;
|
||||
directSubmission.stopRingBuffer();
|
||||
size_t expectedDispatchSize = alreadyDispatchedSize + disabledSizeEnd;
|
||||
size_t expectedDispatchSize = disabledSizeEnd;
|
||||
EXPECT_EQ(expectedDispatchSize, directSubmission.ringCommandStream.getUsed());
|
||||
EXPECT_EQ(oldQueueCount + 1, directSubmission.semaphoreData->QueueWorkCount);
|
||||
|
||||
HardwareParse hwParse;
|
||||
hwParse.parsePipeControl = true;
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, alreadyDispatchedSize);
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
|
||||
hwParse.findHardwareCommands<FamilyType>();
|
||||
MI_BATCH_BUFFER_END *bbEnd = hwParse.getCommand<MI_BATCH_BUFFER_END>();
|
||||
EXPECT_NE(nullptr, bbEnd);
|
||||
@@ -328,22 +325,19 @@ HWTEST_F(DirectSubmissionDispatchBufferTest,
|
||||
givenDirectSubmissionDisableMonitorFenceWhenDispatchWorkloadCalledThenExpectStartWithoutMonitorFence) {
|
||||
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
||||
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> regularDirectSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> regularDirectSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
size_t regularSizeDispatch = regularDirectSubmission.getSizeDispatch();
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionDisableMonitorFence.set(true);
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
bool ret = directSubmission.initialize(true);
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
directSubmission.disableMonitorFence = true;
|
||||
bool ret = directSubmission.allocateResources();
|
||||
EXPECT_TRUE(ret);
|
||||
size_t alreadyDispatchedSize = directSubmission.ringCommandStream.getUsed();
|
||||
|
||||
size_t tagUpdateSize = directSubmission.getSizeTagUpdateSection();
|
||||
size_t tagUpdateSize = Dispatcher::getSizeMonitorFence(*directSubmission.hwInfo);
|
||||
|
||||
size_t disabledSizeDispatch = directSubmission.getSizeDispatch();
|
||||
EXPECT_EQ(disabledSizeDispatch, (regularSizeDispatch - tagUpdateSize));
|
||||
@@ -351,12 +345,12 @@ HWTEST_F(DirectSubmissionDispatchBufferTest,
|
||||
directSubmission.tagValueSetValue = 0x4343123ull;
|
||||
directSubmission.tagAddressSetValue = 0xBEEF00000ull;
|
||||
directSubmission.dispatchWorkloadSection(batchBuffer);
|
||||
size_t expectedDispatchSize = alreadyDispatchedSize + disabledSizeDispatch;
|
||||
size_t expectedDispatchSize = disabledSizeDispatch;
|
||||
EXPECT_EQ(expectedDispatchSize, directSubmission.ringCommandStream.getUsed());
|
||||
|
||||
HardwareParse hwParse;
|
||||
hwParse.parsePipeControl = true;
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, alreadyDispatchedSize);
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
|
||||
hwParse.findHardwareCommands<FamilyType>();
|
||||
MI_BATCH_BUFFER_START *bbStart = hwParse.getCommand<MI_BATCH_BUFFER_START>();
|
||||
ASSERT_NE(nullptr, bbStart);
|
||||
@@ -381,33 +375,31 @@ HWTEST_F(DirectSubmissionDispatchBufferTest,
|
||||
givenDirectSubmissionDisableCacheFlushWhenDispatchWorkloadCalledThenExpectStartWithoutCacheFlush) {
|
||||
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
||||
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> regularDirectSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> regularDirectSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
size_t regularSizeDispatch = regularDirectSubmission.getSizeDispatch();
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionDisableCacheFlush.set(true);
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
bool ret = directSubmission.initialize(true);
|
||||
directSubmission.disableCacheFlush = true;
|
||||
bool ret = directSubmission.allocateResources();
|
||||
EXPECT_TRUE(ret);
|
||||
size_t alreadyDispatchedSize = directSubmission.ringCommandStream.getUsed();
|
||||
|
||||
size_t flushSize = directSubmission.getSizeFlushSection();
|
||||
size_t flushSize = Dispatcher::getSizeCacheFlush(*directSubmission.hwInfo);
|
||||
|
||||
size_t disabledSizeDispatch = directSubmission.getSizeDispatch();
|
||||
EXPECT_EQ(disabledSizeDispatch, (regularSizeDispatch - flushSize));
|
||||
|
||||
directSubmission.dispatchWorkloadSection(batchBuffer);
|
||||
size_t expectedDispatchSize = alreadyDispatchedSize + disabledSizeDispatch;
|
||||
size_t expectedDispatchSize = disabledSizeDispatch;
|
||||
EXPECT_EQ(expectedDispatchSize, directSubmission.ringCommandStream.getUsed());
|
||||
|
||||
HardwareParse hwParse;
|
||||
hwParse.parsePipeControl = true;
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, alreadyDispatchedSize);
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
|
||||
hwParse.findHardwareCommands<FamilyType>();
|
||||
MI_BATCH_BUFFER_START *bbStart = hwParse.getCommand<MI_BATCH_BUFFER_START>();
|
||||
ASSERT_NE(nullptr, bbStart);
|
||||
@@ -432,46 +424,44 @@ HWTEST_F(DirectSubmissionDispatchBufferTest,
|
||||
givenDirectSubmissionDebugBufferModeOneWhenDispatchWorkloadCalledThenExpectNoStartAndLoadDataImm) {
|
||||
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM;
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> regularDirectSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> regularDirectSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
size_t regularSizeDispatch = regularDirectSubmission.getSizeDispatch();
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionEnableDebugBuffer.set(1);
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
bool ret = directSubmission.initialize(true);
|
||||
directSubmission.workloadMode = 1;
|
||||
bool ret = directSubmission.allocateResources();
|
||||
EXPECT_TRUE(ret);
|
||||
size_t alreadyDispatchedSize = directSubmission.ringCommandStream.getUsed();
|
||||
|
||||
size_t startSize = directSubmission.getSizeStartSection();
|
||||
size_t loadDataSize = directSubmission.getSizeStoraDataSection();
|
||||
size_t storeDataSize = Dispatcher::getSizeStoreDwordCommand();
|
||||
|
||||
size_t debugSizeDispatch = directSubmission.getSizeDispatch();
|
||||
EXPECT_EQ(debugSizeDispatch, (regularSizeDispatch - startSize + loadDataSize));
|
||||
EXPECT_EQ(debugSizeDispatch, (regularSizeDispatch - startSize + storeDataSize));
|
||||
|
||||
directSubmission.currentQueueWorkCount = 0x40u;
|
||||
directSubmission.workloadModeOneExpectedValue = 0x40u;
|
||||
directSubmission.semaphoreGpuVa = 0xAFF0000;
|
||||
directSubmission.dispatchWorkloadSection(batchBuffer);
|
||||
size_t expectedDispatchSize = alreadyDispatchedSize + debugSizeDispatch;
|
||||
size_t expectedDispatchSize = debugSizeDispatch;
|
||||
EXPECT_EQ(expectedDispatchSize, directSubmission.ringCommandStream.getUsed());
|
||||
|
||||
HardwareParse hwParse;
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, alreadyDispatchedSize);
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
|
||||
MI_BATCH_BUFFER_START *bbStart = hwParse.getCommand<MI_BATCH_BUFFER_START>();
|
||||
EXPECT_EQ(nullptr, bbStart);
|
||||
|
||||
MI_STORE_DATA_IMM *loadData = hwParse.getCommand<MI_STORE_DATA_IMM>();
|
||||
ASSERT_NE(nullptr, loadData);
|
||||
EXPECT_EQ(0x40u, loadData->getDataDword0());
|
||||
MI_STORE_DATA_IMM *storeData = hwParse.getCommand<MI_STORE_DATA_IMM>();
|
||||
ASSERT_NE(nullptr, storeData);
|
||||
EXPECT_EQ(0x40u + 1u, storeData->getDataDword0());
|
||||
uint64_t expectedGpuVa = directSubmission.semaphoreGpuVa;
|
||||
auto semaphore = static_cast<RingSemaphoreData *>(directSubmission.semaphorePtr);
|
||||
expectedGpuVa += ptrDiff(&semaphore->Reserved1Uint32, directSubmission.semaphorePtr);
|
||||
EXPECT_EQ(expectedGpuVa, loadData->getAddress());
|
||||
EXPECT_EQ(expectedGpuVa, storeData->getAddress());
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionDispatchBufferTest,
|
||||
@@ -483,15 +473,12 @@ HWTEST_F(DirectSubmissionDispatchBufferTest,
|
||||
*osContext.get());
|
||||
size_t regularSizeDispatch = regularDirectSubmission.getSizeDispatch();
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionEnableDebugBuffer.set(2);
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
bool ret = directSubmission.initialize(true);
|
||||
directSubmission.workloadMode = 2;
|
||||
bool ret = directSubmission.allocateResources();
|
||||
EXPECT_TRUE(ret);
|
||||
size_t alreadyDispatchedSize = directSubmission.ringCommandStream.getUsed();
|
||||
|
||||
size_t startSize = directSubmission.getSizeStartSection();
|
||||
|
||||
@@ -500,16 +487,16 @@ HWTEST_F(DirectSubmissionDispatchBufferTest,
|
||||
|
||||
directSubmission.currentQueueWorkCount = 0x40u;
|
||||
directSubmission.dispatchWorkloadSection(batchBuffer);
|
||||
size_t expectedDispatchSize = alreadyDispatchedSize + debugSizeDispatch;
|
||||
size_t expectedDispatchSize = debugSizeDispatch;
|
||||
EXPECT_EQ(expectedDispatchSize, directSubmission.ringCommandStream.getUsed());
|
||||
|
||||
HardwareParse hwParse;
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, alreadyDispatchedSize);
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
|
||||
MI_BATCH_BUFFER_START *bbStart = hwParse.getCommand<MI_BATCH_BUFFER_START>();
|
||||
EXPECT_EQ(nullptr, bbStart);
|
||||
|
||||
MI_STORE_DATA_IMM *loadData = hwParse.getCommand<MI_STORE_DATA_IMM>();
|
||||
EXPECT_EQ(nullptr, loadData);
|
||||
MI_STORE_DATA_IMM *storeData = hwParse.getCommand<MI_STORE_DATA_IMM>();
|
||||
EXPECT_EQ(nullptr, storeData);
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest, givenDirectSubmissionWhenDispatchSemaphoreThenExpectCorrectSizeUsed) {
|
||||
@@ -545,47 +532,50 @@ HWTEST_F(DirectSubmissionTest, givenDirectSubmissionWhenDispatchSwitchRingBuffer
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest, givenDirectSubmissionWhenDispatchFlushSectionThenExpectCorrectSizeUsed) {
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
bool ret = directSubmission.initialize(false);
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
directSubmission.dispatchFlushSection();
|
||||
EXPECT_EQ(directSubmission.getSizeFlushSection(), directSubmission.ringCommandStream.getUsed());
|
||||
Dispatcher::dispatchCacheFlush(directSubmission.ringCommandStream, *directSubmission.hwInfo);
|
||||
EXPECT_EQ(Dispatcher::getSizeCacheFlush(*directSubmission.hwInfo), directSubmission.ringCommandStream.getUsed());
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest, givenDirectSubmissionWhenDispatchTagUpdateSectionThenExpectCorrectSizeUsed) {
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>>
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher>
|
||||
directSubmission(*pDevice, *osContext.get());
|
||||
|
||||
bool ret = directSubmission.initialize(false);
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
directSubmission.dispatchTagUpdateSection(0ull, 0ull);
|
||||
Dispatcher::dispatchMonitorFence(directSubmission.ringCommandStream, 0ull, 0ull, *directSubmission.hwInfo);
|
||||
EXPECT_NE(0x0u, directSubmission.ringCommandStream.getUsed());
|
||||
EXPECT_EQ(directSubmission.getSizeTagUpdateSection(), directSubmission.ringCommandStream.getUsed());
|
||||
EXPECT_EQ(Dispatcher::getSizeMonitorFence(*directSubmission.hwInfo), directSubmission.ringCommandStream.getUsed());
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest, givenDirectSubmissionWhenDispatchEndingSectionThenExpectCorrectSizeUsed) {
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
bool ret = directSubmission.initialize(false);
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
directSubmission.dispatchEndingSection();
|
||||
Dispatcher::dispatchStopCommandBuffer(directSubmission.ringCommandStream);
|
||||
EXPECT_NE(0x0u, directSubmission.ringCommandStream.getUsed());
|
||||
EXPECT_EQ(directSubmission.getSizeEndingSection(), directSubmission.ringCommandStream.getUsed());
|
||||
EXPECT_EQ(Dispatcher::getSizeStopCommandBuffer(), directSubmission.ringCommandStream.getUsed());
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest, givenDirectSubmissionWhenGetDispatchSizeThenExpectCorrectSizeReturned) {
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
size_t expectedSize = directSubmission.getSizeStartSection() +
|
||||
directSubmission.getSizeFlushSection() +
|
||||
directSubmission.getSizeTagUpdateSection() +
|
||||
Dispatcher::getSizeCacheFlush(*directSubmission.hwInfo) +
|
||||
Dispatcher::getSizeMonitorFence(*directSubmission.hwInfo) +
|
||||
directSubmission.getSizeSemaphoreSection();
|
||||
size_t actualSize = directSubmission.getSizeDispatch();
|
||||
EXPECT_EQ(expectedSize, actualSize);
|
||||
@@ -593,14 +583,15 @@ HWTEST_F(DirectSubmissionTest, givenDirectSubmissionWhenGetDispatchSizeThenExpec
|
||||
|
||||
HWTEST_F(DirectSubmissionTest,
|
||||
givenDirectSubmissionEnableDebugBufferModeOneWhenGetDispatchSizeThenExpectCorrectSizeReturned) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionEnableDebugBuffer.set(1);
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
size_t expectedSize = directSubmission.getSizeStoraDataSection() +
|
||||
directSubmission.getSizeFlushSection() +
|
||||
directSubmission.getSizeTagUpdateSection() +
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
directSubmission.workloadMode = 1;
|
||||
|
||||
size_t expectedSize = Dispatcher::getSizeStoreDwordCommand() +
|
||||
Dispatcher::getSizeCacheFlush(*directSubmission.hwInfo) +
|
||||
Dispatcher::getSizeMonitorFence(*directSubmission.hwInfo) +
|
||||
directSubmission.getSizeSemaphoreSection();
|
||||
size_t actualSize = directSubmission.getSizeDispatch();
|
||||
EXPECT_EQ(expectedSize, actualSize);
|
||||
@@ -608,13 +599,13 @@ HWTEST_F(DirectSubmissionTest,
|
||||
|
||||
HWTEST_F(DirectSubmissionTest,
|
||||
givenDirectSubmissionEnableDebugBufferModeTwoWhenGetDispatchSizeThenExpectCorrectSizeReturned) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionEnableDebugBuffer.set(2);
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
size_t expectedSize = directSubmission.getSizeFlushSection() +
|
||||
directSubmission.getSizeTagUpdateSection() +
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
directSubmission.workloadMode = 2;
|
||||
size_t expectedSize = Dispatcher::getSizeCacheFlush(*directSubmission.hwInfo) +
|
||||
Dispatcher::getSizeMonitorFence(*directSubmission.hwInfo) +
|
||||
directSubmission.getSizeSemaphoreSection();
|
||||
size_t actualSize = directSubmission.getSizeDispatch();
|
||||
EXPECT_EQ(expectedSize, actualSize);
|
||||
@@ -622,13 +613,13 @@ HWTEST_F(DirectSubmissionTest,
|
||||
|
||||
HWTEST_F(DirectSubmissionTest,
|
||||
givenDirectSubmissionDisableCacheFlushWhenGetDispatchSizeThenExpectCorrectSizeReturned) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionDisableCacheFlush.set(true);
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
directSubmission.disableCacheFlush = true;
|
||||
size_t expectedSize = directSubmission.getSizeStartSection() +
|
||||
directSubmission.getSizeTagUpdateSection() +
|
||||
Dispatcher::getSizeMonitorFence(*directSubmission.hwInfo) +
|
||||
directSubmission.getSizeSemaphoreSection();
|
||||
size_t actualSize = directSubmission.getSizeDispatch();
|
||||
EXPECT_EQ(expectedSize, actualSize);
|
||||
@@ -636,25 +627,26 @@ HWTEST_F(DirectSubmissionTest,
|
||||
|
||||
HWTEST_F(DirectSubmissionTest,
|
||||
givenDirectSubmissionDisableMonitorFenceWhenGetDispatchSizeThenExpectCorrectSizeReturned) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionDisableMonitorFence.set(true);
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
directSubmission.disableMonitorFence = true;
|
||||
size_t expectedSize = directSubmission.getSizeStartSection() +
|
||||
directSubmission.getSizeFlushSection() +
|
||||
Dispatcher::getSizeCacheFlush(*directSubmission.hwInfo) +
|
||||
directSubmission.getSizeSemaphoreSection();
|
||||
size_t actualSize = directSubmission.getSizeDispatch();
|
||||
EXPECT_EQ(expectedSize, actualSize);
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest, givenDirectSubmissionWhenGetEndSizeThenExpectCorrectSizeReturned) {
|
||||
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
size_t expectedSize = directSubmission.getSizeEndingSection() +
|
||||
directSubmission.getSizeFlushSection();
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
size_t expectedSize = Dispatcher::getSizeStopCommandBuffer() +
|
||||
Dispatcher::getSizeCacheFlush(*directSubmission.hwInfo);
|
||||
size_t actualSize = directSubmission.getSizeEnd();
|
||||
EXPECT_EQ(expectedSize, actualSize);
|
||||
}
|
||||
@@ -913,3 +905,232 @@ HWTEST_F(DirectSubmissionTest, whenInitDirectSubmissionFailThenEngineIsNotCreate
|
||||
auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hardwareInfo);
|
||||
EXPECT_EQ(nullptr, device);
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest,
|
||||
givenDirectSubmissionDiagnosticNotAvailableWhenDiagnosticRegistryIsUsedThenDoNotEnableDiagnostic) {
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
if (NEO::directSubmissionDiagnosticAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionEnableDebugBuffer.set(1);
|
||||
DebugManager.flags.DirectSubmissionDisableCacheFlush.set(true);
|
||||
DebugManager.flags.DirectSubmissionDisableMonitorFence.set(true);
|
||||
|
||||
NEO::IoFunctions::mockFopenCalled = 0u;
|
||||
NEO::IoFunctions::mockVfptrinfCalled = 0u;
|
||||
NEO::IoFunctions::mockFcloseCalled = 0u;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
EXPECT_FALSE(directSubmission.defaultDisableCacheFlush);
|
||||
EXPECT_FALSE(directSubmission.defaultDisableMonitorFence);
|
||||
EXPECT_FALSE(directSubmission.disableCacheFlush);
|
||||
EXPECT_FALSE(directSubmission.disableMonitorFence);
|
||||
EXPECT_EQ(0u, directSubmission.workloadMode);
|
||||
EXPECT_EQ(nullptr, directSubmission.diagnostic.get());
|
||||
bool ret = directSubmission.initialize(false);
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_FALSE(directSubmission.ringStart);
|
||||
EXPECT_EQ(0u, directSubmission.disabledDiagnosticCalled);
|
||||
EXPECT_EQ(0u, directSubmission.ringCommandStream.getUsed());
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockFopenCalled);
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockFcloseCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest,
|
||||
givenDirectSubmissionDiagnosticNotAvailableWhenDiagnosticRegistryIsUsedThenDoNotEnableDiagnosticStartOnlyWithSemaphore) {
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
if (NEO::directSubmissionDiagnosticAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionEnableDebugBuffer.set(1);
|
||||
DebugManager.flags.DirectSubmissionDisableCacheFlush.set(true);
|
||||
DebugManager.flags.DirectSubmissionDisableMonitorFence.set(true);
|
||||
|
||||
NEO::IoFunctions::mockFopenCalled = 0u;
|
||||
NEO::IoFunctions::mockVfptrinfCalled = 0u;
|
||||
NEO::IoFunctions::mockFcloseCalled = 0u;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
EXPECT_FALSE(directSubmission.defaultDisableCacheFlush);
|
||||
EXPECT_FALSE(directSubmission.defaultDisableMonitorFence);
|
||||
EXPECT_FALSE(directSubmission.disableCacheFlush);
|
||||
EXPECT_FALSE(directSubmission.disableMonitorFence);
|
||||
EXPECT_EQ(0u, directSubmission.workloadMode);
|
||||
EXPECT_EQ(nullptr, directSubmission.diagnostic.get());
|
||||
bool ret = directSubmission.initialize(true);
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_TRUE(directSubmission.ringStart);
|
||||
EXPECT_EQ(1u, directSubmission.disabledDiagnosticCalled);
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockFopenCalled);
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockFcloseCalled);
|
||||
size_t expectedSize = Dispatcher::getSizePreemption() +
|
||||
directSubmission.getSizeSemaphoreSection();
|
||||
EXPECT_EQ(expectedSize, directSubmission.ringCommandStream.getUsed());
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest,
|
||||
givenDirectSubmissionDiagnosticAvailableWhenDiagnosticRegistryIsNotUsedThenDoNotEnableDiagnostic) {
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
if (!NEO::directSubmissionDiagnosticAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionDisableCacheFlush.set(true);
|
||||
DebugManager.flags.DirectSubmissionDisableMonitorFence.set(true);
|
||||
|
||||
NEO::IoFunctions::mockFopenCalled = 0u;
|
||||
NEO::IoFunctions::mockVfptrinfCalled = 0u;
|
||||
NEO::IoFunctions::mockFcloseCalled = 0u;
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
EXPECT_FALSE(directSubmission.defaultDisableCacheFlush);
|
||||
EXPECT_FALSE(directSubmission.defaultDisableMonitorFence);
|
||||
EXPECT_FALSE(directSubmission.disableCacheFlush);
|
||||
EXPECT_FALSE(directSubmission.disableMonitorFence);
|
||||
EXPECT_EQ(0u, directSubmission.workloadMode);
|
||||
EXPECT_EQ(nullptr, directSubmission.diagnostic.get());
|
||||
bool ret = directSubmission.initialize(false);
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_FALSE(directSubmission.ringStart);
|
||||
EXPECT_EQ(0u, directSubmission.disabledDiagnosticCalled);
|
||||
EXPECT_EQ(0u, directSubmission.ringCommandStream.getUsed());
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockFopenCalled);
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockFcloseCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest,
|
||||
givenDirectSubmissionDiagnosticAvailableWhenDiagnosticRegistryUsedThenDoPerformDiagnosticRun) {
|
||||
using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM;
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
if (!NEO::directSubmissionDiagnosticAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionEnableDebugBuffer.set(1);
|
||||
DebugManager.flags.DirectSubmissionDisableCacheFlush.set(true);
|
||||
DebugManager.flags.DirectSubmissionDisableMonitorFence.set(true);
|
||||
DebugManager.flags.DirectSubmissionDiagnosticExecutionCount.set(5);
|
||||
|
||||
NEO::IoFunctions::mockFopenCalled = 0u;
|
||||
NEO::IoFunctions::mockVfptrinfCalled = 0u;
|
||||
NEO::IoFunctions::mockFcloseCalled = 0u;
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
uint32_t expectedSemaphoreValue = directSubmission.currentQueueWorkCount;
|
||||
EXPECT_FALSE(directSubmission.defaultDisableCacheFlush);
|
||||
EXPECT_FALSE(directSubmission.defaultDisableMonitorFence);
|
||||
EXPECT_TRUE(directSubmission.disableCacheFlush);
|
||||
EXPECT_TRUE(directSubmission.disableMonitorFence);
|
||||
EXPECT_EQ(1u, directSubmission.workloadMode);
|
||||
ASSERT_NE(nullptr, directSubmission.diagnostic.get());
|
||||
uint32_t expectedExecCount = 5u;
|
||||
expectedSemaphoreValue += expectedExecCount;
|
||||
EXPECT_EQ(expectedExecCount, directSubmission.diagnostic->getExecutionsCount());
|
||||
size_t expectedSize = Dispatcher::getSizePreemption() +
|
||||
directSubmission.getSizeSemaphoreSection();
|
||||
expectedSize += expectedExecCount * directSubmission.getSizeDispatch();
|
||||
|
||||
bool ret = directSubmission.initialize(false);
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_TRUE(directSubmission.ringStart);
|
||||
EXPECT_EQ(0u, directSubmission.disabledDiagnosticCalled);
|
||||
EXPECT_EQ(1u, NEO::IoFunctions::mockFopenCalled);
|
||||
//1 - preamble, 1 - init time, 5 - exec logs
|
||||
EXPECT_EQ(7u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_EQ(1u, NEO::IoFunctions::mockFcloseCalled);
|
||||
EXPECT_EQ(expectedSize, directSubmission.ringCommandStream.getUsed());
|
||||
EXPECT_EQ(expectedSemaphoreValue, directSubmission.currentQueueWorkCount);
|
||||
|
||||
EXPECT_FALSE(directSubmission.disableCacheFlush);
|
||||
EXPECT_FALSE(directSubmission.disableMonitorFence);
|
||||
EXPECT_EQ(0u, directSubmission.workloadMode);
|
||||
EXPECT_EQ(nullptr, directSubmission.diagnostic.get());
|
||||
|
||||
HardwareParse hwParse;
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
|
||||
|
||||
GenCmdList storeDataCmdList = hwParse.getCommandsList<MI_STORE_DATA_IMM>();
|
||||
ASSERT_EQ(5u, storeDataCmdList.size());
|
||||
uint32_t expectedData = 1u;
|
||||
for (auto &storeCmdData : storeDataCmdList) {
|
||||
MI_STORE_DATA_IMM *storeCmd = static_cast<MI_STORE_DATA_IMM *>(storeCmdData);
|
||||
|
||||
auto storeData = storeCmd->getDataDword0();
|
||||
EXPECT_EQ(expectedData, storeData);
|
||||
expectedData++;
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(DirectSubmissionTest,
|
||||
givenDirectSubmissionDiagnosticAvailableWhenDiagnosticRegistryModeTwoUsedThenDoPerformDiagnosticRunWithoutRoundtripMeasures) {
|
||||
using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM;
|
||||
using Dispatcher = RenderDispatcher<FamilyType>;
|
||||
|
||||
if (!NEO::directSubmissionDiagnosticAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DirectSubmissionEnableDebugBuffer.set(2);
|
||||
DebugManager.flags.DirectSubmissionDisableCacheFlush.set(true);
|
||||
DebugManager.flags.DirectSubmissionDisableMonitorFence.set(true);
|
||||
DebugManager.flags.DirectSubmissionDiagnosticExecutionCount.set(5);
|
||||
|
||||
NEO::IoFunctions::mockFopenCalled = 0u;
|
||||
NEO::IoFunctions::mockVfptrinfCalled = 0u;
|
||||
NEO::IoFunctions::mockFcloseCalled = 0u;
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
uint32_t expectedSemaphoreValue = directSubmission.currentQueueWorkCount;
|
||||
EXPECT_FALSE(directSubmission.defaultDisableCacheFlush);
|
||||
EXPECT_FALSE(directSubmission.defaultDisableMonitorFence);
|
||||
EXPECT_TRUE(directSubmission.disableCacheFlush);
|
||||
EXPECT_TRUE(directSubmission.disableMonitorFence);
|
||||
EXPECT_EQ(2u, directSubmission.workloadMode);
|
||||
ASSERT_NE(nullptr, directSubmission.diagnostic.get());
|
||||
uint32_t expectedExecCount = 5u;
|
||||
expectedSemaphoreValue += expectedExecCount;
|
||||
EXPECT_EQ(expectedExecCount, directSubmission.diagnostic->getExecutionsCount());
|
||||
size_t expectedSize = Dispatcher::getSizePreemption() +
|
||||
directSubmission.getSizeSemaphoreSection();
|
||||
size_t expectedDispatch = directSubmission.getSizeSemaphoreSection();
|
||||
EXPECT_EQ(expectedDispatch, directSubmission.getSizeDispatch());
|
||||
expectedSize += expectedExecCount * expectedDispatch;
|
||||
|
||||
bool ret = directSubmission.initialize(false);
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_TRUE(directSubmission.ringStart);
|
||||
EXPECT_EQ(0u, directSubmission.disabledDiagnosticCalled);
|
||||
EXPECT_EQ(1u, NEO::IoFunctions::mockFopenCalled);
|
||||
//1 - preamble, 1 - init time, 0 exec logs in mode 2
|
||||
EXPECT_EQ(2u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_EQ(1u, NEO::IoFunctions::mockFcloseCalled);
|
||||
EXPECT_EQ(expectedSize, directSubmission.ringCommandStream.getUsed());
|
||||
EXPECT_EQ(expectedSemaphoreValue, directSubmission.currentQueueWorkCount);
|
||||
|
||||
EXPECT_FALSE(directSubmission.disableCacheFlush);
|
||||
EXPECT_FALSE(directSubmission.disableMonitorFence);
|
||||
EXPECT_EQ(0u, directSubmission.workloadMode);
|
||||
EXPECT_EQ(nullptr, directSubmission.diagnostic.get());
|
||||
|
||||
HardwareParse hwParse;
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
|
||||
|
||||
GenCmdList storeDataCmdList = hwParse.getCommandsList<MI_STORE_DATA_IMM>();
|
||||
EXPECT_EQ(0u, storeDataCmdList.size());
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/direct_submission/direct_submission_hw.h"
|
||||
#include "shared/source/direct_submission/direct_submission_hw_diagnostic_mode.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
|
||||
namespace NEO {
|
||||
@@ -20,28 +21,27 @@ struct MockDirectSubmissionHw : public DirectSubmissionHw<GfxFamily, Dispatcher>
|
||||
using BaseClass::currentQueueWorkCount;
|
||||
using BaseClass::currentRingBuffer;
|
||||
using BaseClass::deallocateResources;
|
||||
using BaseClass::defaultDisableCacheFlush;
|
||||
using BaseClass::defaultDisableMonitorFence;
|
||||
using BaseClass::device;
|
||||
using BaseClass::diagnostic;
|
||||
using BaseClass::DirectSubmissionHw;
|
||||
using BaseClass::disableCacheFlush;
|
||||
using BaseClass::disableCpuCacheFlush;
|
||||
using BaseClass::dispatchEndingSection;
|
||||
using BaseClass::dispatchFlushSection;
|
||||
using BaseClass::disableMonitorFence;
|
||||
using BaseClass::dispatchSemaphoreSection;
|
||||
using BaseClass::dispatchStartSection;
|
||||
using BaseClass::dispatchSwitchRingBufferSection;
|
||||
using BaseClass::dispatchTagUpdateSection;
|
||||
using BaseClass::dispatchWorkloadSection;
|
||||
using BaseClass::getCommandBufferPositionGpuAddress;
|
||||
using BaseClass::getSizeDispatch;
|
||||
using BaseClass::getSizeEnd;
|
||||
using BaseClass::getSizeEndingSection;
|
||||
using BaseClass::getSizeFlushSection;
|
||||
using BaseClass::getSizeSemaphoreSection;
|
||||
using BaseClass::getSizeStartSection;
|
||||
using BaseClass::getSizeStoraDataSection;
|
||||
using BaseClass::getSizeSwitchRingBufferSection;
|
||||
using BaseClass::getSizeTagUpdateSection;
|
||||
using BaseClass::hwInfo;
|
||||
using BaseClass::osContext;
|
||||
using BaseClass::performDiagnosticMode;
|
||||
using BaseClass::ringBuffer;
|
||||
using BaseClass::ringBuffer2;
|
||||
using BaseClass::ringCommandStream;
|
||||
@@ -53,6 +53,9 @@ struct MockDirectSubmissionHw : public DirectSubmissionHw<GfxFamily, Dispatcher>
|
||||
using BaseClass::setReturnAddress;
|
||||
using BaseClass::stopRingBuffer;
|
||||
using BaseClass::switchRingBuffersAllocations;
|
||||
using BaseClass::workloadMode;
|
||||
using BaseClass::workloadModeOneExpectedValue;
|
||||
using BaseClass::workloadModeOneStoreAddress;
|
||||
using typename BaseClass::RingBufferUse;
|
||||
|
||||
~MockDirectSubmissionHw() override {
|
||||
@@ -97,15 +100,28 @@ struct MockDirectSubmissionHw : public DirectSubmissionHw<GfxFamily, Dispatcher>
|
||||
tagData.tagValue = tagValueSetValue;
|
||||
}
|
||||
|
||||
bool allocateOsResourcesReturn = true;
|
||||
bool submitReturn = true;
|
||||
bool handleResidencyReturn = true;
|
||||
uint32_t submitCount = 0u;
|
||||
uint32_t handleResidencyCount = 0u;
|
||||
size_t submitSize = 0u;
|
||||
void performDiagnosticMode() override {
|
||||
if (!NEO::directSubmissionDiagnosticAvailable) {
|
||||
disabledDiagnosticCalled++;
|
||||
}
|
||||
uint32_t add = 1;
|
||||
if (diagnostic.get()) {
|
||||
add += diagnostic->getExecutionsCount();
|
||||
}
|
||||
*static_cast<volatile uint32_t *>(workloadModeOneStoreAddress) = workloadModeOneExpectedValue + add;
|
||||
BaseClass::performDiagnosticMode();
|
||||
}
|
||||
|
||||
uint64_t updateTagValueReturn = 1ull;
|
||||
uint64_t tagAddressSetValue = MemoryConstants::pageSize;
|
||||
uint64_t tagValueSetValue = 1ull;
|
||||
uint64_t submitGpuAddress = 0ull;
|
||||
size_t submitSize = 0u;
|
||||
uint32_t submitCount = 0u;
|
||||
uint32_t handleResidencyCount = 0u;
|
||||
uint32_t disabledDiagnosticCalled = 0u;
|
||||
bool allocateOsResourcesReturn = true;
|
||||
bool submitReturn = true;
|
||||
bool handleResidencyReturn = true;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -15,6 +15,7 @@ set(NEO_CORE_UTILITIES_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/destructor_counted.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/directory_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/heap_allocator_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/io_functions_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/numeric_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/perf_profiler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/reference_tracked_object_tests.cpp
|
||||
|
||||
29
shared/test/unit_test/utilities/io_functions_tests.cpp
Normal file
29
shared/test/unit_test/utilities/io_functions_tests.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_io_functions.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(IoFunctionTest, WhenMockFunctionsSelectedThenCorrectFunctionPointerUsed) {
|
||||
IoFunctions::mockFopenCalled = 0;
|
||||
IoFunctions::mockVfptrinfCalled = 0;
|
||||
IoFunctions::mockFcloseCalled = 0;
|
||||
|
||||
FILE *file = IoFunctions::fopenPtr("dummy file", "dummy mode");
|
||||
EXPECT_EQ(reinterpret_cast<FILE *>(0x40), file);
|
||||
int expectedPrintfRet = 0x10;
|
||||
int actualPrintfRet = IoFunctions::fprintf(file, "dummy format", "dummy string");
|
||||
EXPECT_EQ(expectedPrintfRet, actualPrintfRet);
|
||||
IoFunctions::fprintf(file, "another dummy format", "another dummy string");
|
||||
IoFunctions::fclosePtr(file);
|
||||
|
||||
EXPECT_EQ(1u, IoFunctions::mockFopenCalled);
|
||||
EXPECT_EQ(2u, IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_EQ(1u, IoFunctions::mockFcloseCalled);
|
||||
}
|
||||
Reference in New Issue
Block a user