Skip to content

Commit

Permalink
add firstnodex policy
Browse files Browse the repository at this point in the history
  • Loading branch information
trws committed Aug 17, 2023
1 parent a34dbe6 commit e4d85e8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 47 deletions.
4 changes: 3 additions & 1 deletion resource/policies/dfu_match_policy_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ std::shared_ptr<dfu_match_cb_t> create_match_cb (const std::string &policy)
std::shared_ptr<dfu_match_cb_t> matcher = nullptr;

try {
if (policy == FIRST_MATCH) {
if (policy == FIRST_MATCH || policy == FIRST_NODEX_MATCH) {
std::shared_ptr<high_first_t> ptr
= std::make_shared<high_first_t> ();
ptr->add_score_factor (std::string ("node"), 1, 10000);
ptr->set_stop_on_k_matches (1);
if (policy == FIRST_NODEX_MATCH)
ptr->add_exclusive_resource_type ("node");
matcher = ptr;
} else if (policy == HIGH_ID_FIRST) {
matcher = std::make_shared<high_first_t> ();
Expand Down
1 change: 1 addition & 0 deletions resource/policies/dfu_match_policy_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Flux {
namespace resource_model {

const std::string FIRST_MATCH = "first";
const std::string FIRST_NODEX_MATCH = "firstnodex";
const std::string HIGH_ID_FIRST = "high";
const std::string LOW_ID_FIRST = "low";
const std::string LOW_NODE_FIRST = "lonode";
Expand Down
79 changes: 33 additions & 46 deletions t/t3033-resource-nodex.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,36 @@ exp_dir="${SHARNESS_TEST_SRCDIR}/data/resource/expected/nodex"
grugs="${SHARNESS_TEST_SRCDIR}/data/resource/grugs/small.graphml"
query="../../resource/utilities/resource-query"

#
# Takes policy and cmd outfile prefix
run_tests_with_policy() {
pol=$1
prefix=$2

cmds001="${cmd_dir}/cmds01.in"
test001_desc="allocate 7 jobs with node-level constraint (pol=$pol)"
test_expect_success "${test001_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds001} > cmds001 &&
${query} -L ${grugs} -S CA -P $pol -t ${prefix}1.R.out < cmds001 &&
test_cmp ${prefix}1.R.out ${exp_dir}/${prefix}1.R.out
'

cmds002="${cmd_dir}/cmds02.in"
test002_desc="allocate 7 jobs with no node-level constraint (pol=$pol)"
test_expect_success "${test002_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds002} > cmds002 &&
${query} -L ${grugs} -S CA -P $pol -t ${prefix}2.R.out < cmds002 &&
test_cmp ${prefix}2.R.out ${exp_dir}/${prefix}2.R.out
'

cmds003="${cmd_dir}/cmds03.in"
test003_desc="match allocate 7 jobs -- last fails (pol=$pol)"
test_expect_success "${test003_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds003} > cmds003 &&
${query} -L ${grugs} -S CA -P $pol -t ${prefix}3.R.out < cmds003 &&
test_cmp ${prefix}3.R.out ${exp_dir}/${prefix}3.R.out
'
}

# Selection Policy -- High node first with node exclusivity (-P hinodex)
# Selection behavior is identical to hinode except that
# it marks each selected node as exclusive even if the
Expand All @@ -25,29 +54,7 @@ query="../../resource/utilities/resource-query"
# again all 36 cores from the current available highest node.
#

cmds001="${cmd_dir}/cmds01.in"
test001_desc="allocate 7 jobs with node-level constraint (pol=hinodex)"
test_expect_success "${test001_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds001} > cmds001 &&
${query} -L ${grugs} -S CA -P hinodex -t 001.R.out < cmds001 &&
test_cmp 001.R.out ${exp_dir}/001.R.out
'

cmds002="${cmd_dir}/cmds02.in"
test002_desc="allocate 7 jobs with no node-level constraint (pol=hinodex)"
test_expect_success "${test002_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds002} > cmds002 &&
${query} -L ${grugs} -S CA -P hinodex -t 002.R.out < cmds002 &&
test_cmp 002.R.out ${exp_dir}/002.R.out
'

cmds003="${cmd_dir}/cmds03.in"
test003_desc="match allocate 7 jobs -- last fails (pol=hinodex)"
test_expect_success "${test003_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds003} > cmds003 &&
${query} -L ${grugs} -S CA -P hinodex -t 003.R.out < cmds003 &&
test_cmp 003.R.out ${exp_dir}/003.R.out
'
run_tests_with_policy hinodex 00

#
# Selection Policy -- Low node first with node exclusivity (-P lonodex)
Expand All @@ -65,28 +72,8 @@ test_expect_success "${test003_desc}" '
# again all 36 cores from the current available lowest node.
#

cmds011="${cmd_dir}/cmds01.in"
test011_desc="allocate 7 jobs with node-level constraint (pol=lonodex)"
test_expect_success "${test011_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds011} > cmds011 &&
${query} -L ${grugs} -S CA -P lonodex -t 011.R.out < cmds011 &&
test_cmp 011.R.out ${exp_dir}/011.R.out
'

cmds012="${cmd_dir}/cmds02.in"
test012_desc="allocate 7 jobs with no node-level constraint (pol=lonodex)"
test_expect_success "${test012_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds012} > cmds012 &&
${query} -L ${grugs} -S CA -P lonodex -t 012.R.out < cmds012 &&
test_cmp 012.R.out ${exp_dir}/012.R.out
'
run_tests_with_policy lonodex 01

cmds013="${cmd_dir}/cmds03.in"
test013_desc="match allocate 7 jobs -- last fails (pol=lonodex)"
test_expect_success "${test013_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds013} > cmds013 &&
${query} -L ${grugs} -S CA -P lonodex -t 013.R.out < cmds013 &&
test_cmp 013.R.out ${exp_dir}/013.R.out
'
run_tests_with_policy firstnodex 00

test_done

0 comments on commit e4d85e8

Please sign in to comment.