matrix pool init ok, working on task publish

This commit is contained in:
Nitload
2026-03-30 01:42:09 +08:00
parent 61303635ad
commit 24498c2717
9 changed files with 220 additions and 208 deletions
@@ -33,32 +33,22 @@ using System.Threading.Tasks;
namespace StgSharp.HighPerformance.Memory
{
[Flags]
public enum PredictResult
{
Success = 1,
Exhausted = 2,
}
public interface IL4Predict
{
bool IsExhausted { get; }
PredictResult Predict(Span<CacheLinePrediction> node, out int count);
/// <summary>
/// Writes predicted cache line descriptors into <paramref name="node" />.
/// </summary>
/// <param name="node">
/// Prediction output buffer.
/// </param>
/// <param name="count">
/// When this method returns, contains the number of valid entries written to <paramref ///
/// name="node" />. The value must not exceed <paramref name="node" />.Length.
/// </param>
/// <returns>
/// <see langword="true" /> if any prediction data was produced; otherwise, <see langword="false"
/// />.
/// </returns>
bool Predict(
Span<CacheLinePrediction> node,
out int count
);
/// <summary>
/// Materializes the cache line identified by <paramref name="origin" /> into <paramref ///
/// Materializes the cache line identified by <paramref name="origin" /> into <paramref /// ///
/// name="cache" />.
/// </summary>
/// <param name="origin">
@@ -70,11 +60,7 @@ namespace StgSharp.HighPerformance.Memory
/// <param name="cache">
/// Destination cache line buffer.
/// </param>
void Prefetch(
nuint origin,
ulong policy,
Span<byte> cache
);
void Prefetch(nuint origin, ulong policy, Span<byte> cache);
/// <summary>
/// Writes the cache line in <paramref name="cache" /> back to <paramref name="origin" />.
@@ -88,32 +74,24 @@ namespace StgSharp.HighPerformance.Memory
/// <param name="cache">
/// Source cache line buffer.
/// </param>
void WriteBack(
nuint origin,
ulong policy,
ReadOnlySpan<byte> cache
);
void WriteBack(nuint origin, ulong policy, ReadOnlySpan<byte> cache);
}
public struct CacheLinePrediction : IEquatable<CacheLinePrediction>
{
public override readonly bool Equals(
object? obj
)
public override readonly bool Equals(object? obj)
{
return obj is CacheLinePrediction prediction &&
return (obj is CacheLinePrediction prediction) &&
Address.Equals(prediction.Address) &&
MapPolicy == prediction.MapPolicy;
(MapPolicy == prediction.MapPolicy);
}
public readonly bool Equals(
CacheLinePrediction other
)
public readonly bool Equals(CacheLinePrediction other)
{
return
Address == other.Address && MapPolicy == other.MapPolicy;
(Address == other.Address) && (MapPolicy == other.MapPolicy);
}
public override readonly int GetHashCode()
@@ -121,17 +99,11 @@ namespace StgSharp.HighPerformance.Memory
return HashCode.Combine(Address, MapPolicy);
}
public static bool operator !=(
CacheLinePrediction left,
CacheLinePrediction right
)
public static bool operator !=(CacheLinePrediction left, CacheLinePrediction right)
{
return !(left == right);
}
public static bool operator ==(
CacheLinePrediction left,
CacheLinePrediction right
)
public static bool operator ==(CacheLinePrediction left, CacheLinePrediction right)
{
return left.Equals(right);
}