Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for "real cores" and threads per core #284

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -60,6 +60,8 @@ const (
vcpus = "vcpus"
memory = "memory"
vcpusToMemoryRatio = "vcpus-to-memory-ratio"
defaultCores = "default-cores"
defaultThreadsPerCore = "default-threads-per-core"
cpuArchitecture = "cpu-architecture"
cpuManufacturer = "cpu-manufacturer"
gpus = "gpus"
@@ -164,6 +166,8 @@ Full docs can be found at github.com/aws/amazon-` + binName
// Filter Flags - These will be grouped at the top of the help flags

cli.Int32MinMaxRangeFlags(vcpus, cli.StringMe("c"), nil, "Number of vcpus available to the instance type.")
cli.Int32MinMaxRangeFlags(defaultCores, cli.StringMe("p"), nil, "Number of real cores available to the instance type.")
cli.Int32MinMaxRangeFlags(defaultThreadsPerCore, nil, nil, "Default threads per core (i.e., hyperthreading).")
cli.ByteQuantityMinMaxRangeFlags(memory, cli.StringMe("m"), nil, "Amount of Memory available (Example: 4 GiB)")
cli.RatioFlag(vcpusToMemoryRatio, nil, nil, "The ratio of vcpus to GiBs of memory. (Example: 1:2)")
cli.StringOptionsFlag(cpuArchitecture, cli.StringMe("a"), nil, "CPU architecture [x86_64/amd64, x86_64_mac, i386, or arm64]", []string{"x86_64", "x86_64_mac", "amd64", "i386", "arm64"})
@@ -370,6 +374,8 @@ Full docs can be found at github.com/aws/amazon-` + binName

filters := selector.Filters{
VCpusRange: cli.Int32RangeMe(flags[vcpus]),
DefaultCores: cli.Int32RangeMe(flags[defaultCores]),
DefaultThreadsPerCore: cli.Int32RangeMe(flags[defaultThreadsPerCore]),
MemoryRange: cli.ByteQuantityRangeMe(flags[memory]),
VCpusToMemoryRatio: cli.Float64Me(flags[vcpusToMemoryRatio]),
CPUArchitecture: cpuArchitectureFilterValue,
4 changes: 4 additions & 0 deletions pkg/selector/selector.go
Original file line number Diff line number Diff line change
@@ -55,6 +55,8 @@ const (
rootDeviceType = "rootDeviceType"
hibernationSupported = "hibernationSupported"
vcpusRange = "vcpusRange"
defaultCores = "defaultCores"
defaultThreadsPerCore = "defaultThreadsPerCore"
memoryRange = "memoryRange"
gpuMemoryRange = "gpuMemoryRange"
gpusRange = "gpusRange"
@@ -317,6 +319,8 @@ func (itf Selector) prepareFilter(ctx context.Context, filters Filters, instance
rootDeviceType: {filters.RootDeviceType, instanceTypeInfo.SupportedRootDeviceTypes},
hibernationSupported: {filters.HibernationSupported, instanceTypeInfo.HibernationSupported},
vcpusRange: {filters.VCpusRange, instanceTypeInfo.VCpuInfo.DefaultVCpus},
defaultCores: {filters.DefaultCores, instanceTypeInfo.VCpuInfo.DefaultCores},
defaultThreadsPerCore: {filters.DefaultThreadsPerCore, instanceTypeInfo.VCpuInfo.DefaultThreadsPerCore},
memoryRange: {filters.MemoryRange, instanceTypeInfo.MemoryInfo.SizeInMiB},
gpuMemoryRange: {filters.GpuMemoryRange, getTotalGpuMemory(instanceTypeInfo.GpuInfo)},
gpusRange: {filters.GpusRange, getTotalGpusCount(instanceTypeInfo.GpuInfo)},
6 changes: 6 additions & 0 deletions pkg/selector/types.go
Original file line number Diff line number Diff line change
@@ -215,6 +215,12 @@ type Filters struct {
// VCpusRange filter is a range of acceptable VCpus for the instance type
VCpusRange *Int32RangeFilter

// DefaultCores filter is a range of acceptable real cores for the instance type
DefaultCores *Int32RangeFilter

// DefaultThreadsPerCore is a range of acceptable threads per core
DefaultThreadsPerCore *Int32RangeFilter

// VcpusToMemoryRatio is a ratio of vcpus to memory expressed as a floating point
VCpusToMemoryRatio *float64

12 changes: 12 additions & 0 deletions test/e2e/run-test
Original file line number Diff line number Diff line change
@@ -93,6 +93,18 @@ params=(
)
echo "${expected[*]}" | execute_test "24 VCPUs" "${params[@]}"

expected=(c7a.32xlarge m7a.32xlarge r7a.32xlarge)
params=(
"--vcpus=128 --default-cores=128"
)
echo "${expected[*]}" | execute_test "128 vCPUs and 128 cores" "${params[@]}"

expected=(c6a.metal m6a.metal r6a.metal)
params=(
"--vcpus=192 --default-cores=96 --baremetal"
)
echo "${expected[*]}" | execute_test "192 vCPUs and 96 cores and baremetal" "${params[@]}"

expected=(g2.8xlarge g3.16xlarge g4dn.12xlarge p3.8xlarge)
params=(
"--gpus=4"