Interface OSNuma

All Known Implementing Classes:
LinuxNuma, OSNuma.NoOp, OSNuma.PreCalculatedNuma

public interface OSNuma
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
     
    static class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    getCores(int numaId)
    Returns the cores associated with the specified NUMA node.
    int
    Returns the current core that this thread is running on.
    int
    Returns the current NUMA node that this thread is running on.
    long[]
    Returns the current thread's affinity mask.
    static OSNuma
     
    int[][]
    Returns an N by N array where cost[i][j] = getNumaDistance(i,j)
    int
    getNumaDistance(int n1, int n2)
    Returns the distance between the specified NUMA nodes.
    int
    getNumaNode(int coreId)
    Returns the NUMA node associated with the specified core.
    int
    Returns the total number of cores on the system.
    int
    Returns the total number of nodes on the system.
    boolean
    Returns whether interaction with the OS for NUMA is available.
    default void
    setCurrentNumaAffinity(int[] numaNodes)
    Attempts to adjust the current thread's NUMA affinity mask to the specified list of numa nodes.
    default void
    Attempts to adjust the current thread's NUMA affinity mask to the specified bitset.
    void
    Attempts to adjust the current thread's affinity mask to the specified bitset.
  • Method Details

    • getNativeInstance

      static OSNuma getNativeInstance()
    • isAvailable

      boolean isAvailable()
      Returns whether interaction with the OS for NUMA is available. If no interaction is available, then the following applies:
      Returns:
      Whether there exists native support to retrieve NUMA information and set scheduling affinity.
    • getNumaDistance

      int getNumaDistance(int n1, int n2)
      Returns the distance between the specified NUMA nodes. The return values are defined by the ACPI SLIT table present on the system.
      Parameters:
      n1 - First node
      n2 - Second node
      Returns:
      The distance between the NUMA nodes.
      See Also:
    • getTotalNumaNodes

      int getTotalNumaNodes()
      Returns the total number of nodes on the system.
      Returns:
      The total number of nodes on the system.
    • getNodeDistances

      int[][] getNodeDistances()
      Returns an N by N array where cost[i][j] = getNumaDistance(i,j)
      Returns:
      The node distance matrix.
      See Also:
    • getNumaNode

      int getNumaNode(int coreId)
      Returns the NUMA node associated with the specified core. If the core is not valid, then returns -1.
      Parameters:
      coreId - The specified core
      Returns:
      The NUMA node for the core.
    • getTotalCores

      int getTotalCores()
      Returns the total number of cores on the system.
      Returns:
      The total number of cores on the system.
    • getCores

      int[] getCores(int numaId)
      Returns the cores associated with the specified NUMA node. If the node is not valid, then returns null.

      Note that the returned array is not a bitset. It is simply a list of core numbers.

      Parameters:
      numaId - The specified NUMA node.
      Returns:
      The cores associated with the specified NUMA node.
    • getCurrentNumaNode

      int getCurrentNumaNode()
      Returns the current NUMA node that this thread is running on. If NUMA interaction is not available, then 0 will be returned.
      Returns:
      The current NUMA node that this thread is running on
    • getCurrentCore

      int getCurrentCore()
      Returns the current core that this thread is running on. If NUMA interaction is not available, then 0 will be returned.
      Returns:
      The current core this thread is running on
      See Also:
    • getCurrentThreadAffinity

      long[] getCurrentThreadAffinity()
      Returns the current thread's affinity mask. If NUMA interaction is not available, then this function will return an undefined result.
      Returns:
      The current thread's affinity mask.
      See Also:
    • setCurrentThreadAffinity

      void setCurrentThreadAffinity(long[] to)
      Attempts to adjust the current thread's affinity mask to the specified bitset. If NUMA interaction is not available, then this function is a no-op.
      Parameters:
      to - Specified new affinity bitmask.
      See Also:
    • setCurrentNumaAffinity

      default void setCurrentNumaAffinity(long[] to)
      Attempts to adjust the current thread's NUMA affinity mask to the specified bitset. This is equivalent to invoking setCurrentThreadAffinity(long[]) with a bitmask specifying all cores present in the specified NUMA nodes. If NUMA interaction is not available, then this function is a no-op.
      Parameters:
      to - Specified new NUMA affinity bitmask.
      See Also:
    • setCurrentNumaAffinity

      default void setCurrentNumaAffinity(int[] numaNodes)
      Attempts to adjust the current thread's NUMA affinity mask to the specified list of numa nodes. This is equivalent to invoking setCurrentThreadAffinity(long[]) with a bitmask specifying all cores present in the specified NUMA nodes. If NUMA interaction is not available, then this function is a no-op.
      Parameters:
      numaNodes - Specified new NUMA nodes.
      See Also: