123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- // Copyright © 2021 Jeffrey H. Johnson <trnsz@pobox.com>.
- // Copyright © 2021 Gridfinity, LLC.
- // Copyright © 2019 Neal.
- // Copyright © 2018 lrita@163.com.
- //
- // Use of this source code is governed by the MIT
- // license that can be found in the LICENSE file.
- //go:build !linux
- // +build !linux
- package gonuma
- import (
- "runtime"
- "syscall"
- "unsafe"
- )
- func init() {
- // only used for cross-compile
- NUMAnodemax = 1
- memnodes = NewBitmask(NodePossibleCount())
- numanodes = NewBitmask(NodePossibleCount())
- NUMAconfigurednode = setupconfigurednodes()
- memnodes.Set(0, true)
- numanodes.Set(0, true)
- NUMAcpuMax = runtime.NumCPU()
- NUMAconfiguredcpu = runtime.NumCPU()
- cpu2node = make(map[int]int, NUMAcpuMax)
- for i := 0; i < NUMAcpuMax; i++ {
- cpu2node[i] = 0
- }
- cpumask := NewBitmask(NUMAconfiguredcpu)
- for i := 0; i < NUMAconfiguredcpu; i++ {
- cpumask.Set(i, true)
- }
- node2cpu = map[int]Bitmask{0: cpumask}
- }
- func setupconfigurednodes() (n int) {
- for i := 0; i < NodePossibleCount(); i++ {
- numanodes.Set(i, true)
- memnodes.Set(i, true)
- }
- return NodePossibleCount()
- }
- // GetMemPolicy retrieves the NUMA policy of the calling process or of a
- // memory address, depending on the setting of flags.
- func GetMemPolicy(
- nodemask Bitmask,
- addr unsafe.Pointer,
- flags int,
- ) (mode int, err error) {
- return 0, syscall.ENOSYS
- }
- // SetMemPolicy sets the NUMA memory policy of the calling process, which
- // consists of a policy mode and zero or more nodes, to the values specified
- // by the mode, nodemask and maxnode arguments.
- func SetMemPolicy(mode int, nodemask Bitmask) error {
- return syscall.ENOSYS
- }
- // NodeMemSize64 return the memory total size and free size of given node.
- func NodeMemSize64(node int) (total, free int64, err error) {
- return 0, 0, syscall.ENOSYS
- }
- // MBind sets the NUMA memory policy, which consists of a policy mode and zero
- // or more nodes, for the memory range starting with addr and continuing for
- // length bytes. The policy defines from which node the memory is allocated.
- // For full details, refer to the manpage/documentation of the mbind function.
- func MBind(
- addr unsafe.Pointer,
- length, mode, flags int,
- nodemask Bitmask,
- ) error {
- return syscall.ENOSYS
- }
- // GetSchedAffinity writes the affinity mask of the process whose ID is pid
- // into the input mask. If pid is zero, then the mask of the calling process
- // is returned.
- func GetSchedAffinity(pid int, cpumask Bitmask) (int, error) {
- return 0, syscall.ENOSYS
- }
- // SetSchedAffinity sets the CPU affinity mask of the process whose ID
- // is pid to the value specified by mask. If pid is zero, then the calling
- // process is used.
- func SetSchedAffinity(pid int, cpumask Bitmask) error {
- return syscall.ENOSYS
- }
- // GetCPUAndNode returns the node id and cpu id the caller is running on.
- func GetCPUAndNode() (cpu, node int) {
- cpu = runtimeProcPin()
- runtimeProcUnpin()
- return cpu % NUMAcpuMax, NUMAnodemax - 1
- }
- // Implemented in runtime.
- //go:linkname runtimeProcPin runtime.procPin
- //go:nosplit
- func runtimeProcPin() int
- //go:linkname runtimeProcUnpin runtime.procUnpin
- //go:nosplit
- func runtimeProcUnpin()
|