This commit is contained in:
Nitload
2026-03-16 07:15:19 +08:00
parent ccf95ec270
commit 8e6dfa7211
3 changed files with 62 additions and 50 deletions
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="L4.Predict"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -36,29 +36,48 @@ namespace StgSharp.HighPerformance.Memory
public interface IPrefetchPredict
{
int Predict(
Span<CacheLinePrediction> node
);
int Predict(Span<CacheLinePrediction> node);
bool Prefetch(
nuint origin,
ulong policy,
nuint cache
);
bool Prefetch(nuint origin, ulong policy, nuint cache);
void WriteBack(
nuint origin,
ulong policy,
nuint cache
);
void WriteBack(nuint origin, ulong policy, nuint cache);
}
public struct CacheLinePrediction
public struct CacheLinePrediction : IEquatable<CacheLinePrediction>
{
public override readonly bool Equals(object? obj)
{
return obj is CacheLinePrediction prediction &&
Address.Equals(prediction.Address) &&
MapPolicy == prediction.MapPolicy;
}
public readonly bool Equals(CacheLinePrediction other)
{
return
Address == other.Address && MapPolicy == other.MapPolicy;
}
public override readonly int GetHashCode()
{
return HashCode.Combine(Address, MapPolicy);
}
public static bool operator !=(CacheLinePrediction left, CacheLinePrediction right)
{
return !(left == right);
}
public static bool operator ==(CacheLinePrediction left, CacheLinePrediction right)
{
return left.Equals(right);
}
#pragma warning disable CA1051
public nuint Address;
public ulong MapPolicy;
#pragma warning restore CA1051
}
}