Skip to content

Commit

Permalink
Merge pull request #878 from dongahn/more-min-max
Browse files Browse the repository at this point in the history
resource: beefing up min/max count-based matching
  • Loading branch information
mergify[bot] authored Nov 1, 2021
2 parents e619600 + b6717d3 commit eed1166
Show file tree
Hide file tree
Showing 53 changed files with 14,901 additions and 43 deletions.
8 changes: 7 additions & 1 deletion resource/policies/base/matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
\*****************************************************************************/

#include <algorithm>

#include <limits>
#include "policies/base/matcher.hpp"

namespace Flux {
Expand Down Expand Up @@ -140,6 +140,12 @@ unsigned int matcher_util_api_t::calc_count (
return count;
}

unsigned int matcher_util_api_t::calc_effective_max (
const Flux::Jobspec::Resource &resource) const
{
return calc_count (resource, std::numeric_limits<unsigned int>::max ());
}

int matcher_util_api_t::register_resource_pair (const std::string &subsystem,
std::string &r_pair)
{
Expand Down
9 changes: 9 additions & 0 deletions resource/policies/base/matcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ class matcher_util_api_t
unsigned int calc_count (const Flux::Jobspec::Resource &resource,
unsigned int qual_cnt) const;

/*! Calculate the effective max count that should be allocated.
*
* \param resource resource section of the jobspec.
* \return Effective max count; 0 if an error is encountered.
*/
unsigned int calc_effective_max (
const Flux::Jobspec::Resource &resource) const;


/*! Set prune filters based on spec. The spec should comply with
* the following format:
* <HL-resource1:LL-resource1[,HL-resource2:LL-resource2...]...]>
Expand Down
11 changes: 7 additions & 4 deletions resource/traversers/dfu_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ int dfu_impl_t::match (vtx_t u, const std::vector<Resource> &resources,
for (auto &c_resource : resource.with)
if (c_resource.type == "slot") {
*slot_resource = &c_resource;
*nslots = c_resource.count.min;
*nslots = m_match->calc_effective_max (c_resource);
}
}
matched = true;
Expand All @@ -248,7 +248,7 @@ int dfu_impl_t::match (vtx_t u, const std::vector<Resource> &resources,
if (matched == true)
goto ret;
*slot_resource = &resource;
*nslots = resource.count.min; // slot is limited to only min
*nslots = m_match->calc_effective_max (resource);
matched = true;
}
}
Expand Down Expand Up @@ -422,7 +422,9 @@ bool dfu_impl_t::is_enough (const subsystem_t &subsystem,
[&] (const Resource &resource) {
unsigned int total = dfu.total_count (subsystem,
resource.type);
unsigned int required = multiplier * resource.count.min;
unsigned int required = multiplier
* m_match->calc_effective_max (
resource);
return total >= required;
});
}
Expand All @@ -434,7 +436,8 @@ int dfu_impl_t::new_sat_types (const subsystem_t &subsystem,
{
for (auto &resource : resources) {
unsigned int total = dfu.total_count (subsystem, resource.type);
unsigned int required = multiplier * resource.count.min;
unsigned int required = multiplier
* m_match->calc_effective_max (resource);
bool sat = total >= required;
if (sat && sat_types.find (resource.type) == sat_types.end ()) {
auto ret = sat_types.insert (resource.type);
Expand Down
1 change: 1 addition & 0 deletions t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ TESTS = \
t3028-resource-grow.t \
t3029-resource-prune.t \
t3030-resource-multi.t \
t3031-resource-minmax2.t \
t3300-system-dontblock.t \
t3301-system-latestart.t \
t4000-match-params.t \
Expand Down
2 changes: 2 additions & 0 deletions t/data/resource/commands/min_max2/cmds01.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test001.yaml
quit
2 changes: 2 additions & 0 deletions t/data/resource/commands/min_max2/cmds02.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test002.yaml
quit
2 changes: 2 additions & 0 deletions t/data/resource/commands/min_max2/cmds03.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test003.yaml
quit
2 changes: 2 additions & 0 deletions t/data/resource/commands/min_max2/cmds04.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test004.yaml
quit
7 changes: 7 additions & 0 deletions t/data/resource/commands/min_max2/cmds05.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test005.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test006.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test006.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test006.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test006.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test006.yaml
quit
4 changes: 4 additions & 0 deletions t/data/resource/commands/min_max2/cmds06.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test007.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test008.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test008.yaml
quit
2 changes: 2 additions & 0 deletions t/data/resource/commands/min_max2/cmds08.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test009.yaml
quit
3 changes: 3 additions & 0 deletions t/data/resource/commands/min_max2/cmds09.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test005.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/min_max2/test009.yaml
quit
55 changes: 55 additions & 0 deletions t/data/resource/commands/min_max2/sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#cmds012="${cmd_dir}/cmds02.in"
#test012_desc="min=1/max=99999 on core works (pol=first)"
#test_expect_success "${test012_desc}" '
# sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds012} > cmds012 &&
# ${query} -L ${grugs} -S CA -P first -t 012.R.out < cmds012 &&
# test_cmp 012.R.out ${exp_dir}/012.R.out
#'
#
#cmds013="${cmd_dir}/cmds03.in"
#test013_desc="min=1/max=18 on core min=1/max=2 on gpu works (pol=first)"
#test_expect_success "${test013_desc}" '
# sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds013} > cmds013 &&
# ${query} -L ${grugs} -S CA -P first -t 013.R.out < cmds013 &&
# test_cmp 013.R.out ${exp_dir}/013.R.out
#'
#
#cmds014="${cmd_dir}/cmds04.in"
#test014_desc="min=1/max=99999 on core min=1/max=99999 on gpu works (pol=first)"
#test_expect_success "${test014_desc}" '
# sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds014} > cmds014 &&
# ${query} -L ${grugs} -S CA -P first -t 014.R.out < cmds014 &&
# test_cmp 014.R.out ${exp_dir}/014.R.out
#'
#
#cmds015="${cmd_dir}/cmds05.in"
#test015_desc="min=1/max=18 on core results in count=4 (pol=first)"
#test_expect_success "${test015_desc}" '
# sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds015} > cmds015 &&
# ${query} -L ${grugs} -S CA -P first -t 015.R.out < cmds015 &&
# test_cmp 015.R.out ${exp_dir}/015.R.out
#'
#
#cmds016="${cmd_dir}/cmds06.in"
#test016_desc="A node exclusive request (node=1) works (pol=first)"
#test_expect_success "${test016_desc}" '
# sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds016} > cmds016 &&
# ${query} -L ${grugs} -S CA -P first -t 016.R.out < cmds016 &&
# test_cmp 016.R.out ${exp_dir}/016.R.out
#'
#
#cmds018="${cmd_dir}/cmds08.in"
#test018_desc="A multi-level min/max works (pol=first)"
#test_expect_success "${test018_desc}" '
# sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds018} > cmds018 &&
# ${query} -L ${grugs} -S CA -P first -t 018.R.out < cmds018 &&
# test_cmp 018.R.out ${exp_dir}/018.R.out
#'
#
#cmds019="${cmd_dir}/cmds09.in"
#test019_desc="A multi-level min/max works with an existing allocation (pol=first)"
#test_expect_success "${test019_desc}" '
# sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds019} > cmds019 &&
# ${query} -L ${grugs} -S CA -P first -t 019.R.out < cmds019 &&
# test_cmp 019.R.out ${exp_dir}/019.R.out
#'
69 changes: 63 additions & 6 deletions t/data/resource/expected/min_max/011.R.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
---------------core0[1:x]
---------------core1[1:x]
---------------core2[1:x]
---------------core3[1:x]
---------------core4[1:x]
---------------core5[1:x]
---------------core6[1:x]
---------------core7[1:x]
---------------core8[1:x]
---------------core9[1:x]
---------------core10[1:x]
---------------core11[1:x]
---------------core12[1:x]
---------------core13[1:x]
---------------core14[1:x]
---------------core15[1:x]
---------------core16[1:x]
---------------core17[1:x]
------------socket0[1:x]
---------------core18[1:x]
---------------core19[1:x]
---------------core20[1:x]
Expand Down Expand Up @@ -2196,8 +2215,8 @@ INFO: =============================
---------------core16[1:x]
---------------core17[1:x]
------------socket0[1:x]
---------node107[1:s]
------rack5[1:s]
---------node89[1:s]
------rack4[1:s]
---resv_test0[1:s]
INFO: =============================
INFO: JOBID=3
Expand All @@ -2223,14 +2242,52 @@ INFO: =============================
---------------core16[1:x]
---------------core17[1:x]
------------socket0[1:x]
---------node89[1:s]
------rack4[1:s]
---------------core18[1:x]
---------------core19[1:x]
---------------core20[1:x]
---------------core21[1:x]
---------------core22[1:x]
---------------core23[1:x]
---------------core24[1:x]
---------------core25[1:x]
---------------core26[1:x]
---------------core27[1:x]
---------------core28[1:x]
---------------core29[1:x]
---------------core30[1:x]
---------------core31[1:x]
---------------core32[1:x]
---------------core33[1:x]
---------------core34[1:x]
---------------core35[1:x]
------------socket1[1:x]
---------node71[1:s]
------rack3[1:s]
---resv_test0[1:s]
INFO: =============================
INFO: JOBID=4
INFO: RESOURCES=ALLOCATED
INFO: SCHEDULED AT=Now
INFO: =============================
---------------core0[1:x]
---------------core1[1:x]
---------------core2[1:x]
---------------core3[1:x]
---------------core4[1:x]
---------------core5[1:x]
---------------core6[1:x]
---------------core7[1:x]
---------------core8[1:x]
---------------core9[1:x]
---------------core10[1:x]
---------------core11[1:x]
---------------core12[1:x]
---------------core13[1:x]
---------------core14[1:x]
---------------core15[1:x]
---------------core16[1:x]
---------------core17[1:x]
------------socket0[1:x]
---------------core18[1:x]
---------------core19[1:x]
---------------core20[1:x]
Expand All @@ -2250,8 +2307,8 @@ INFO: =============================
---------------core34[1:x]
---------------core35[1:x]
------------socket1[1:x]
---------node89[1:s]
------rack4[1:s]
---------node70[1:s]
------rack3[1:s]
---resv_test0[1:s]
INFO: =============================
INFO: JOBID=5
Expand Down
69 changes: 63 additions & 6 deletions t/data/resource/expected/min_max/012.R.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
---------------core0[1:x]
---------------core1[1:x]
---------------core2[1:x]
---------------core3[1:x]
---------------core4[1:x]
---------------core5[1:x]
---------------core6[1:x]
---------------core7[1:x]
---------------core8[1:x]
---------------core9[1:x]
---------------core10[1:x]
---------------core11[1:x]
---------------core12[1:x]
---------------core13[1:x]
---------------core14[1:x]
---------------core15[1:x]
---------------core16[1:x]
---------------core17[1:x]
------------socket0[1:x]
---------------core18[1:x]
---------------core19[1:x]
---------------core20[1:x]
Expand Down Expand Up @@ -2196,8 +2215,8 @@ INFO: =============================
---------------core16[1:x]
---------------core17[1:x]
------------socket0[1:x]
---------node107[1:s]
------rack5[1:s]
---------node89[1:s]
------rack4[1:s]
---resv_test0[1:s]
INFO: =============================
INFO: JOBID=3
Expand All @@ -2223,14 +2242,52 @@ INFO: =============================
---------------core16[1:x]
---------------core17[1:x]
------------socket0[1:x]
---------node89[1:s]
------rack4[1:s]
---------------core18[1:x]
---------------core19[1:x]
---------------core20[1:x]
---------------core21[1:x]
---------------core22[1:x]
---------------core23[1:x]
---------------core24[1:x]
---------------core25[1:x]
---------------core26[1:x]
---------------core27[1:x]
---------------core28[1:x]
---------------core29[1:x]
---------------core30[1:x]
---------------core31[1:x]
---------------core32[1:x]
---------------core33[1:x]
---------------core34[1:x]
---------------core35[1:x]
------------socket1[1:x]
---------node71[1:s]
------rack3[1:s]
---resv_test0[1:s]
INFO: =============================
INFO: JOBID=4
INFO: RESOURCES=ALLOCATED
INFO: SCHEDULED AT=Now
INFO: =============================
---------------core0[1:x]
---------------core1[1:x]
---------------core2[1:x]
---------------core3[1:x]
---------------core4[1:x]
---------------core5[1:x]
---------------core6[1:x]
---------------core7[1:x]
---------------core8[1:x]
---------------core9[1:x]
---------------core10[1:x]
---------------core11[1:x]
---------------core12[1:x]
---------------core13[1:x]
---------------core14[1:x]
---------------core15[1:x]
---------------core16[1:x]
---------------core17[1:x]
------------socket0[1:x]
---------------core18[1:x]
---------------core19[1:x]
---------------core20[1:x]
Expand All @@ -2250,8 +2307,8 @@ INFO: =============================
---------------core34[1:x]
---------------core35[1:x]
------------socket1[1:x]
---------node89[1:s]
------rack4[1:s]
---------node70[1:s]
------rack3[1:s]
---resv_test0[1:s]
INFO: =============================
INFO: JOBID=5
Expand Down
Loading

0 comments on commit eed1166

Please sign in to comment.