Skip to content

Commit

Permalink
traverser: fix errors from converting or slot back to slot
Browse files Browse the repository at this point in the history
  • Loading branch information
zekemorton committed Feb 26, 2025
1 parent fa0de82 commit 439e697
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 26 deletions.
1 change: 0 additions & 1 deletion resource/schema/data_std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ resource_type_t gpu_rt{"gpu"};
resource_type_t node_rt{"node"};
resource_type_t rack_rt{"rack"};
resource_type_t slot_rt{"slot"};
resource_type_t or_slot_rt{"or_slot"};

} // namespace resource_model
} // namespace Flux
Expand Down
1 change: 0 additions & 1 deletion resource/schema/data_std.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ constexpr uint64_t resource_type_id{1};
struct resource_type_tag {};
using resource_type_t = intern::interned_string<intern::dense_storage<resource_type_tag, uint16_t>>;
extern resource_type_t slot_rt;
extern resource_type_t or_slot_rt;
extern resource_type_t cluster_rt;
extern resource_type_t rack_rt;
extern resource_type_t node_rt;
Expand Down
47 changes: 44 additions & 3 deletions resource/traversers/dfu_flexible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int dfu_flexible_t::match (vtx_t u,
if (!resource.with.empty ()) {
for (auto &c_resource : resource.with) {
if (c_resource.type == slot_rt) {
*slot_resource = &c_resource;
*slot_resources = &resource.with;
*nslots = m_match->calc_effective_max (c_resource);
}
}
Expand Down Expand Up @@ -165,7 +165,7 @@ void dfu_flexible_t::prime_jobspec (std::vector<Resource> &resources,

// Or slots should use a minimum of values rather than an accumulation
// otherwise possible matches may be filtered out
if (resource.type == or_slot_rt) {
if (resource.type == slot_rt) {
for (auto &aggregate : resource.user_data) {
min_if (subsystem,
aggregate.first,
Expand Down Expand Up @@ -326,11 +326,52 @@ int dfu_flexible_t::dom_slot (const jobmeta_t &meta,
current_config = or_config[Key (std::get<0> (current_config))];
}
for (auto &edg_group : edg_group_vector)
dfu.add (dom, or_slot_rt, edg_group);
dfu.add (dom, slot_rt, edg_group);

done:
return (qual_num_slots) ? 0 : -1;
}

int dfu_flexible_t::prune (const jobmeta_t &meta,
bool exclusive,
subsystem_t s,
vtx_t u,
const std::vector<Jobspec::Resource> &resources)
{
int rc = 0;
// Prune by the visiting resource vertex's availability
// If resource is not UP, no reason to descend further.
if (meta.alloc_type != jobmeta_t::alloc_type_t::AT_SATISFIABILITY
&& (*m_graph)[u].status != resource_pool_t::status_t::UP) {
rc = -1;
goto done;
}
// RFC 31 constraints only match against type == "node"
// unspecified constraint matches everything
if (meta.constraint != nullptr && (*m_graph)[u].type == node_rt
&& !meta.constraint->match ((*m_graph)[u])) {
rc = -1;
goto done;
}
// if rack has been allocated exclusively, no reason to descend further.
if ((rc = by_avail (meta, s, u, resources)) == -1)
goto done;
for (auto &resource : resources) {
if ((*m_graph)[u].type != resource.type && resource.type != slot_rt)
continue;
// Prune by exclusivity checker
if (resource.type != slot_rt && (rc = by_excl (meta, s, u, exclusive, resource)) == -1)
break;
// Prune by the subtree planner quantities
if (resource.type != slot_rt && (rc = by_subplan (meta, s, u, resource)) == -1)
break;
if (resource.type == slot_rt && (rc = by_subplan (meta, s, u, resource)) == -1)
continue;
}

done:
return rc;
}
/*
* vi:tabstop=4 shiftwidth=4 expandtab
*/
6 changes: 6 additions & 0 deletions resource/traversers/dfu_flexible.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ class dfu_flexible_t : public dfu_impl_t {
void prime_jobspec (std::vector<Jobspec::Resource> &resources,
std::unordered_map<resource_type_t, int64_t> &to_parent);

int prune (const jobmeta_t &meta,
bool excl,
subsystem_t subsystem,
vtx_t u,
const std::vector<Jobspec::Resource> &resources);

public:
dfu_flexible_t ();
dfu_flexible_t (std::shared_ptr<resource_graph_db_t> db, std::shared_ptr<dfu_match_cb_t> m);
Expand Down
43 changes: 22 additions & 21 deletions resource/traversers/dfu_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class dfu_impl_t {
* \return none.
*/
virtual void prime_jobspec (std::vector<Jobspec::Resource> &resources,
std::unordered_map<resource_type_t, int64_t> &to_parent);
std::unordered_map<resource_type_t, int64_t> &to_parent);

/*! Extract the aggregate info in the lookup object as pertaining to the
* planner-tracking resource types into resource_counts array, a form that
Expand Down Expand Up @@ -355,11 +355,11 @@ class dfu_impl_t {
subsystem_t s,
vtx_t u,
const Jobspec::Resource &resource);
int prune (const jobmeta_t &meta,
bool excl,
subsystem_t subsystem,
vtx_t u,
const std::vector<Jobspec::Resource> &resources);
virtual int prune (const jobmeta_t &meta,
bool excl,
subsystem_t subsystem,
vtx_t u,
const std::vector<Jobspec::Resource> &resources);

planner_multi_t *subtree_plan (vtx_t u,
std::vector<uint64_t> &avail,
Expand All @@ -369,16 +369,17 @@ class dfu_impl_t {
* including slot match
*/
virtual int match (vtx_t u,
const std::vector<Jobspec::Resource> &resources,
const Jobspec::Resource **slot_resource,
unsigned int *nslots,
const Jobspec::Resource **match_resource);
const std::vector<Jobspec::Resource> &resources,
const Jobspec::Resource **slot_resource,
unsigned int *nslots,
const Jobspec::Resource **match_resource);
bool slot_match (vtx_t u, const Jobspec::Resource *slot_resource);
virtual const std::vector<Jobspec::Resource> &test (vtx_t u,
const std::vector<Jobspec::Resource> &resources,
bool &prestine,
unsigned int &nslots,
match_kind_t &ko);
virtual const std::vector<Jobspec::Resource> &test (
vtx_t u,
const std::vector<Jobspec::Resource> &resources,
bool &prestine,
unsigned int &nslots,
match_kind_t &ko);
bool is_pconstraint_matched (vtx_t u, const std::string &property);

/*! Accumulate count into accum if type matches with one of the resource
Expand Down Expand Up @@ -444,12 +445,12 @@ class dfu_impl_t {
scoring_api_t &to_parent);
int cnt_slot (const std::vector<Jobspec::Resource> &slot_shape, scoring_api_t &dfu_slot);
virtual int dom_slot (const jobmeta_t &meta,
vtx_t u,
const std::vector<Jobspec::Resource> &resources,
unsigned int nslots,
bool prestine,
bool *excl,
scoring_api_t &dfu);
vtx_t u,
const std::vector<Jobspec::Resource> &resources,
unsigned int nslots,
bool prestine,
bool *excl,
scoring_api_t &dfu);
// std::size_t hash_value(std::map<resource_type_t, int> counts);
int dom_exp (const jobmeta_t &meta,
vtx_t u,
Expand Down

0 comments on commit 439e697

Please sign in to comment.