Skip to content

Commit

Permalink
#2338: determine ids of encoded objects via bit stripping
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed Aug 27, 2024
1 parent a596377 commit 7c7e96f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/vt/vrt/collection/balance/lb_data_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,18 @@ LBDataHolder::LBDataHolder(nlohmann::json const& j)
task["entity"].find("collection_id") != task["entity"].end() and
task["entity"].find("index") != task["entity"].end()
) {
elm = elm::ElmIDBits::createCollectionImpl(migratable, object, home, node);
using Field = uint64_t;
auto strippedObject = BitPackerType::getField<
vt::elm::eElmIDProxyBitsNonObjGroup::ID,
vt::elm::elm_id_num_bits,
Field
>(static_cast<Field>(object));
auto cid = task["entity"]["collection_id"];
auto idx = task["entity"]["index"];
elm = elm::ElmIDBits::createCollectionImpl(migratable,
strippedObject,
home,
node);
if (cid.is_number() && idx.is_array()) {
std::vector<uint64_t> arr = idx;
auto proxy = static_cast<VirtualProxyType>(cid);
Expand Down
2 changes: 0 additions & 2 deletions src/vt/vrt/collection/balance/workload_replay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include <nlohmann/json.hpp>

#include <set>
#include <iostream>

namespace vt { namespace vrt { namespace collection {
namespace balance { namespace replay {
Expand All @@ -61,7 +60,6 @@ void replayWorkloads(
) {
// read in object loads from json files
auto const filename = theConfig()->getLBDataFileIn();
std::cout << "Reading in file: " << filename << std::endl;
auto workloads = readInWorkloads(filename);

// use the default stats handler
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;
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 */

0 comments on commit 7c7e96f

Please sign in to comment.