feat(scheduler-allocator-runner): parjob allocates through the framework runner (task 4.1)
parjob registers sched_allocator_run with parjob_alloc_iface (accepts maxTasks > 1, bug-1767, plus its plan iterator); its private my_alloc() and claim helpers are gone. Characterization now pins the intended changes: a reason for every short host (2/6/5) and the bug-1893 shared reason. No other test expectation changed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0e68ed991a
commit
239bcf95cd
4 changed files with 116 additions and 563 deletions
|
|
@ -90,6 +90,7 @@
|
|||
* to reach them directly.
|
||||
*/
|
||||
#include "../src/core.c"
|
||||
#include "../src/alloc_runner.c"
|
||||
#include "../src/host_iter.c"
|
||||
#include "../src/plugins/parjob_allocator.c"
|
||||
#include "../src/resource.c"
|
||||
|
|
@ -313,7 +314,8 @@ static void init_primary_obj(xce_sched_obj_t* obj,
|
|||
* attempt runs: sched_ctx_init() -> sched_ctx_set_primary() (the real
|
||||
* call that stages ctx->alloc_req.shared via plugin_prepare_allocation()'s
|
||||
* ctx->worker==NULL branch, exactly as sched_make_primary_allocation()
|
||||
* does today) -> my_alloc(). Returns my_alloc()'s return code; ctx is left
|
||||
* does today) -> parjob's registered entry point, the framework routine
|
||||
* sched_allocator_run(). Returns its return code; ctx is left
|
||||
* initialized (caller must sched_ctx_fini()). Identical to
|
||||
* test_seqjob_rewrap_equivalence.c's own helper. */
|
||||
static int drive_my_alloc(xce_scheduler_t* sched, xce_sched_obj_t* obj,
|
||||
|
|
@ -328,13 +330,12 @@ static int drive_my_alloc(xce_scheduler_t* sched, xce_sched_obj_t* obj,
|
|||
|
||||
memset(&plugin, 0, sizeof(plugin));
|
||||
plugin.sched = sched;
|
||||
/* scheduler-sim-live-allocation spec, task 4.3: my_alloc() now reads
|
||||
* plugin->core (honestly typed, task 1.2) for every core-safe call,
|
||||
* alongside the still-needed plugin->sched (sched_make_allocs(),
|
||||
* scheduler.c, unchanged). */
|
||||
plugin.core = &(sched->core);
|
||||
/* the runner reads plugin->core, plugin->sched (sched_make_allocs())
|
||||
* and parjob's allocator contract */
|
||||
plugin.core = &(sched->core);
|
||||
plugin.allocator_iface = &parjob_alloc_iface;
|
||||
|
||||
return my_alloc(&plugin, ctx);
|
||||
return sched_allocator_run(&plugin, ctx);
|
||||
}
|
||||
|
||||
/* assert_uncommitted_host_debit - reads ctx->uncomitted.hosts[w->idx] for
|
||||
|
|
@ -824,7 +825,7 @@ static void test_descending_bucket_order_succeeds_where_ascending_fails(void)
|
|||
xce_alloc_plan_t plan;
|
||||
int bucket_slots_desc[2];
|
||||
int bucket_slots_asc[2];
|
||||
parjob_claim_t claimed[2];
|
||||
sched_alloc_claim_t claimed[2];
|
||||
int nclaimed;
|
||||
int rc;
|
||||
int idx[1];
|
||||
|
|
@ -866,9 +867,9 @@ static void test_descending_bucket_order_succeeds_where_ascending_fails(void)
|
|||
TEST_ASSERT_EQUAL_INT(0, sched_ctx_init(&ctx, &(sched.core), &obj));
|
||||
sched_ctx_set_primary(&ctx, &primary);
|
||||
|
||||
/* my_alloc() always lazily creates ctx->reason before ever reaching
|
||||
* parjob_try_plan_() (see my_alloc()'s own top-of-function guard);
|
||||
* this test calls parjob_try_plan_() directly, bypassing that step,
|
||||
/* sched_allocator_run() always creates ctx->reason before ever
|
||||
* reaching sched_try_plan_() (alloc_runner.c); this test calls
|
||||
* sched_try_plan_() directly, bypassing that step,
|
||||
* so it must set one up itself -- sched_try_alloc_on_host_()
|
||||
* (resource.c) unconditionally records a pend reason into
|
||||
* ctx->reason->reasons on a resource-unmet candidate, which the
|
||||
|
|
@ -887,11 +888,9 @@ static void test_descending_bucket_order_succeeds_where_ascending_fails(void)
|
|||
plan.nbuckets = 2;
|
||||
plan.bucket_slots = bucket_slots_desc;
|
||||
|
||||
/* scheduler-sim-live-allocation spec, task 4.3: parjob_try_plan_() is
|
||||
* now honestly typed xce_sched_core_t* (mirrors task 2.1's identical
|
||||
* ctx->sched ripple immediately above) -- pass &(sched.core), not
|
||||
* &sched. */
|
||||
rc = parjob_try_plan_(&(sched.core), &ctx, &plan, claimed, &nclaimed);
|
||||
/* sched_try_plan_() (alloc_runner.c) takes the core: pass
|
||||
* &(sched.core), not &sched. */
|
||||
rc = sched_try_plan_(&(sched.core), &ctx, &plan, claimed, &nclaimed);
|
||||
TEST_ASSERT_EQUAL_INT(1, rc);
|
||||
TEST_ASSERT_EQUAL_INT(2, nclaimed);
|
||||
TEST_ASSERT_TRUE(claimed[0].w == host_first);
|
||||
|
|
@ -899,7 +898,7 @@ static void test_descending_bucket_order_succeeds_where_ascending_fails(void)
|
|||
|
||||
/* Roll back before trying the ascending variant against the exact
|
||||
* same, otherwise-untouched host pool. */
|
||||
parjob_rollback_claims_(&ctx, claimed, nclaimed);
|
||||
sched_rollback_claims_(&ctx, claimed, nclaimed);
|
||||
assert_uncommitted_host_debit(&ctx, host_first, slots_res->idx, 0.0f);
|
||||
assert_uncommitted_host_debit(&ctx, host_second, slots_res->idx, 0.0f);
|
||||
|
||||
|
|
@ -914,11 +913,9 @@ static void test_descending_bucket_order_succeeds_where_ascending_fails(void)
|
|||
plan.nbuckets = 2;
|
||||
plan.bucket_slots = bucket_slots_asc;
|
||||
|
||||
/* scheduler-sim-live-allocation spec, task 4.3: parjob_try_plan_() is
|
||||
* now honestly typed xce_sched_core_t* (mirrors task 2.1's identical
|
||||
* ctx->sched ripple immediately above) -- pass &(sched.core), not
|
||||
* &sched. */
|
||||
rc = parjob_try_plan_(&(sched.core), &ctx, &plan, claimed, &nclaimed);
|
||||
/* sched_try_plan_() (alloc_runner.c) takes the core: pass
|
||||
* &(sched.core), not &sched. */
|
||||
rc = sched_try_plan_(&(sched.core), &ctx, &plan, claimed, &nclaimed);
|
||||
TEST_ASSERT_EQUAL_INT(0, rc);
|
||||
TEST_ASSERT_EQUAL_INT(0, nclaimed);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue