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