Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2338: Fix the object ID to have to the correct features in the JSON reader #2339

17 changes: 16 additions & 1 deletion src/vt/vrt/collection/balance/lb_data_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#include "vt/vrt/collection/balance/lb_data_holder.h"
#include "vt/context/context.h"
#include "vt/elm/elm_id_bits.h"

#include <nlohmann/json.hpp>

Expand Down Expand Up @@ -296,6 +297,9 @@ LBDataHolder::LBDataHolder(nlohmann::json const& j)
auto node = task["node"];
auto time = task["time"];
auto etype = task["entity"]["type"];
auto home = task["entity"]["home"];
bool migratable = task["entity"]["migratable"];

vtAssertExpr(time.is_number());
vtAssertExpr(node.is_number());

Expand All @@ -304,12 +308,21 @@ LBDataHolder::LBDataHolder(nlohmann::json const& j)
vtAssertExpr(object.is_number());

auto elm = ElementIDStruct{object, node};
this->node_data_[id][elm].whole_phase_load = time;

if (
task["entity"].find("collection_id") != task["entity"].end() and
task["entity"].find("index") != task["entity"].end()
) {
using Field = uint64_t;
auto strippedObject = BitPackerType::getField<
vt::elm::eElmIDProxyBitsNonObjGroup::ID,
vt::elm::elm_id_num_bits,
Field
>(static_cast<Field>(object));
elm = elm::ElmIDBits::createCollectionImpl(migratable,
strippedObject,
home,
node);
auto cid = task["entity"]["collection_id"];
auto idx = task["entity"]["index"];
if (cid.is_number() && idx.is_array()) {
Expand All @@ -319,6 +332,8 @@ LBDataHolder::LBDataHolder(nlohmann::json const& j)
}
}

this->node_data_[id][elm].whole_phase_load = time;

if (task.find("subphases") != task.end()) {
auto subphases = task["subphases"];
if (subphases.is_array()) {
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/utils/test_bit_packing.nompi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <gtest/gtest.h>

#include "vt/utils/bits/bits_packer.h"
#include "vt/elm/elm_id_bits.h"
#include "test_harness.h"

namespace vt { namespace tests { namespace unit {
Expand Down Expand Up @@ -125,4 +126,20 @@ TEST_F(TestBitPacking, test_bit_packing_dynamic_check_masking_5) {
EXPECT_EQ(x, 0x0000FCCD0000FEEDull);
}

TEST_F(TestBitPacking, test_bit_packing_and_create_collection) {
using Field = uint64_t;
bool migratable = true;
int home = 0;
int node = 0;
nlslatt marked this conversation as resolved.
Show resolved Hide resolved
auto seq_id = 3;
auto init_elm = elm::ElmIDBits::createCollectionImpl(migratable, seq_id, home, node);
auto derived_id = BitPackerType::getField<
vt::elm::eElmIDProxyBitsNonObjGroup::ID,
vt::elm::elm_id_num_bits,
Field
>(init_elm.id);
auto derived_elm = elm::ElmIDBits::createCollectionImpl(migratable, derived_id, home, node);
EXPECT_EQ(init_elm.id, derived_elm.id);
}

}}} /* end namespace vt::tests::unit */
Loading