You are optimizing a “vectored computation” on a heterogeneous (non-SMP) CPU with asymmetric cores.
There are two core types:
Each core runs one operation at a time; operations assigned to the same core run sequentially.
You are given a vector of independent operations (order doesn’t matter):
ops[i] ∈ {'M', 'D'}
meaning multiply or divide.
And performance parameters:
time_D_on_Dcore
time_D_on_MDcore
,
time_M_on_MDcore
Design and implement a function that produces a near-optimal schedule to minimize the total completion time (makespan):
def schedule_ops(ops: list[str], num_d: int, num_md: int,
tD_d: int, tD_md: int, tM_md: int) -> tuple[int, list[int]]:
"""
Returns:
- estimated minimal makespan (time units)
- an assignment array where assignment[i] is the core index chosen for ops[i]
(e.g., cores 0..num_d-1 are D-cores, num_d..num_d+num_md-1 are MD-cores)
"""
M
op to a D-core.
num_d=0
or
num_md=0