mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Debug flag to force early exit
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
16db7cc890
commit
6e9257c623
@@ -232,6 +232,8 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableMultipleRegularContextForBcs, -1, "-1: def
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, AppendAubStreamContextFlags, -1, "-1: default, >0: Append flags passed during HardwareContext creation.")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, DisableScratchPages, -1, "-1: default, 0: do not disable scratch pages during VM creations, 1: disable scratch pages during VM creations")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, OptimizeIoqBarriersHandling, -1, "-1: default, 0: disable, 1: enable. If enabled, dont dispatch stalling commands for IOQ. Instead, inherit TimestampPackets from previous enqueue.")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, ExitOnSubmissionNumber, -1, "Call exit(0) on X submission. >=0: submission count (start from 0)")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, ExitOnSubmissionMode, 0, "Exit on X submission mode. 0: Any context type, 1: Compute context only, 2: Copy context only ")
|
||||
DECLARE_DEBUG_VARIABLE(int64_t, OverrideEventSynchronizeTimeout, -1, "-1: default - user provided timeout value, >0: timeout in nanoseconds")
|
||||
|
||||
/*LOGGING FLAGS*/
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/sys_calls_common.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
@@ -87,6 +88,22 @@ inline DrmCommandStreamReceiver<GfxFamily>::~DrmCommandStreamReceiver() {
|
||||
|
||||
template <typename GfxFamily>
|
||||
SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
|
||||
if (DebugManager.flags.ExitOnSubmissionNumber.get() != -1) {
|
||||
bool enabled = (this->taskCount >= static_cast<TaskCountType>(DebugManager.flags.ExitOnSubmissionNumber.get()));
|
||||
|
||||
if (DebugManager.flags.ExitOnSubmissionMode.get() == 1 && !EngineHelpers::isComputeEngine(this->osContext->getEngineType())) {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
if (DebugManager.flags.ExitOnSubmissionMode.get() == 2 && !EngineHelpers::isBcs(this->osContext->getEngineType())) {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
SysCalls::exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
this->printDeviceIndex();
|
||||
DrmAllocation *alloc = static_cast<DrmAllocation *>(batchBuffer.commandBufferAllocation);
|
||||
DEBUG_BREAK_IF(!alloc);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <iostream>
|
||||
@@ -21,6 +22,10 @@ namespace NEO {
|
||||
|
||||
namespace SysCalls {
|
||||
|
||||
void exit(int code) {
|
||||
std::exit(code);
|
||||
}
|
||||
|
||||
unsigned int getProcessId() {
|
||||
static unsigned int pid = getpid();
|
||||
return pid;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -15,6 +15,8 @@ unsigned int getProcessId();
|
||||
|
||||
unsigned long getNumThreads();
|
||||
|
||||
void exit(int code);
|
||||
|
||||
} // namespace SysCalls
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "shared/source/os_interface/windows/sys_calls.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
unsigned int getPid() {
|
||||
@@ -25,6 +27,9 @@ bool isShutdownInProgress() {
|
||||
}
|
||||
|
||||
namespace SysCalls {
|
||||
void exit(int code) {
|
||||
std::exit(code);
|
||||
}
|
||||
|
||||
unsigned int getProcessId() {
|
||||
return GetCurrentProcessId();
|
||||
|
||||
@@ -29,6 +29,7 @@ struct MockDrmCsr : public DrmCommandStreamReceiver<GfxFamily> {
|
||||
using DrmCommandStreamReceiver<GfxFamily>::dispatchMode;
|
||||
using DrmCommandStreamReceiver<GfxFamily>::completionFenceValuePointer;
|
||||
using DrmCommandStreamReceiver<GfxFamily>::flushInternal;
|
||||
using DrmCommandStreamReceiver<GfxFamily>::CommandStreamReceiver::taskCount;
|
||||
};
|
||||
|
||||
class DrmCommandStreamTest : public ::testing::Test {
|
||||
|
||||
@@ -31,7 +31,9 @@ uint32_t closeFuncCalled = 0u;
|
||||
int closeFuncArgPassed = 0;
|
||||
int closeFuncRetVal = 0;
|
||||
int dlOpenFlags = 0;
|
||||
bool dlOpenCalled = 0;
|
||||
int latestExitCode = 0;
|
||||
bool exitCalled = false;
|
||||
bool dlOpenCalled = false;
|
||||
bool getNumThreadsCalled = false;
|
||||
bool makeFakeDevicePath = false;
|
||||
bool allowFakeDevicePath = false;
|
||||
@@ -66,6 +68,11 @@ int (*sysCallsPipe)(int pipeFd[2]) = nullptr;
|
||||
int (*sysCallsFstat)(int fd, struct stat *buf) = nullptr;
|
||||
char *(*sysCallsRealpath)(const char *path, char *buf) = nullptr;
|
||||
|
||||
void exit(int code) {
|
||||
exitCalled = true;
|
||||
latestExitCode = code;
|
||||
}
|
||||
|
||||
int close(int fileDescriptor) {
|
||||
closeFuncCalled++;
|
||||
closeFuncArgPassed = fileDescriptor;
|
||||
|
||||
@@ -33,6 +33,8 @@ extern int passedFileDescriptorFlagsToSet;
|
||||
extern int getFileDescriptorFlagsCalled;
|
||||
extern int setFileDescriptorFlagsCalled;
|
||||
extern uint32_t closeFuncCalled;
|
||||
extern bool exitCalled;
|
||||
extern int latestExitCode;
|
||||
|
||||
extern std::vector<void *> mmapVector;
|
||||
extern std::vector<void *> mmapCapturedExtendedPointers;
|
||||
|
||||
@@ -33,6 +33,9 @@ const HKEY validHkey = reinterpret_cast<HKEY>(0);
|
||||
bool getNumThreadsCalled = false;
|
||||
bool mmapAllowExtendedPointers = false;
|
||||
|
||||
void exit(int code) {
|
||||
}
|
||||
|
||||
HANDLE createEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) {
|
||||
if (mockCreateEventClb) {
|
||||
return mockCreateEventClb(lpEventAttributes, bManualReset, bInitialState, lpName, mockCreateEventClbData);
|
||||
|
||||
@@ -515,3 +515,5 @@ DetectIndirectAccessInKernel = -1
|
||||
OptimizeIoqBarriersHandling = -1
|
||||
AllocateSharedAllocationsInHeapExtended = 0
|
||||
DirectSubmissionControllerMaxTimeout = -1
|
||||
ExitOnSubmissionNumber = -1
|
||||
ExitOnSubmissionMode = 0
|
||||
@@ -40,6 +40,13 @@
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
namespace NEO {
|
||||
namespace SysCalls {
|
||||
extern bool exitCalled;
|
||||
extern int latestExitCode;
|
||||
} // namespace SysCalls
|
||||
} // namespace NEO
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenFlushStampWhenWaitCalledThenWaitForSpecifiedBoHandle) {
|
||||
FlushStamp handleToWait = 123;
|
||||
GemWait expectedWait = {};
|
||||
@@ -51,6 +58,72 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenFlushStampWhenWaitCalledThenWaitFo
|
||||
EXPECT_EQ(1, mock->ioctlCount.gemWait);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenDebugFlagSetWhenSubmittingThenCallExit) {
|
||||
uint32_t expectedExitCounter = 13;
|
||||
|
||||
DebugManager.flags.ExitOnSubmissionNumber.set(expectedExitCounter);
|
||||
|
||||
csr->initializeTagAllocation();
|
||||
|
||||
auto &cs = csr->getCS();
|
||||
IndirectHeap ih(cs.getGraphicsAllocation());
|
||||
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
|
||||
dispatchFlags.preemptionMode = PreemptionMode::Disabled;
|
||||
|
||||
executionEnvironment.incRefInternal();
|
||||
std::unique_ptr<MockDevice> device(MockDevice::create<MockDevice>(&executionEnvironment, 0));
|
||||
device->setPreemptionMode(PreemptionMode::Disabled);
|
||||
|
||||
bool bcsSupported = false;
|
||||
for (auto &engine : csr->getGfxCoreHelper().getGpgpuEngineInstances(device->getRootDeviceEnvironment())) {
|
||||
if (engine.first == aub_stream::EngineType::ENGINE_BCS) {
|
||||
bcsSupported = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t mode : {0, 1, 2}) {
|
||||
DebugManager.flags.ExitOnSubmissionMode.set(mode);
|
||||
|
||||
for (auto engineType : {aub_stream::ENGINE_BCS, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::ENGINE_RCS, device->getRootDeviceEnvironment())}) {
|
||||
if (engineType == aub_stream::ENGINE_BCS && !bcsSupported) {
|
||||
continue;
|
||||
}
|
||||
|
||||
osContext = std::make_unique<OsContextLinux>(*mock, 0, 0,
|
||||
EngineDescriptorHelper::getDefaultDescriptor({engineType, EngineUsage::Regular}, PreemptionMode::ThreadGroup));
|
||||
|
||||
osContext->ensureContextInitialized();
|
||||
|
||||
csr->setupContext(*osContext);
|
||||
static_cast<MockDrmCsr<FamilyType> *>(csr)->taskCount = 0;
|
||||
|
||||
for (uint32_t i = 0; i <= expectedExitCounter + 3; i++) {
|
||||
SysCalls::exitCalled = false;
|
||||
|
||||
csr->flushTask(cs, 0u, &ih, &ih, &ih, 0u, dispatchFlags, *device);
|
||||
|
||||
bool enabled = (i >= expectedExitCounter);
|
||||
|
||||
if (mode == 1 && !EngineHelpers::isComputeEngine(engineType)) {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
if (mode == 2 && !EngineHelpers::isBcs(engineType)) {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
EXPECT_TRUE(SysCalls::exitCalled);
|
||||
EXPECT_EQ(0, SysCalls::latestExitCode);
|
||||
} else {
|
||||
EXPECT_FALSE(SysCalls::exitCalled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamTest, WhenMakingResidentThenSucceeds) {
|
||||
DrmAllocation graphicsAllocation(0, AllocationType::UNKNOWN, nullptr, nullptr, 1024, static_cast<osHandle>(1u), MemoryPool::MemoryNull);
|
||||
csr->makeResident(graphicsAllocation);
|
||||
|
||||
Reference in New Issue
Block a user