Skip to content

Commit

Permalink
Merge pull request #2339 from DARMA-tasking/2338-fix-the-object-id-to…
Browse files Browse the repository at this point in the history
…-have-to-the-correct-features-in-the-json-reader

#2338: Fix the object ID to have to the correct features in the JSON reader
  • Loading branch information
lifflander committed Aug 28, 2024
2 parents 1dbedd2 + 2dfae5d commit 9bf7c94
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
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
16 changes: 16 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,19 @@ TEST_F(TestBitPacking, test_bit_packing_dynamic_check_masking_5) {
EXPECT_EQ(x, 0x0000FCCD0000FEEDull);
}

TEST_F(TestBitPacking, test_bit_packing_and_create_collection) {
bool migratable = true;
int home = 1;
int node = 0;
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,
uint64_t
>(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 */

0 comments on commit 9bf7c94

Please sign in to comment.