Skip to content

Commit 7418cff

Browse files
feature: add debug flags and instrumentation of waitpkg calls
Related-To: NEO-9737 Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent 9df6808 commit 7418cff

File tree

10 files changed

+281
-37
lines changed

10 files changed

+281
-37
lines changed

shared/source/debug_settings/debug_variables_base.inl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ DECLARE_DEBUG_VARIABLE(std::string, WddmResidencyLoggerOutputDirectory, std::str
9898
DECLARE_DEBUG_VARIABLE(int64_t, OverrideMultiStoragePlacement, -1, "Place memory only in selected tiles indicated by bit mask; ignore when -1")
9999
DECLARE_DEBUG_VARIABLE(int64_t, ForceCompressionDisabledForCompressedBlitCopies, -1, "If compression is required, set AUX_CCS_E, but force CompressionEnable filed; 0 should result in uncompressed read/write; values = -1: default, 0: disabled, 1: enabled")
100100
DECLARE_DEBUG_VARIABLE(int64_t, WddmPagingFenceCpuWaitDelayTime, 0, "Amount of microseconds after waitng for paging fence on CPU")
101+
DECLARE_DEBUG_VARIABLE(int64_t, OverrideEventSynchronizeTimeout, -1, "-1: default - user provided timeout value, >0: timeout in nanoseconds")
102+
DECLARE_DEBUG_VARIABLE(int64_t, WaitpkgCounterValue, -1, "-1: use default, >=0: use constant value added for umwait counter")
103+
DECLARE_DEBUG_VARIABLE(int32_t, WaitpkgControlValue, -1, "-1: use default, 0: slower wakeup - larger power savings, 1: faster wakeup - smaller power savings")
101104
DECLARE_DEBUG_VARIABLE(int32_t, ForceL1Caching, -1, "Program L1 cache policy for surface state and stateless accesses; values = -1: default, 0: disable, 1: enable")
102105
DECLARE_DEBUG_VARIABLE(int32_t, ForceAuxTranslationEnabled, -1, "Require AUX translation for kernels; values = -1: default, 0: disabled, 1: enabled")
103106
DECLARE_DEBUG_VARIABLE(int32_t, EnableExperimentalCommandBuffer, 0, "Inject experimental command buffer")
@@ -247,7 +250,6 @@ DECLARE_DEBUG_VARIABLE(int32_t, ExitOnSubmissionMode, 0, "Exit on X submission m
247250
DECLARE_DEBUG_VARIABLE(int32_t, ForceInOrderImmediateCmdListExecution, -1, "-1: default, 0: disabled, 1: all Immediate Command Lists are switched to in-order execution")
248251
DECLARE_DEBUG_VARIABLE(int32_t, ForceInOrderEvents, -1, "-1: default, 0: disabled, 1: Enable all Events as in-order, to rely on command list counter value")
249252
DECLARE_DEBUG_VARIABLE(int32_t, EnableImplicitConvertionToCounterBasedEvents, -1, "-1: default, 0: Disable, 1: Enable. If enabled, try to convert Regular Events used on Immediate CL to CounterBased")
250-
DECLARE_DEBUG_VARIABLE(int64_t, OverrideEventSynchronizeTimeout, -1, "-1: default - user provided timeout value, >0: timeout in nanoseconds")
251253
DECLARE_DEBUG_VARIABLE(int32_t, ForceTlbFlush, -1, "-1: default, 0: Tlb flush disabled, 1: Tlb Flush enabled")
252254
DECLARE_DEBUG_VARIABLE(int32_t, DebugSetMemoryDiagnosticsDelay, -1, "-1: default, >=0: delay time in minutes necessary for completion of Memory diagnostics")
253255
DECLARE_DEBUG_VARIABLE(int32_t, EnableDeviceStateVerification, -1, "-1: default, 0: disable, 1: enable check of device state before submit on Windows")
@@ -415,6 +417,7 @@ DECLARE_DEBUG_VARIABLE(bool, EngineInstancedSubDevices, false, "Create subdevice
415417
DECLARE_DEBUG_VARIABLE(bool, AllowSingleTileEngineInstancedSubDevices, false, "Create subdevices assigned to specific engine on single tile config")
416418
DECLARE_DEBUG_VARIABLE(bool, EnablePrivateBO, false, "Enable PRELIM_I915_GEM_CREATE_EXT_VM_PRIVATE extension creating VM_PRIVATE BOs")
417419
DECLARE_DEBUG_VARIABLE(bool, UseDeprecatedClDeviceIpVersion, false, "When enabled, the deprecated ip version scheme distinguishing between families and integrated devices will be queried in OCL")
420+
DECLARE_DEBUG_VARIABLE(bool, EnableAIL, true, "Enables AIL")
418421
DECLARE_DEBUG_VARIABLE(int32_t, ForceRunAloneContext, -1, "Control creation of run-alone HW context, -1:default, 0:disable, 1:enable")
419422
DECLARE_DEBUG_VARIABLE(int32_t, AddClGlSharing, -1, "Add cl-gl extension")
420423
DECLARE_DEBUG_VARIABLE(int32_t, EnableKernelTunning, -1, "Perform a tunning of enqueue kernel, -1:default(disabled), 0:disable, 1:enable simple kernel tunning, 2:enable full kernel tunning")
@@ -456,6 +459,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, UseBindlessMode, -1, "Use precompiled builtins i
456459
DECLARE_DEBUG_VARIABLE(int32_t, OverrideSlmSize, -1, "Force different slm size than default in kB")
457460
DECLARE_DEBUG_VARIABLE(int32_t, UseCyclesPerSecondTimer, 0, "0: default behavior, 0: disabled: Report L0 timer in nanosecond units, 1: enabled: Report L0 timer in cycles per second")
458461
DECLARE_DEBUG_VARIABLE(int32_t, WaitLoopCount, -1, "-1: use default, >=0: number of iterations in wait loop")
462+
DECLARE_DEBUG_VARIABLE(int32_t, EnableWaitpkg, -1, "-1: use default, 0: disable, 1: enable")
459463
DECLARE_DEBUG_VARIABLE(int32_t, GTPinAllocateBufferInSharedMemory, -1, "Force GTPin to allocate buffer in shared memory")
460464
DECLARE_DEBUG_VARIABLE(int32_t, AlignLocalMemoryVaTo2MB, -1, "Allow 2MB pages for allocations with size>=2MB. On Linux it means aligned VA, on Windows it means aligned size. -1: default, 0: disabled, 1: enabled")
461465
DECLARE_DEBUG_VARIABLE(int32_t, EnableUserFenceForCompletionWait, -1, "-1: default (disabled), 0: disable, 1: enable : Use Wait User Fence instead Gem Wait")
@@ -485,7 +489,6 @@ DECLARE_DEBUG_VARIABLE(int32_t, CompactL3FlushEventPacket, -1, "Compact COMPUTE_
485489
DECLARE_DEBUG_VARIABLE(int32_t, UseDynamicEventPacketsCount, -1, "Use dynamic estimation for event packet count based on a given device configuration, -1: default , 0: disabled, 1: enabled")
486490
DECLARE_DEBUG_VARIABLE(int32_t, SignalAllEventPackets, -1, "All packets of event are signaled, reset and waited/synchronized, -1: default, 0: disabled, 1: enabled")
487491
DECLARE_DEBUG_VARIABLE(int32_t, EnableBcsSwControlWa, -1, "Enable BCS WA via BCSSWCONTROL MMIO. -1: default, 0: disabled, 1: if src in system mem, 2: if dst in system mem, 3: if src and dst in system mem, 4: always")
488-
DECLARE_DEBUG_VARIABLE(bool, EnableAIL, true, "Enables AIL")
489492

490493
/* IMPLICIT SCALING */
491494
DECLARE_DEBUG_VARIABLE(int32_t, EnableWalkerPartition, -1, "-1: default, 0: disable, 1: enable, Enables Walker Partitioning via WPARID.")

shared/source/utilities/wait_util.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,50 @@
88
#include "shared/source/utilities/wait_util.h"
99

1010
#include "shared/source/debug_settings/debug_settings_manager.h"
11+
#include "shared/source/utilities/cpu_info.h"
1112

1213
namespace NEO {
1314

1415
namespace WaitUtils {
1516

17+
constexpr uint64_t defaultCounterValue = 10000;
18+
constexpr uint32_t defaultControlValue = 0;
19+
constexpr bool defaultEnableWaitPkg = false;
20+
21+
uint64_t counterValue = defaultCounterValue;
22+
uint32_t controlValue = defaultControlValue;
23+
1624
uint32_t waitCount = defaultWaitCount;
1725

26+
#ifdef SUPPORTS_WAITPKG
27+
bool waitpkgSupport = SUPPORTS_WAITPKG;
28+
#else
29+
bool waitpkgSupport = false;
30+
#endif
31+
bool waitpkgUse = false;
32+
1833
void init() {
34+
bool enableWaitPkg = defaultEnableWaitPkg;
35+
int32_t overrideEnableWaitPkg = debugManager.flags.EnableWaitpkg.get();
36+
if (overrideEnableWaitPkg != -1) {
37+
enableWaitPkg = !!(overrideEnableWaitPkg);
38+
}
39+
if (enableWaitPkg && waitpkgSupport) {
40+
if (CpuInfo::getInstance().isFeatureSupported(CpuInfo::featureWaitPkg)) {
41+
waitpkgUse = true;
42+
waitCount = 0;
43+
}
44+
}
45+
46+
int64_t overrideWaitPkgCounter = debugManager.flags.WaitpkgCounterValue.get();
47+
if (overrideWaitPkgCounter != -1) {
48+
counterValue = static_cast<uint64_t>(overrideWaitPkgCounter);
49+
}
50+
int32_t overrideWaitPkgControl = debugManager.flags.WaitpkgControlValue.get();
51+
if (overrideWaitPkgControl != -1) {
52+
controlValue = static_cast<uint32_t>(overrideWaitPkgControl);
53+
}
54+
1955
int32_t overrideWaitCount = debugManager.flags.WaitLoopCount.get();
2056
if (overrideWaitCount != -1) {
2157
waitCount = static_cast<uint32_t>(overrideWaitCount);

shared/source/utilities/wait_util.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2022 Intel Corporation
2+
* Copyright (C) 2021-2023 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -18,7 +18,12 @@ namespace NEO {
1818
namespace WaitUtils {
1919

2020
constexpr uint32_t defaultWaitCount = 1u;
21+
22+
extern uint64_t counterValue;
23+
extern uint32_t controlValue;
2124
extern uint32_t waitCount;
25+
extern bool waitpkgSupport;
26+
extern bool waitpkgUse;
2227

2328
template <typename T>
2429
inline bool waitFunctionWithPredicate(volatile T const *pollAddress, T expectedValue, std::function<bool(T, T)> predicate) {

shared/test/common/test_files/igdrcl.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ HBMSizePerTileInGigabytes = 0
362362
OverrideSystolicPipelineSelect = -1
363363
OverrideSystolicInComputeWalker = -1
364364
SkipFlushingEventsOnGetStatusCalls = 0
365+
EnableWaitpkg = -1
366+
WaitpkgControlValue = -1
367+
WaitpkgCounterValue = -1
365368
AllowUnrestrictedSize = 0
366369
ForceDefaultThreadArbitrationPolicyIfNotSpecified = 0
367370
DoNotFreeResources = 0

shared/test/unit_test/mocks/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#
2-
# Copyright (C) 2021-2022 Intel Corporation
2+
# Copyright (C) 2021-2023 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
66

77
target_sources(neo_shared_tests PRIVATE
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
99
${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_stream.h
10+
${CMAKE_CURRENT_SOURCE_DIR}/mock_cpuid_functions.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}/mock_cpuid_functions.h
1012
${CMAKE_CURRENT_SOURCE_DIR}/mock_csr_simulated_common_hw.h
1113
${CMAKE_CURRENT_SOURCE_DIR}/mock_direct_submission_diagnostic_collector.h
1214
${CMAKE_CURRENT_SOURCE_DIR}/mock_dispatch_kernel_encoder_interface.h
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) 2023 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/test/unit_test/mocks/mock_cpuid_functions.h"
9+
10+
void mockCpuidEnableAll(int *cpuInfo, int functionId) {
11+
cpuInfo[0] = -1;
12+
cpuInfo[1] = -1;
13+
cpuInfo[2] = -1;
14+
cpuInfo[3] = -1;
15+
}
16+
17+
void mockCpuidFunctionAvailableDisableAll(int *cpuInfo, int functionId) {
18+
cpuInfo[0] = -1;
19+
cpuInfo[1] = 0;
20+
cpuInfo[2] = 0;
21+
cpuInfo[3] = 0;
22+
}
23+
24+
void mockCpuidFunctionNotAvailableDisableAll(int *cpuInfo, int functionId) {
25+
cpuInfo[0] = 0;
26+
cpuInfo[1] = 0;
27+
cpuInfo[2] = 0;
28+
cpuInfo[3] = 0;
29+
}
30+
31+
void mockCpuidReport36BitVirtualAddressSize(int *cpuInfo, int functionId) {
32+
if (static_cast<unsigned int>(functionId) == 0x80000008) {
33+
cpuInfo[0] = 36 << 8;
34+
cpuInfo[1] = 0;
35+
cpuInfo[2] = 0;
36+
cpuInfo[3] = 0;
37+
} else {
38+
mockCpuidEnableAll(cpuInfo, functionId);
39+
}
40+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (C) 2023 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
void mockCpuidEnableAll(int *cpuInfo, int functionId);
11+
12+
void mockCpuidFunctionAvailableDisableAll(int *cpuInfo, int functionId);
13+
14+
void mockCpuidFunctionNotAvailableDisableAll(int *cpuInfo, int functionId);
15+
16+
void mockCpuidReport36BitVirtualAddressSize(int *cpuInfo, int functionId);

shared/test/unit_test/utilities/x86_64/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2021-2022 Intel Corporation
2+
# Copyright (C) 2021-2023 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -8,6 +8,7 @@ if(${NEO_TARGET_PROCESSOR} STREQUAL "x86_64")
88
target_sources(neo_shared_tests PRIVATE
99
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
1010
${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_x86_64.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}/wait_util_tests_x86_64.cpp
1112
)
1213

1314
add_subdirectories()

shared/test/unit_test/utilities/x86_64/cpuinfo_tests_x86_64.cpp

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,12 @@
66
*/
77

88
#include "shared/source/utilities/cpu_info.h"
9+
#include "shared/test/unit_test/mocks/mock_cpuid_functions.h"
910

1011
#include "gtest/gtest.h"
1112

1213
using namespace NEO;
1314

14-
void mockCpuidEnableAll(int *cpuInfo, int functionId) {
15-
cpuInfo[0] = -1;
16-
cpuInfo[1] = -1;
17-
cpuInfo[2] = -1;
18-
cpuInfo[3] = -1;
19-
}
20-
21-
void mockCpuidFunctionAvailableDisableAll(int *cpuInfo, int functionId) {
22-
cpuInfo[0] = -1;
23-
cpuInfo[1] = 0;
24-
cpuInfo[2] = 0;
25-
cpuInfo[3] = 0;
26-
}
27-
28-
void mockCpuidFunctionNotAvailableDisableAll(int *cpuInfo, int functionId) {
29-
cpuInfo[0] = 0;
30-
cpuInfo[1] = 0;
31-
cpuInfo[2] = 0;
32-
cpuInfo[3] = 0;
33-
}
34-
35-
void mockCpuidReport36BitVirtualAddressSize(int *cpuInfo, int functionId) {
36-
if (static_cast<uint32_t>(functionId) == 0x80000008) {
37-
cpuInfo[0] = 36 << 8;
38-
cpuInfo[1] = 0;
39-
cpuInfo[2] = 0;
40-
cpuInfo[3] = 0;
41-
} else {
42-
mockCpuidEnableAll(cpuInfo, functionId);
43-
}
44-
}
45-
4615
TEST(CpuInfoTest, giveFunctionIsNotAvailableWhenFeatureIsNotSupportedThenMaskBitIsOff) {
4716
void (*defaultCpuidFunc)(int *, int) = CpuInfo::cpuidFunc;
4817
CpuInfo::cpuidFunc = mockCpuidFunctionNotAvailableDisableAll;

0 commit comments

Comments
 (0)