2018-03-21 17:00:49 +08:00
|
|
|
/*
|
2024-03-22 19:18:35 +08:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2018-03-21 17:00:49 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2018-03-21 17:00:49 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2022-11-22 21:53:59 +08:00
|
|
|
#include "shared/source/command_stream/task_count_helper.h"
|
2022-03-23 22:36:07 +08:00
|
|
|
#include "shared/source/command_stream/wait_status.h"
|
2018-04-09 16:05:32 +08:00
|
|
|
|
2018-06-07 15:14:00 +08:00
|
|
|
#include <atomic>
|
2019-02-27 18:39:32 +08:00
|
|
|
#include <cstdint>
|
2018-03-21 17:00:49 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2022-11-25 23:04:24 +08:00
|
|
|
enum QueueThrottle : uint32_t;
|
|
|
|
using FlushStamp = uint64_t;
|
|
|
|
|
2018-03-21 17:00:49 +08:00
|
|
|
struct KmdNotifyProperties {
|
2018-12-06 22:33:02 +08:00
|
|
|
int64_t delayKmdNotifyMicroseconds;
|
|
|
|
int64_t delayQuickKmdSleepMicroseconds;
|
|
|
|
int64_t delayQuickKmdSleepForSporadicWaitsMicroseconds;
|
2021-12-18 02:42:13 +08:00
|
|
|
int64_t delayQuickKmdSleepForDirectSubmissionMicroseconds;
|
2018-03-22 16:41:17 +08:00
|
|
|
// Main switch for KMD Notify optimization - if its disabled, all below are disabled too
|
2018-03-21 17:00:49 +08:00
|
|
|
bool enableKmdNotify;
|
2018-03-22 16:41:17 +08:00
|
|
|
// Use smaller delay in specific situations (ie. from AsyncEventsHandler)
|
2018-03-21 17:00:49 +08:00
|
|
|
bool enableQuickKmdSleep;
|
2018-03-22 16:41:17 +08:00
|
|
|
// If waits are called sporadically use QuickKmdSleep mode, otherwise use standard delay
|
|
|
|
bool enableQuickKmdSleepForSporadicWaits;
|
2021-12-18 02:42:13 +08:00
|
|
|
// If direct submission is enabled, use direct submission delay, otherwise use standard delay
|
|
|
|
bool enableQuickKmdSleepForDirectSubmission;
|
2018-04-10 16:26:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace KmdNotifyConstants {
|
2022-12-08 22:23:49 +08:00
|
|
|
inline constexpr int64_t timeoutInMicrosecondsForDisconnectedAcLine = 10000;
|
|
|
|
inline constexpr uint32_t minimumTaskCountDiffToCheckAcLine = 10;
|
2018-04-10 16:26:59 +08:00
|
|
|
} // namespace KmdNotifyConstants
|
2018-03-22 16:41:17 +08:00
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
class KmdNotifyHelper {
|
|
|
|
public:
|
|
|
|
KmdNotifyHelper() = delete;
|
|
|
|
KmdNotifyHelper(const KmdNotifyProperties *properties) : properties(properties){};
|
2018-05-24 17:06:30 +08:00
|
|
|
MOCKABLE_VIRTUAL ~KmdNotifyHelper() = default;
|
2018-03-22 16:41:17 +08:00
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
WaitParams obtainTimeoutParams(bool quickKmdSleepRequest,
|
2022-11-22 21:53:59 +08:00
|
|
|
TagAddressType currentHwTag,
|
|
|
|
TaskCountType taskCountToWait,
|
2022-03-23 22:36:07 +08:00
|
|
|
FlushStamp flushStampToWait,
|
|
|
|
QueueThrottle throttle,
|
|
|
|
bool kmdWaitModeActive,
|
|
|
|
bool directSubmissionEnabled);
|
2018-04-09 16:05:32 +08:00
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
bool quickKmdSleepForSporadicWaitsEnabled() const { return properties->enableQuickKmdSleepForSporadicWaits; }
|
|
|
|
MOCKABLE_VIRTUAL void updateLastWaitForCompletionTimestamp();
|
|
|
|
MOCKABLE_VIRTUAL void updateAcLineStatus();
|
2024-03-22 19:18:35 +08:00
|
|
|
bool getAcLineConnected() const { return acLineConnected.load(); }
|
2018-03-22 16:41:17 +08:00
|
|
|
|
|
|
|
static void overrideFromDebugVariable(int32_t debugVariableValue, int64_t &destination);
|
|
|
|
static void overrideFromDebugVariable(int32_t debugVariableValue, bool &destination);
|
2018-04-10 16:26:59 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool applyQuickKmdSleepForSporadicWait() const;
|
2018-06-07 15:14:00 +08:00
|
|
|
int64_t getMicrosecondsSinceEpoch() const;
|
2018-04-10 16:26:59 +08:00
|
|
|
|
|
|
|
const KmdNotifyProperties *properties = nullptr;
|
2018-06-07 15:14:00 +08:00
|
|
|
std::atomic<int64_t> lastWaitForCompletionTimestampUs{0};
|
|
|
|
std::atomic<bool> acLineConnected{true};
|
2018-03-21 17:00:49 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|