HLSf use nuint rather than long, L4 now uses hlsf rather than array to alloc cache line.
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="HLSFAllocator.Level"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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
|
||||
@@ -33,23 +33,38 @@ using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Mathematics.Memory
|
||||
namespace StgSharp.HighPerformance.Memory
|
||||
{
|
||||
public unsafe partial class HybridLayerSegregatedFitAllocator
|
||||
{
|
||||
|
||||
private const int MaxLevel = 9;
|
||||
|
||||
private int[] _levelSizeArray = [64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216];
|
||||
private uint[] _levelSizeArray = [
|
||||
64U,
|
||||
256U,
|
||||
1024U,
|
||||
4096U,
|
||||
16384U,
|
||||
65536U,
|
||||
262144U,
|
||||
1048576U,
|
||||
4194304U,
|
||||
16777216U
|
||||
];
|
||||
|
||||
public int AlignOfLevel(int bucketLevel)
|
||||
public int AlignOfLevel(
|
||||
int bucketLevel
|
||||
)
|
||||
{
|
||||
int blockSize = _levelSizeArray[bucketLevel];
|
||||
return int.Min(blockSize, _align);
|
||||
uint blockSize = _levelSizeArray[bucketLevel];
|
||||
return Math.Min((int)blockSize, _align);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static int GetLevelFromSize(long size)
|
||||
private static int GetLevelFromSize(
|
||||
nuint size
|
||||
)
|
||||
{
|
||||
/*
|
||||
* Level sizes: [64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, ......]
|
||||
@@ -72,7 +87,9 @@ namespace StgSharp.Mathematics.Memory
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static int GetLevelFromSize(uint size)
|
||||
private static int GetLevelFromSize(
|
||||
uint size
|
||||
)
|
||||
{
|
||||
return GetLevelFromSize(size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user