github.com/lrita/numa@v1.0.2/numa_other.go (about)

     1  // +build !linux
     2  
     3  package numa
     4  
     5  import (
     6  	"runtime"
     7  	"syscall"
     8  	"unsafe"
     9  )
    10  
    11  func init() {
    12  	// only used for cross-compile
    13  	nnodemax = 1
    14  	memnodes = NewBitmask(NodePossibleCount())
    15  	numanodes = NewBitmask(NodePossibleCount())
    16  	nconfigurednode = setupconfigurednodes()
    17  
    18  	memnodes.Set(0, true)
    19  	numanodes.Set(0, true)
    20  
    21  	ncpumax = runtime.NumCPU()
    22  	nconfiguredcpu = runtime.NumCPU()
    23  
    24  	cpu2node = make(map[int]int, ncpumax)
    25  	for i := 0; i < ncpumax; i++ {
    26  		cpu2node[i] = 0
    27  	}
    28  	cpumask := NewBitmask(nconfiguredcpu)
    29  	for i := 0; i < nconfiguredcpu; i++ {
    30  		cpumask.Set(i, true)
    31  	}
    32  	node2cpu = map[int]Bitmask{0: cpumask}
    33  }
    34  
    35  func setupconfigurednodes() (n int) {
    36  	for i := 0; i < NodePossibleCount(); i++ {
    37  		numanodes.Set(i, true)
    38  		memnodes.Set(i, true)
    39  	}
    40  	return NodePossibleCount()
    41  }
    42  
    43  // GetMemPolicy retrieves the NUMA policy of the calling process or of a
    44  // memory address, depending on the setting of flags.
    45  func GetMemPolicy(nodemask Bitmask, addr unsafe.Pointer, flags int) (mode int, err error) {
    46  	return 0, syscall.ENOSYS
    47  }
    48  
    49  // SetMemPolicy sets the NUMA memory policy of the calling process, which
    50  // consists of a policy mode and zero or more nodes, to the values specified
    51  // by the mode, nodemask and maxnode arguments.
    52  func SetMemPolicy(mode int, nodemask Bitmask) error {
    53  	return syscall.ENOSYS
    54  }
    55  
    56  // NodeMemSize64 return the memory total size and free size of given node.
    57  func NodeMemSize64(node int) (total int64, free int64, err error) {
    58  	return 0, 0, syscall.ENOSYS
    59  }
    60  
    61  // MBind sets the NUMA memory policy, which consists of a policy mode and zero
    62  // or more nodes, for the memory range starting with addr and continuing for
    63  // length bytes. The memory policy defines from which node memory is allocated.
    64  // Details to see manpage of mbind.
    65  func MBind(addr unsafe.Pointer, length, mode, flags int, nodemask Bitmask) error {
    66  	return syscall.ENOSYS
    67  }
    68  
    69  // GetSchedAffinity writes the affinity mask of the process whose ID is pid
    70  // into the input mask. If pid is zero, then the mask of the calling process
    71  // is returned.
    72  func GetSchedAffinity(pid int, cpumask Bitmask) (int, error) {
    73  	return 0, syscall.ENOSYS
    74  }
    75  
    76  // SetSchedAffinity sets the CPU affinity mask of the process whose ID
    77  // is pid to the value specified by mask. If pid is zero, then the calling
    78  // process is used.
    79  func SetSchedAffinity(pid int, cpumask Bitmask) error {
    80  	return syscall.ENOSYS
    81  }
    82  
    83  // GetCPUAndNode returns the node id and cpu id which current caller running on.
    84  func GetCPUAndNode() (cpu int, node int) {
    85  	cpu = runtime_procPin()
    86  	runtime_procUnpin()
    87  	return cpu % ncpumax, nnodemax - 1
    88  }
    89  
    90  // Implemented in runtime.
    91  
    92  //go:linkname runtime_procPin runtime.procPin
    93  //go:nosplit
    94  func runtime_procPin() int
    95  
    96  //go:linkname runtime_procUnpin runtime.procUnpin
    97  //go:nosplit
    98  func runtime_procUnpin()