L4 is now on new algo, using tricky way to init entryies
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
//
|
//
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using Hlsf = StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator;
|
using Hlsf = StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator;
|
||||||
@@ -55,12 +56,13 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
{
|
{
|
||||||
|
|
||||||
[FieldOffset(0)] internal Hlsf.Entry AllocatorEntry;
|
[FieldOffset(0)] internal Hlsf.Entry AllocatorEntry;
|
||||||
|
[FieldOffset(0)] internal readonly M512 Buffer;
|
||||||
|
|
||||||
#region reference counting and state information
|
#region reference counting and state information
|
||||||
|
|
||||||
[FieldOffset(52)] internal int RefCount;
|
[FieldOffset(52)] internal int RefCount;
|
||||||
[FieldOffset(60)] private readonly int Reverse;
|
[FieldOffset(60)] private readonly int Reverse;
|
||||||
[FieldOffset(56)] internal int Id;
|
[FieldOffset(56)] internal readonly int Id;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -137,12 +137,14 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
head = _head + index;
|
head = _head + index;
|
||||||
head->Id = index;
|
|
||||||
head->Origin = address;
|
head->Origin = address;
|
||||||
head->Profile = pHandle.MapPolicy;
|
head->Profile = pHandle.MapPolicy;
|
||||||
head->RefCount = 0;
|
head->RefCount = 0;
|
||||||
head->Predictor = (short)predictIndex;
|
head->Predictor = (short)predictIndex;
|
||||||
|
|
||||||
|
(*_predictCount)[index] = 1;
|
||||||
|
(*_mapCount)[index] = 1;
|
||||||
|
|
||||||
// pre fetch them here
|
// pre fetch them here
|
||||||
predict.Prefetch(head->Origin, head->Profile, new Span<byte>((byte*)head->Address, (int)head->Size));
|
predict.Prefetch(head->Origin, head->Profile, new Span<byte>((byte*)head->Address, (int)head->Size));
|
||||||
_ = _map.TryAddOrSet(address, (nuint)head, out _);
|
_ = _map.TryAddOrSet(address, (nuint)head, out _);
|
||||||
|
|||||||
@@ -103,6 +103,11 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
ptr += predictionCountSize;
|
ptr += predictionCountSize;
|
||||||
_mapCount = (MapArray*)ptr;
|
_mapCount = (MapArray*)ptr;
|
||||||
ptr += predictionCountSize;
|
ptr += predictionCountSize;
|
||||||
|
|
||||||
|
M512* mPtr = (M512*)_head;
|
||||||
|
for (uint i = 0; i < CacheLineCount; i++) {
|
||||||
|
mPtr->BroadCastFrom<ulong>(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public nuint ByteCapacity { get; init; }
|
public nuint ByteCapacity { get; init; }
|
||||||
|
|||||||
@@ -42,7 +42,13 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
{
|
{
|
||||||
|
|
||||||
[FieldOffset(0)] private fixed byte _buffer[64];
|
[FieldOffset(0)] private fixed byte _buffer[64];
|
||||||
[FieldOffset(0)] private Vector512<float> Vec;
|
[FieldOffset(0)] private Vector512<byte> Vec;
|
||||||
|
|
||||||
|
public M512()
|
||||||
|
{
|
||||||
|
Unsafe.SkipInit(out this);
|
||||||
|
Unsafe.SkipInit(out Vec);
|
||||||
|
}
|
||||||
|
|
||||||
public ref T AsRef<T>() where T : unmanaged, INumber<T>
|
public ref T AsRef<T>() where T : unmanaged, INumber<T>
|
||||||
{
|
{
|
||||||
@@ -53,7 +59,7 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
T value
|
T value
|
||||||
) where T : unmanaged, INumber<T>
|
) where T : unmanaged, INumber<T>
|
||||||
{
|
{
|
||||||
Vec = Vector512.Create(value).AsSingle();
|
Vec = Vector512.Create(value).AsByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ref T Member<T>(
|
public ref T Member<T>(
|
||||||
|
|||||||
Reference in New Issue
Block a user