L4 completely add support for multi predictor, working on ver 5 mat para
This commit is contained in:
@@ -62,29 +62,38 @@ namespace StgSharp.HighPerformance.Memory
|
||||
int remain = count;
|
||||
Vector128<byte> three = Vector128.Create((byte)0x03);
|
||||
byte* p = (byte*)_eviction;
|
||||
for (int i = 0; (i < CacheLineCount) && (remain > 0); i += 16)
|
||||
_predictors.RequestSpanOperation();
|
||||
Span<IL4Predict> pSpan = _predictors.AsSpan();
|
||||
try
|
||||
{
|
||||
int evictMask = _intrinsic.ScanEvict(p + i, three);
|
||||
while ((evictMask != 0) && (remain > 0))
|
||||
for (int i = 0; (i < CacheLineCount) && (remain > 0); i += 16)
|
||||
{
|
||||
int bitPos = BitOperations.TrailingZeroCount(evictMask);
|
||||
int index = bitPos + i;
|
||||
CacheLineHead* head = &_head[index];
|
||||
if (Interlocked.CompareExchange(ref head->_refCount, int.MinValue, 0) == 0)
|
||||
int evictMask = _intrinsic.ScanEvict(p + i, three);
|
||||
while ((evictMask != 0) && (remain > 0))
|
||||
{
|
||||
// EvictLine(i + index);
|
||||
_ = _map.TryRemove(head->_origin, out _);
|
||||
int id = (int)head->_predictor;
|
||||
IL4Predict predict = _predictions[id] ??
|
||||
throw new L4PredictUnregisteredException(id);
|
||||
predict.WriteBack(head->_origin, head->_profile, new ReadOnlySpan<byte>((byte*)head->_address, Unsafe.SizeOf<CacheLineData>()));
|
||||
RecycleLine(index);
|
||||
remain--;
|
||||
int bitPos = BitOperations.TrailingZeroCount(evictMask);
|
||||
int index = bitPos + i;
|
||||
CacheLineHead* head = &_head[index];
|
||||
if (Interlocked.CompareExchange(ref head->_refCount, int.MinValue, 0) == 0)
|
||||
{
|
||||
// EvictLine(i + index);
|
||||
_ = _map.TryRemove(head->_origin, out _);
|
||||
int id = (int)head->_predictor;
|
||||
IL4Predict predict = pSpan[id] ??
|
||||
throw new L4PredictUnregisteredException(id);
|
||||
predict.WriteBack(head->_origin, head->_profile, new ReadOnlySpan<byte>((byte*)head->_address, Unsafe.SizeOf<CacheLineData>()));
|
||||
RecycleLine(index);
|
||||
remain--;
|
||||
}
|
||||
evictMask &= evictMask - 1;
|
||||
}
|
||||
evictMask &= evictMask - 1;
|
||||
}
|
||||
return remain;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_predictors.ReleaseSpanOperation();
|
||||
}
|
||||
return remain;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
Reference in New Issue
Block a user