Skip to content

Commit

Permalink
#2342: fix scope error
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed Sep 20, 2024
1 parent 7a53331 commit 27646fe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
26 changes: 14 additions & 12 deletions src/vt/vrt/collection/balance/lb_data_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void get_object_from_json_field_(
}

ElementIDStruct get_elm_from_object_info_(
const nlohmann::json& object, bool is_bitpacked, bool migratable,
const nlohmann::json& object, bool is_bitpacked, bool is_migratable,
const nlohmann::json& home, const nlohmann::json& node) {
using Field = uint64_t;

Expand All @@ -75,26 +75,28 @@ ElementIDStruct get_elm_from_object_info_(
}

return elm::ElmIDBits::createCollectionImpl(
migratable, object_id, home, node);
is_migratable, object_id, home, node);
}

ElementIDStruct get_elm_from_comm_object_(const nlohmann::json& field, bool collection) {
ElementIDStruct
get_elm_from_comm_object_(const nlohmann::json& field, bool collection) {
// Get the object's id and determine if it is bit-encoded
nlohmann::json object;
bool is_bitpacked;
get_object_from_json_field_(field, object, is_bitpacked);
vtAssertExpr(object.is_number());

// TODO: need to get this information (if it's relevant)
int home = 0;
int node = 0;
bool migratable = false;

// Create elm with encoded data
ElementIDStruct elm;

if (collection) {
elm =
get_elm_from_object_info_(object, is_bitpacked, migratable, home, node);
// TODO: need to get actual object data
int home = 0;
int node = 0;
bool is_migratable = false;

elm = get_elm_from_object_info_(
object, is_bitpacked, is_migratable, home, node);
} else {
elm = ElementIDStruct{object, theContext()->getNode()};
}
Expand Down Expand Up @@ -350,7 +352,7 @@ LBDataHolder::LBDataHolder(nlohmann::json const& j)
auto time = task["time"];
auto etype = task["entity"]["type"];
auto home = task["entity"]["home"];
bool migratable = task["entity"]["migratable"];
bool is_migratable = task["entity"]["migratable"];

vtAssertExpr(time.is_number());
vtAssertExpr(node.is_number());
Expand All @@ -367,7 +369,7 @@ LBDataHolder::LBDataHolder(nlohmann::json const& j)
task["entity"].find("collection_id") != task["entity"].end() and
task["entity"].find("index") != task["entity"].end()) {
elm = get_elm_from_object_info_(
object, is_bitpacked, migratable, home, node);
object, is_bitpacked, is_migratable, home, node);
auto cid = task["entity"]["collection_id"];
auto idx = task["entity"]["index"];
if (cid.is_number() && idx.is_array()) {
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/lb/test_lb_data_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace vt { namespace tests { namespace unit { namespace lb {
using TestLBDataHolder = TestHarness;

nlohmann::json create_basic_json(std::string id_type, int id,
int home, int node, bool migratable) {
int home, int node, bool is_migratable) {
nlohmann::json j = {
{"metadata", {
{"rank", 0},
Expand All @@ -70,7 +70,7 @@ nlohmann::json create_basic_json(std::string id_type, int id,
{"index", {0}},
{"home", home},
{id_type, id},
{"migratable", migratable},
{"migratable", is_migratable},
{"type", "object"}
}},
{"node", node},
Expand All @@ -85,18 +85,18 @@ nlohmann::json create_basic_json(std::string id_type, int id,
return j;
}

void test_data_holder_elms(int seq_id, int home, int node, bool migratable) {
void test_data_holder_elms(int seq_id, int home, int node, bool is_migratable) {
// Determine encoded ID
auto elm = elm::ElmIDBits::createCollectionImpl(migratable, seq_id, home, node);
auto elm = elm::ElmIDBits::createCollectionImpl(is_migratable, seq_id, home, node);
auto encoded_id = elm.id;

// Create DataHolder and get resulting object elm
auto simple_json_id = create_basic_json("id", encoded_id, home, node, migratable);
auto simple_json_id = create_basic_json("id", encoded_id, home, node, is_migratable);
auto dh_id = vt::vrt::collection::balance::LBDataHolder(simple_json_id);
auto elm_id = dh_id.node_data_[0].begin()->first;

// Create new DataHolder using "seq_id" and get elm
auto simple_json_seq = create_basic_json("seq_id", seq_id, home, node, migratable);
auto simple_json_seq = create_basic_json("seq_id", seq_id, home, node, is_migratable);
auto dh_seq = vt::vrt::collection::balance::LBDataHolder(simple_json_seq);
auto elm_seq = dh_seq.node_data_[0].begin()->first;

Expand All @@ -106,7 +106,7 @@ void test_data_holder_elms(int seq_id, int home, int node, bool migratable) {
}

TEST_F(TestLBDataHolder, test_lb_data_holder_no_comms_object_id) {
// Run a variety of test cases (seq_id, home, node, migratable)
// Run a variety of test cases (seq_id, home, node, is_migratable)
test_data_holder_elms(0,0,0,false);
test_data_holder_elms(0,0,0,true);
test_data_holder_elms(0,0,2,false);
Expand Down

0 comments on commit 27646fe

Please sign in to comment.