Better FMA
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="HlsfAllocatorBench"
|
||||
// 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
|
||||
@@ -27,6 +27,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using StgSharp.Mathematics.Memory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Benchmark
|
||||
@@ -40,7 +42,15 @@ namespace StgSharp.Benchmark
|
||||
|
||||
private const int AllocationCount = 2048;
|
||||
|
||||
private static readonly int[] AllocSizes = [64, 96, 150, 200, 400, 1024, 4096];
|
||||
private static readonly int[] AllocSizes = [
|
||||
64,
|
||||
96,
|
||||
150,
|
||||
200,
|
||||
400,
|
||||
1024,
|
||||
4096
|
||||
];
|
||||
private HybridLayerSegregatedFitAllocator _hlsfAllocator = null!;
|
||||
private readonly List<HybridLayerSegregatedFitAllocationHandle> _hlsfLocalList = new();
|
||||
private readonly List<nint> _libcLocalList = new();
|
||||
@@ -96,7 +106,9 @@ namespace StgSharp.Benchmark
|
||||
_hlsfAllocator = new HybridLayerSegregatedFitAllocator(GetArenaBytes(), align:(int)Alignment);
|
||||
}
|
||||
|
||||
private static uint AlignSize(uint size)
|
||||
private static uint AlignSize(
|
||||
uint size
|
||||
)
|
||||
{
|
||||
uint mask = Alignment - 1;
|
||||
return (size + mask) & ~mask;
|
||||
@@ -109,7 +121,9 @@ namespace StgSharp.Benchmark
|
||||
int mb = defaultMb;
|
||||
|
||||
string? env = Environment.GetEnvironmentVariable("HLSF_BENCH_ARENA_MB");
|
||||
if (!string.IsNullOrWhiteSpace(env) && int.TryParse(env, out int parsed) && parsed >= minMb) {
|
||||
if (!string.IsNullOrWhiteSpace(env) &&
|
||||
int.TryParse(env, out int parsed) &&
|
||||
parsed >= minMb) {
|
||||
mb = parsed;
|
||||
}
|
||||
|
||||
@@ -118,7 +132,10 @@ namespace StgSharp.Benchmark
|
||||
|
||||
private uint GetNextRandomSize() => (uint)AllocSizes[_random.Next(AllocSizes.Length)];
|
||||
|
||||
private void RunHlsf(HybridLayerSegregatedFitAllocator allocator, FreePolicy policy)
|
||||
private void RunHlsf(
|
||||
HybridLayerSegregatedFitAllocator allocator,
|
||||
FreePolicy policy
|
||||
)
|
||||
{
|
||||
_hlsfLocalList.Clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user