Aetheria/Assets/Scripts/NIH/LinqFaster/Utils/CustomPartition.cs
hyperion51 c58ba0b1da Copy Aetheria Code
Added a bunch of code from the old Aetheria project
2020-02-27 18:51:07 +00:00

38 lines
No EOL
1 KiB
C#

#if !(UNITY_4 || UNITY_5)
using System;
using System.Collections.Concurrent;
namespace JM.LinqFaster.Utils
{
internal static class CustomPartition
{
public static OrderablePartitioner<Tuple<int,int>> MakePartition(int len, int? batchSize)
{
if (batchSize == null)
{
return Partitioner.Create(0, len);
}
else
{
return Partitioner.Create(0, len, batchSize.Value);
}
}
public static OrderablePartitioner<Tuple<int, int>> MakeSIMDPartition(int len, int chunkSize, int? batchSize)
{
int chunkLen = len - len % chunkSize;
int numChunks = chunkLen / chunkSize;
if (batchSize == null)
{
return Partitioner.Create(0, numChunks,numChunks/Environment.ProcessorCount);
}
else
{
return Partitioner.Create(0, numChunks, batchSize.Value);
}
}
}
}
#endif