Skip to content

Commit bf8b531

Browse files
authored
Increase max supported affinity from 31 to 64 (#2211) (#2228)
1 parent a6ef739 commit bf8b531

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/BenchmarkDotNet/Extensions/ProcessExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ internal static string ToPresentation(this IntPtr processorAffinity, int process
4545

4646
private static IntPtr FixAffinity(IntPtr processorAffinity)
4747
{
48-
int cpuMask = (1 << Environment.ProcessorCount) - 1;
48+
// Max supported affinity without CPU groups is 64
49+
long cpuMask = Environment.ProcessorCount >= 64 ? unchecked((long)0xFFFF_FFFF_FFFF_FFFF) : (1L << Environment.ProcessorCount) - 1;
4950

5051
return RuntimeInformation.Is64BitPlatform()
5152
? new IntPtr(processorAffinity.ToInt64() & cpuMask)

tests/BenchmarkDotNet.IntegrationTests/ProcessPropertiesTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void Ensure()
6060
{
6161
if (Process.GetCurrentProcess().ProcessorAffinity != Value)
6262
{
63-
throw new InvalidOperationException("Did not set custom affinity");
63+
throw new InvalidOperationException($"Did not set custom affinity {Process.GetCurrentProcess().ProcessorAffinity} != {Value}");
6464
}
6565
}
6666
}

0 commit comments

Comments
 (0)