func (cs *supply) GrantedShared() int {
	return cs.grantedShared
}
GrantedShared returns the locally granted sharable CPU capacity.
package topologyaware
import (
	"fmt"
	"strconv"
	"time"
	v1 "k8s.io/api/core/v1"
	"k8s.io/kubernetes/pkg/kubelet/cm/cpuset"
	"github.com/intel/cri-resource-manager/pkg/cpuallocator"
	"github.com/intel/cri-resource-manager/pkg/cri/resource-manager/cache"
	"github.com/intel/cri-resource-manager/pkg/cri/resource-manager/kubernetes"
	idset "github.com/intel/goresctrl/pkg/utils"
)
type Supply interface {
	GetNode() Node
	Clone() Supply
	IsolatedCPUs() cpuset.CPUSet
	ReservedCPUs() cpuset.CPUSet
	SharableCPUs() cpuset.CPUSet
	GrantedReserved() int
	GrantedShared() int
	GrantedMemory(memoryType) uint64
	Cumulate(Supply)
	AssignMemory(mem memoryMap)
	AccountAllocateCPU(Grant)
	AccountReleaseCPU(Grant)
	GetScore(Request) Score
	AllocatableSharedCPU(...bool) int
	Allocate(Request) (Grant, error)
	ReleaseCPU(Grant)
	ReleaseMemory(Grant)
	ReallocateMemory(Grant) error
	ExtraMemoryReservation(memoryType) uint64
	SetExtraMemoryReservation(Grant)
	ReleaseExtraMemoryReservation(Grant)
	MemoryLimit() memoryMap
	Reserve(Grant) error
	ReserveMemory(Grant) error
	DumpCapacity() string
	DumpAllocatable() string
	DumpMemoryState(string)
}
type Request interface {
	GetContainer() cache.Container
	String() string
	CPUType() cpuClass
	SetCPUType(cpuType cpuClass)
	FullCPUs() int
	CPUFraction() int
	Isolate() bool
	MemoryType() memoryType
	MemAmountToAllocate() uint64
	ColdStart() time.Duration
}
type Grant interface {
	SetCPUPortion(fraction int)
	SetMemoryAllocation(memoryType, memoryMap, time.Duration)
	Clone() Grant
	RefetchNodes() error
	GetContainer() cache.Container
	GetCPUNode() Node
	GetMemoryNode() Node
	CPUType() cpuClass
	CPUPortion() int
	ExclusiveCPUs() cpuset.CPUSet
	ReservedCPUs() cpuset.CPUSet
	ReservedPortion() int
	SharedCPUs() cpuset.CPUSet
	SharedPortion() int
	IsolatedCPUs() cpuset.CPUSet
	MemoryType() memoryType
	SetMemoryNode(Node)
	Memset() idset.IDSet
	ExpandMemset() (bool, error)
	MemLimit() memoryMap
	String() string
	Release()
	AccountAllocateCPU()
	AccountReleaseCPU()
	UpdateExtraMemoryReservation()
	RestoreMemset()
	ColdStart() time.Duration
	AddTimer(*time.Timer)
	StopTimer()
	ClearTimer()
}
type Score interface {
	Eval() float64
	Supply() Supply
	Request() Request
	IsolatedCapacity() int
	ReservedCapacity() int
	SharedCapacity() int
	Colocated() int
	HintScores() map[string]float64
	String() string
}
type memoryMap map[memoryType]uint64
type supply struct {
	node                 Node                 
	isolated             cpuset.CPUSet        
	reserved             cpuset.CPUSet        
	sharable             cpuset.CPUSet        
	grantedReserved      int                  
	grantedShared        int                  
	mem                  memoryMap            
	grantedMem           memoryMap            
	extraMemReservations map[Grant]memoryMap  
}
var _ Supply = &supply{}
type request struct {
	container cache.Container  
	full      int              
	fraction  int              
	isolate   bool             
	cpuType   cpuClass         
	memReq  uint64      
	memLim  uint64      
	memType memoryType  
	coldStart time.Duration
}
var _ Request = &request{}
type grant struct {
	container      cache.Container  
	node           Node             
	memoryNode     Node             
	exclusive      cpuset.CPUSet    
	cpuType        cpuClass         
	cpuPortion     int              
	memType        memoryType       
	memset         idset.IDSet      
	allocatedMem   memoryMap        
	coldStart      time.Duration    
	coldStartTimer *time.Timer      
}
var _ Grant = &grant{}
type score struct {
	supply    Supply              
	req       Request             
	isolated  int                 
	reserved  int                 
	shared    int                 
	colocated int                 
	hints     map[string]float64  
}
var _ Score = &score{}
func newSupply(n Node, isolated, reserved, sharable cpuset.CPUSet, grantedReserved int, grantedShared int, mem, grantedMem memoryMap) Supply {
	if mem == nil {
		mem = createMemoryMap(0, 0, 0)
	}
	if grantedMem == nil {
		grantedMem = createMemoryMap(0, 0, 0)
	}
	return &supply{
		node:                 n,
		isolated:             isolated.Clone(),
		reserved:             reserved.Clone(),
		sharable:             sharable.Clone(),
		grantedReserved:      grantedReserved,
		grantedShared:        grantedShared,
		mem:                  mem,
		grantedMem:           grantedMem,
		extraMemReservations: make(map[Grant]memoryMap),
	}
}
func createMemoryMap(dram, pmem, hbm uint64) memoryMap {
	return memoryMap{
		memoryDRAM:   dram,
		memoryPMEM:   pmem,
		memoryHBM:    hbm,
		memoryAll:    dram + pmem + hbm,
		memoryUnspec: 0,
	}
}
func (m memoryMap) Add(dram, pmem, hbm uint64) {
	m[memoryDRAM] += dram
	m[memoryPMEM] += pmem
	m[memoryPMEM] += hbm
	m[memoryAll] += dram + pmem + hbm
}
func (m memoryMap) AddDRAM(dram uint64) {
	m[memoryDRAM] += dram
	m[memoryAll] += dram
}
func (m memoryMap) AddPMEM(pmem uint64) {
	m[memoryPMEM] += pmem
	m[memoryAll] += pmem
}
func (m memoryMap) AddHBM(hbm uint64) {
	m[memoryHBM] += hbm
	m[memoryAll] += hbm
}
func (m memoryMap) String() string {
	mem, sep := "", ""
	dram, pmem, hbm, types := m[memoryDRAM], m[memoryPMEM], m[memoryHBM], 0
	if dram > 0 || pmem > 0 || hbm > 0 {
		if dram > 0 {
			mem += "DRAM " + prettyMem(dram)
			sep = ", "
			types++
		}
		if pmem > 0 {
			mem += sep + "PMEM " + prettyMem(pmem)
			sep = ", "
			types++
		}
		if hbm > 0 {
			mem += sep + "HBM " + prettyMem(hbm)
			types++
		}
		if types > 1 {
			mem += sep + "total " + prettyMem(pmem+dram+hbm)
		}
	}
	return mem
}
func (cs *supply) GetNode() Node {
	return cs.node
}
func (cs *supply) Clone() Supply {
	mem := make(memoryMap)
	for key, value := range cs.mem {
		mem[key] = value
	}
	grantedMem := make(memoryMap)
	for key, value := range cs.grantedMem {
		grantedMem[key] = value
	}
	return newSupply(cs.node, cs.isolated, cs.reserved, cs.sharable, cs.grantedReserved, cs.grantedShared, mem, grantedMem)
}
func (cs *supply) IsolatedCPUs() cpuset.CPUSet {
	return cs.isolated.Clone()
}
func (cs *supply) ReservedCPUs() cpuset.CPUSet {
	return cs.reserved.Clone()
}
func (cs *supply) SharableCPUs() cpuset.CPUSet {
	return cs.sharable.Clone()
}
func (cs *supply) GrantedReserved() int {
	return cs.grantedReserved
}