device

package
v0.0.0-...-47d56ae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2020 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 8 more Imports: 5 Imported by: 0

Documentation

Overview

* Tencent is pleased to support the open source community by making TKEStack available. * * Copyright (C) 2012-2019 Tencent. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at * * https://opensource.org/licenses/Apache-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License.

* Tencent is pleased to support the open source community by making TKEStack available. * * Copyright (C) 2012-2019 Tencent. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at * * https://opensource.org/licenses/Apache-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License.

* Tencent is pleased to support the open source community by making TKEStack available. * * Copyright (C) 2012-2019 Tencent. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at * * https://opensource.org/licenses/Apache-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ByAllocatableCores compares two device or node by allocatable cores
	ByAllocatableCores = func(p1, p2 interface{}) bool {
		var result bool
		switch p1.(type) {
		case *DeviceInfo:
			d1 := p1.(*DeviceInfo)
			d2 := p2.(*DeviceInfo)
			result = d1.AllocatableCores() < d2.AllocatableCores()
		case *NodeInfo:
			n1 := p1.(*NodeInfo)
			n2 := p2.(*NodeInfo)
			result = n1.GetAvailableCore() < n2.GetAvailableCore()
		}
		return result
	}

	// ByAllocatableMemory compares two device or node by allocatable memory
	ByAllocatableMemory = func(p1, p2 interface{}) bool {
		var result bool
		switch p1.(type) {
		case *DeviceInfo:
			d1 := p1.(*DeviceInfo)
			d2 := p2.(*DeviceInfo)
			result = d1.AllocatableMemory() < d2.AllocatableMemory()
		case *NodeInfo:
			n1 := p1.(*NodeInfo)
			n2 := p2.(*NodeInfo)
			result = n1.GetAvailableMemory() < n2.GetAvailableMemory()
		}
		return result
	}

	ByID = func(p1, p2 interface{}) bool {
		var result bool
		switch p1.(type) {
		case *DeviceInfo:
			d1 := p1.(*DeviceInfo)
			d2 := p2.(*DeviceInfo)
			result = d1.GetID() < d2.GetID()
		case *NodeInfo:
			n1 := p1.(*NodeInfo)
			n2 := p2.(*NodeInfo)
			result = n1.GetName() < n2.GetName()
		}
		return result
	}
)

Functions

func NodeInfoSort

func NodeInfoSort(less ...LessFunc) *nodeInfoPriority

Types

type DeviceInfo

type DeviceInfo struct {
	// contains filtered or unexported fields
}

func (*DeviceInfo) AddUsedResources

func (dev *DeviceInfo) AddUsedResources(usedCore uint, usedMemory uint) error

AddUsedResources records the used GPU core and memory

func (*DeviceInfo) AllocatableCores

func (d *DeviceInfo) AllocatableCores() uint

AllocatableCores returns the remaining cores of this GPU device

func (*DeviceInfo) AllocatableMemory

func (d *DeviceInfo) AllocatableMemory() uint

AllocatableMemory returns the remaining memory of this GPU device

func (*DeviceInfo) GetID

func (dev *DeviceInfo) GetID() int

GetID returns the idx of this device

type LessFunc

type LessFunc func(p1, p2 interface{}) bool

LessFunc represents funcion to compare two DeviceInfo or NodeInfo

type NodeInfo

type NodeInfo struct {
	// contains filtered or unexported fields
}

func NewNodeInfo

func NewNodeInfo(node *v1.Node, pods []*v1.Pod) *NodeInfo

func (*NodeInfo) AddUsedResources

func (n *NodeInfo) AddUsedResources(devID int, vcore uint, vmemory uint) error

AddUsedResources records the used GPU core and memory

func (*NodeInfo) GetAvailableCore

func (n *NodeInfo) GetAvailableCore() int

GetAvailableCore returns the remaining cores of this node

func (*NodeInfo) GetAvailableMemory

func (n *NodeInfo) GetAvailableMemory() int

GetAvailableMemory returns the remaining memory of this node

func (*NodeInfo) GetDeviceCount

func (n *NodeInfo) GetDeviceCount() int

GetDeviceCount returns the number of GPU devices

func (*NodeInfo) GetDeviceMap

func (n *NodeInfo) GetDeviceMap() map[int]*DeviceInfo

GetDeviceMap returns each GPU device information structure

func (*NodeInfo) GetName

func (n *NodeInfo) GetName() string

GetName returns node name

func (*NodeInfo) GetNode

func (n *NodeInfo) GetNode() *v1.Node

GetNode returns the original node structure of kubernetes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL