mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Add debug variable for logging drm_buffer object
Change-Id: Ida9635705172c1059b6adf4b6f55fdf4bc50c5b1
This commit is contained in:

committed by
sys_ocldev

parent
55ba0ab459
commit
2fb1dd439e
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
||||
|
||||
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture.h"
|
||||
#include "test.h"
|
||||
@ -136,6 +137,22 @@ TEST_F(DrmBufferObjectTest, onPinIoctlFailed) {
|
||||
EXPECT_EQ(EINVAL, ret);
|
||||
}
|
||||
|
||||
TEST_F(DrmBufferObjectTest, whenPrintExecutionBufferIsSetToTrueThenMessageFoundInStdStream) {
|
||||
mock->ioctl_expected.total = 1;
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.PrintExecutionBuffer.set(true);
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto ret = bo->exec(0, 0, 0, false, 1, nullptr, 0u, &execObjectsStorage);
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
auto idx = output.find("drm_i915_gem_execbuffer2 {");
|
||||
size_t expectedValue = 0;
|
||||
EXPECT_EQ(expectedValue, idx);
|
||||
}
|
||||
|
||||
TEST(DrmBufferObjectSimpleTest, givenInvalidBoWhenPinIsCalledThenErrorIsReturned) {
|
||||
std::unique_ptr<uint32_t[]> buff(new uint32_t[256]);
|
||||
std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom);
|
||||
|
@ -164,4 +164,5 @@ UseCommandBufferHeaderSizeForWddmQueueSubmission = 1
|
||||
OverridePreemptionSurfaceSizeInMb = -1
|
||||
OverrideLeastOccupiedBank = -1
|
||||
UseAsyncDrmExec = -1
|
||||
EnableMultiStorageResources = -1
|
||||
EnableMultiStorageResources = -1
|
||||
PrintExecutionBuffer = 0
|
||||
|
@ -89,6 +89,7 @@ DECLARE_DEBUG_VARIABLE(bool, PrintTimestampPacketContents, false, "prints all ti
|
||||
DECLARE_DEBUG_VARIABLE(bool, WddmResidencyLogger, false, "gather Wddm residency statistics to file")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")
|
||||
DECLARE_DEBUG_VARIABLE(bool, PrintDeviceAndEngineIdOnSubmission, false, "print submissions device and engine IDs to standard output")
|
||||
DECLARE_DEBUG_VARIABLE(bool, PrintExecutionBuffer, false, "print execution buffer information to standard output")
|
||||
|
||||
/*DIRECT SUBMISSION FLAGS*/
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, EnableDirectSubmission, -1, "-1: default (disabled), 0: disable, 1:enable. Enables direct submission of command buffers bypassing KMD")
|
||||
|
@ -114,6 +114,10 @@ int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bo
|
||||
execbuf.flags = flags;
|
||||
execbuf.rsvd1 = drmContextId;
|
||||
|
||||
if (DebugManager.flags.PrintExecutionBuffer.get()) {
|
||||
printExecutionBuffer(execbuf, residencyCount, execObjectsStorage);
|
||||
}
|
||||
|
||||
int ret = this->drm->ioctl(DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
|
||||
if (ret == 0) {
|
||||
return 0;
|
||||
@ -124,6 +128,33 @@ int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bo
|
||||
return err;
|
||||
}
|
||||
|
||||
void BufferObject::printExecutionBuffer(drm_i915_gem_execbuffer2 &execbuf, const size_t &residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage) {
|
||||
std::string logger = "drm_i915_gem_execbuffer2 {\n";
|
||||
logger += " buffers_ptr: " + std::to_string(execbuf.buffers_ptr) + ",\n";
|
||||
logger += " buffer_count: " + std::to_string(execbuf.buffer_count) + ",\n";
|
||||
logger += " batch_start_offset: " + std::to_string(execbuf.batch_start_offset) + ",\n";
|
||||
logger += " batch_len: " + std::to_string(execbuf.batch_len) + ",\n";
|
||||
logger += " flags: " + std::to_string(execbuf.flags) + ",\n";
|
||||
logger += " rsvd1: " + std::to_string(execbuf.rsvd1) + ",\n";
|
||||
logger += "}\n";
|
||||
|
||||
for (size_t i = 0; i < residencyCount + 1; i++) {
|
||||
std::string temp = "drm_i915_gem_exec_object2 {\n";
|
||||
temp += " handle: " + std::to_string(execObjectsStorage[i].handle) + ",\n";
|
||||
temp += " relocation_count: " + std::to_string(execObjectsStorage[i].relocation_count) + ",\n";
|
||||
temp += " relocs_ptr: " + std::to_string(execObjectsStorage[i].relocs_ptr) + ",\n";
|
||||
temp += " alignment: " + std::to_string(execObjectsStorage[i].alignment) + ",\n";
|
||||
temp += " offset: " + std::to_string(execObjectsStorage[i].offset) + ",\n";
|
||||
temp += " flags: " + std::to_string(execObjectsStorage[i].flags) + ",\n";
|
||||
temp += " rsvd1: " + std::to_string(execObjectsStorage[i].rsvd1) + ",\n";
|
||||
temp += " rsvd2: " + std::to_string(execObjectsStorage[i].rsvd2) + ",\n";
|
||||
temp += " pad_to_size: " + std::to_string(execObjectsStorage[i].pad_to_size) + ",\n";
|
||||
temp += "}\n";
|
||||
logger += temp;
|
||||
}
|
||||
std::cout << logger << std::endl;
|
||||
}
|
||||
|
||||
int BufferObject::pin(BufferObject *const boToPin[], size_t numberOfBos, uint32_t drmContextId) {
|
||||
StackVec<drm_i915_gem_exec_object2, maxFragmentsCount + 1> execObject(numberOfBos + 1);
|
||||
return this->exec(4u, 0u, 0u, false, drmContextId, boToPin, numberOfBos, &execObject[0]);
|
||||
|
@ -6,6 +6,8 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <stdint.h>
|
||||
@ -31,6 +33,8 @@ class BufferObject {
|
||||
|
||||
int exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, uint32_t drmContextId, BufferObject *const residency[], size_t residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage);
|
||||
|
||||
void printExecutionBuffer(drm_i915_gem_execbuffer2 &execbuf, const size_t &residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage);
|
||||
|
||||
int wait(int64_t timeoutNs);
|
||||
bool close();
|
||||
|
||||
|
Reference in New Issue
Block a user