Table of Contents

Class CpuUtilities

Namespace
DotCompute.Backends.CPU.Threading.NUMA
Assembly
DotCompute.Backends.CPU.dll

Utility methods for CPU and NUMA operations.

public static class CpuUtilities
Inheritance
CpuUtilities
Inherited Members

Methods

CountSetBits(ulong)

Counts the number of set bits in a processor mask.

public static int CountSetBits(ulong mask)

Parameters

mask ulong

The processor mask.

Returns

int

Number of set bits.

CreateCpuMask(int, int)

Creates a CPU mask for a range of processors.

public static ulong CreateCpuMask(int startCpu, int endCpu)

Parameters

startCpu int

Start CPU index.

endCpu int

End CPU index.

Returns

ulong

CPU mask with specified range set.

EstimateOptimalThreadCount(NumaNode, WorkloadType)

Estimates the optimal number of threads for a workload on a given node.

public static int EstimateOptimalThreadCount(NumaNode node, WorkloadType workloadType)

Parameters

node NumaNode

NUMA node information.

workloadType WorkloadType

Type of workload (CPU-bound, I/O-bound, etc.).

Returns

int

Optimal thread count.

ParseCpuList(string)

Parses a CPU list string (e.g., "0-3,8-11") into a mask and count.

public static (ulong mask, int count) ParseCpuList(string cpuList)

Parameters

cpuList string

CPU list string.

Returns

(ulong mask, int count)

Tuple of CPU mask and count.

ParseCpuMask(string, out ulong, out int)

Parses a CPU mask string (e.g., "00000000,00000fff") into a mask and count.

public static bool ParseCpuMask(string cpuMap, out ulong cpuMask, out int cpuCount)

Parameters

cpuMap string

CPU mask string.

cpuMask ulong

Parsed CPU mask.

cpuCount int

Number of CPUs in mask.

Returns

bool

True if parsing succeeded.

ParseFirstCpu(string)

Gets the first CPU ID from a CPU list string.

public static int ParseFirstCpu(string cpuList)

Parameters

cpuList string

CPU list string.

Returns

int

First CPU ID or -1 if not found.