mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
convert driver to device for device constraint/attributes
This commit is contained in:
@@ -235,14 +235,14 @@ func TestParse(t *testing.T) {
|
||||
Count: helper.Uint64ToPtr(10),
|
||||
Constraints: []*api.Constraint{
|
||||
{
|
||||
LTarget: "${driver.attr.memory}",
|
||||
LTarget: "${device.attr.memory}",
|
||||
RTarget: "2GB",
|
||||
Operand: ">",
|
||||
},
|
||||
},
|
||||
Affinities: []*api.Affinity{
|
||||
{
|
||||
LTarget: "${driver.model}",
|
||||
LTarget: "${device.model}",
|
||||
RTarget: "1080ti",
|
||||
Operand: "=",
|
||||
Weight: 50,
|
||||
|
||||
@@ -200,13 +200,13 @@ job "binstore-storagelocker" {
|
||||
device "nvidia/gpu" {
|
||||
count = 10
|
||||
constraint {
|
||||
attribute = "${driver.attr.memory}"
|
||||
attribute = "${device.attr.memory}"
|
||||
value = "2GB"
|
||||
operator = ">"
|
||||
}
|
||||
|
||||
affinity {
|
||||
attribute = "${driver.model}"
|
||||
attribute = "${device.model}"
|
||||
value = "1080ti"
|
||||
weight = 50
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ func TestDeviceAllocator_Allocate_Constraints(t *testing.T) {
|
||||
Name: "gpu",
|
||||
Constraints: []*structs.Constraint{
|
||||
{
|
||||
LTarget: "${driver.attr.cuda_cores}",
|
||||
LTarget: "${device.attr.cuda_cores}",
|
||||
Operand: ">",
|
||||
RTarget: "4000",
|
||||
},
|
||||
@@ -172,7 +172,7 @@ func TestDeviceAllocator_Allocate_Constraints(t *testing.T) {
|
||||
Name: "gpu",
|
||||
Constraints: []*structs.Constraint{
|
||||
{
|
||||
LTarget: "${driver.attr.cuda_cores}",
|
||||
LTarget: "${device.attr.cuda_cores}",
|
||||
Operand: "<",
|
||||
RTarget: "4000",
|
||||
},
|
||||
@@ -184,17 +184,17 @@ func TestDeviceAllocator_Allocate_Constraints(t *testing.T) {
|
||||
Constraints: []*structs.Constraint{
|
||||
// First two are shared across both devices
|
||||
{
|
||||
LTarget: "${driver.attr.memory_bandwidth}",
|
||||
LTarget: "${device.attr.memory_bandwidth}",
|
||||
Operand: ">",
|
||||
RTarget: "10 GB/s",
|
||||
},
|
||||
{
|
||||
LTarget: "${driver.attr.memory}",
|
||||
LTarget: "${device.attr.memory}",
|
||||
Operand: "is",
|
||||
RTarget: "11264 MiB",
|
||||
},
|
||||
{
|
||||
LTarget: "${driver.attr.graphics_clock}",
|
||||
LTarget: "${device.attr.graphics_clock}",
|
||||
Operand: ">",
|
||||
RTarget: "1.4 GHz",
|
||||
},
|
||||
@@ -209,18 +209,18 @@ func TestDeviceAllocator_Allocate_Constraints(t *testing.T) {
|
||||
Name: "nvidia/gpu",
|
||||
Constraints: []*structs.Constraint{
|
||||
{
|
||||
LTarget: "${driver.attr.memory_bandwidth}",
|
||||
LTarget: "${device.attr.memory_bandwidth}",
|
||||
Operand: ">",
|
||||
RTarget: "10 GB/s",
|
||||
},
|
||||
{
|
||||
LTarget: "${driver.attr.memory}",
|
||||
LTarget: "${device.attr.memory}",
|
||||
Operand: "is",
|
||||
RTarget: "11264 MiB",
|
||||
},
|
||||
// Rules both out
|
||||
{
|
||||
LTarget: "${driver.attr.graphics_clock}",
|
||||
LTarget: "${device.attr.graphics_clock}",
|
||||
Operand: ">",
|
||||
RTarget: "2.4 GHz",
|
||||
},
|
||||
@@ -271,7 +271,7 @@ func TestDeviceAllocator_Allocate_Affinities(t *testing.T) {
|
||||
Name: "gpu",
|
||||
Affinities: []*structs.Affinity{
|
||||
{
|
||||
LTarget: "${driver.attr.cuda_cores}",
|
||||
LTarget: "${device.attr.cuda_cores}",
|
||||
Operand: ">",
|
||||
RTarget: "4000",
|
||||
Weight: 0.6,
|
||||
@@ -283,7 +283,7 @@ func TestDeviceAllocator_Allocate_Affinities(t *testing.T) {
|
||||
Name: "gpu",
|
||||
Affinities: []*structs.Affinity{
|
||||
{
|
||||
LTarget: "${driver.attr.cuda_cores}",
|
||||
LTarget: "${device.attr.cuda_cores}",
|
||||
Operand: "<",
|
||||
RTarget: "4000",
|
||||
Weight: 0.1,
|
||||
@@ -295,7 +295,7 @@ func TestDeviceAllocator_Allocate_Affinities(t *testing.T) {
|
||||
Name: "gpu",
|
||||
Affinities: []*structs.Affinity{
|
||||
{
|
||||
LTarget: "${driver.attr.cuda_cores}",
|
||||
LTarget: "${device.attr.cuda_cores}",
|
||||
Operand: ">",
|
||||
RTarget: "4000",
|
||||
Weight: -0.2,
|
||||
@@ -309,19 +309,19 @@ func TestDeviceAllocator_Allocate_Affinities(t *testing.T) {
|
||||
Affinities: []*structs.Affinity{
|
||||
// First two are shared across both devices
|
||||
{
|
||||
LTarget: "${driver.attr.memory_bandwidth}",
|
||||
LTarget: "${device.attr.memory_bandwidth}",
|
||||
Operand: ">",
|
||||
RTarget: "10 GB/s",
|
||||
Weight: 0.2,
|
||||
},
|
||||
{
|
||||
LTarget: "${driver.attr.memory}",
|
||||
LTarget: "${device.attr.memory}",
|
||||
Operand: "is",
|
||||
RTarget: "11264 MiB",
|
||||
Weight: 0.2,
|
||||
},
|
||||
{
|
||||
LTarget: "${driver.attr.graphics_clock}",
|
||||
LTarget: "${device.attr.graphics_clock}",
|
||||
Operand: ">",
|
||||
RTarget: "1.4 GHz",
|
||||
Weight: 0.9,
|
||||
|
||||
@@ -953,17 +953,17 @@ func resolveDeviceTarget(target string, d *structs.NodeDeviceResource) (*psstruc
|
||||
|
||||
// Handle the interpolations
|
||||
switch {
|
||||
case "${driver.model}" == target:
|
||||
case "${device.model}" == target:
|
||||
return psstructs.NewStringAttribute(d.Name), true
|
||||
|
||||
case "${driver.vendor}" == target:
|
||||
case "${device.vendor}" == target:
|
||||
return psstructs.NewStringAttribute(d.Vendor), true
|
||||
|
||||
case "${driver.type}" == target:
|
||||
case "${device.type}" == target:
|
||||
return psstructs.NewStringAttribute(d.Type), true
|
||||
|
||||
case strings.HasPrefix(target, "${driver.attr."):
|
||||
attr := strings.TrimPrefix(target, "${driver.attr.")
|
||||
case strings.HasPrefix(target, "${device.attr."):
|
||||
attr := strings.TrimPrefix(target, "${device.attr.")
|
||||
attr = strings.TrimSuffix(attr, "}")
|
||||
val, ok := d.Attributes[attr]
|
||||
return val, ok
|
||||
|
||||
@@ -1862,22 +1862,22 @@ func TestDeviceChecker(t *testing.T) {
|
||||
Constraints: []*structs.Constraint{
|
||||
{
|
||||
Operand: "=",
|
||||
LTarget: "${driver.model}",
|
||||
LTarget: "${device.model}",
|
||||
RTarget: "1080ti",
|
||||
},
|
||||
{
|
||||
Operand: ">",
|
||||
LTarget: "${driver.attr.memory}",
|
||||
LTarget: "${device.attr.memory}",
|
||||
RTarget: "1320.5 MB",
|
||||
},
|
||||
{
|
||||
Operand: "<=",
|
||||
LTarget: "${driver.attr.pci_bandwidth}",
|
||||
LTarget: "${device.attr.pci_bandwidth}",
|
||||
RTarget: ".98 GiB/s",
|
||||
},
|
||||
{
|
||||
Operand: "=",
|
||||
LTarget: "${driver.attr.cores_clock}",
|
||||
LTarget: "${device.attr.cores_clock}",
|
||||
RTarget: "800MHz",
|
||||
},
|
||||
},
|
||||
@@ -1895,22 +1895,22 @@ func TestDeviceChecker(t *testing.T) {
|
||||
Constraints: []*structs.Constraint{
|
||||
{
|
||||
Operand: "=",
|
||||
LTarget: "${driver.model}",
|
||||
LTarget: "${device.model}",
|
||||
RTarget: "1080ti",
|
||||
},
|
||||
{
|
||||
Operand: ">",
|
||||
LTarget: "${driver.attr.memory}",
|
||||
LTarget: "${device.attr.memory}",
|
||||
RTarget: "1320.5 MB",
|
||||
},
|
||||
{
|
||||
Operand: "<=",
|
||||
LTarget: "${driver.attr.pci_bandwidth}",
|
||||
LTarget: "${device.attr.pci_bandwidth}",
|
||||
RTarget: ".98 GiB/s",
|
||||
},
|
||||
{
|
||||
Operand: "=",
|
||||
LTarget: "${driver.attr.cores_clock}",
|
||||
LTarget: "${device.attr.cores_clock}",
|
||||
RTarget: "800MHz",
|
||||
},
|
||||
},
|
||||
@@ -1928,22 +1928,22 @@ func TestDeviceChecker(t *testing.T) {
|
||||
Constraints: []*structs.Constraint{
|
||||
{
|
||||
Operand: "=",
|
||||
LTarget: "${driver.model}",
|
||||
LTarget: "${device.model}",
|
||||
RTarget: "1080ti",
|
||||
},
|
||||
{
|
||||
Operand: ">",
|
||||
LTarget: "${driver.attr.memory}",
|
||||
LTarget: "${device.attr.memory}",
|
||||
RTarget: "1320.5 MB",
|
||||
},
|
||||
{
|
||||
Operand: "<=",
|
||||
LTarget: "${driver.attr.pci_bandwidth}",
|
||||
LTarget: "${device.attr.pci_bandwidth}",
|
||||
RTarget: ".98 GiB/s",
|
||||
},
|
||||
{
|
||||
Operand: "=",
|
||||
LTarget: "${driver.attr.cores_clock}",
|
||||
LTarget: "${device.attr.cores_clock}",
|
||||
RTarget: "800MHz",
|
||||
},
|
||||
},
|
||||
@@ -1961,22 +1961,22 @@ func TestDeviceChecker(t *testing.T) {
|
||||
Constraints: []*structs.Constraint{
|
||||
{
|
||||
Operand: "=",
|
||||
LTarget: "${driver.model}",
|
||||
LTarget: "${device.model}",
|
||||
RTarget: "2080ti",
|
||||
},
|
||||
{
|
||||
Operand: ">",
|
||||
LTarget: "${driver.attr.memory}",
|
||||
LTarget: "${device.attr.memory}",
|
||||
RTarget: "1320.5 MB",
|
||||
},
|
||||
{
|
||||
Operand: "<=",
|
||||
LTarget: "${driver.attr.pci_bandwidth}",
|
||||
LTarget: "${device.attr.pci_bandwidth}",
|
||||
RTarget: ".98 GiB/s",
|
||||
},
|
||||
{
|
||||
Operand: "=",
|
||||
LTarget: "${driver.attr.cores_clock}",
|
||||
LTarget: "${device.attr.cores_clock}",
|
||||
RTarget: "800MHz",
|
||||
},
|
||||
},
|
||||
@@ -1994,22 +1994,22 @@ func TestDeviceChecker(t *testing.T) {
|
||||
Constraints: []*structs.Constraint{
|
||||
{
|
||||
Operand: "=",
|
||||
LTarget: "${driver.model}",
|
||||
LTarget: "${device.model}",
|
||||
RTarget: "1080ti",
|
||||
},
|
||||
{
|
||||
Operand: "<",
|
||||
LTarget: "${driver.attr.memory}",
|
||||
LTarget: "${device.attr.memory}",
|
||||
RTarget: "1320.5 MB",
|
||||
},
|
||||
{
|
||||
Operand: "<=",
|
||||
LTarget: "${driver.attr.pci_bandwidth}",
|
||||
LTarget: "${device.attr.pci_bandwidth}",
|
||||
RTarget: ".98 GiB/s",
|
||||
},
|
||||
{
|
||||
Operand: "=",
|
||||
LTarget: "${driver.attr.cores_clock}",
|
||||
LTarget: "${device.attr.cores_clock}",
|
||||
RTarget: "800MHz",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -584,7 +584,7 @@ func TestBinPackIterator_Devices(t *testing.T) {
|
||||
Count: 1,
|
||||
Affinities: []*structs.Affinity{
|
||||
{
|
||||
LTarget: "${driver.attr.graphics_clock}",
|
||||
LTarget: "${device.attr.graphics_clock}",
|
||||
Operand: ">",
|
||||
RTarget: "1.4 GHz",
|
||||
Weight: 0.9,
|
||||
|
||||
Reference in New Issue
Block a user