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

KVCache use MinBlocksInfo to get start/count in query #4294

Merged
merged 5 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions source/adios2/engine/bp5/BP5Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ void BP5Reader::EndStep()
m_BetweenStepPairs = false;
PERFSTUBS_SCOPED_TIMER("BP5Reader::EndStep");
PerformGets();
for (auto &item : MinBlocksInfoMap)
{
delete item.second;
}
MinBlocksInfoMap.clear();
}

std::pair<double, double> BP5Reader::ReadData(adios2::transportman::TransportMan &FileManager,
Expand Down Expand Up @@ -385,15 +390,44 @@ void BP5Reader::PerformRemoteGetsWithKVCache()

for (size_t req_seq = 0; req_seq < GetRequests.size(); req_seq++)
{
const auto &Req = GetRequests[req_seq];
auto &Req = GetRequests[req_seq];
const DataType varType = m_IO.InquireVariableType(Req.VarName);

std::string keyPrefix = m_Fingerprint + "|" + Req.VarName + std::to_string(Req.RelStep);
if (Req.BlockID != std::numeric_limits<std::size_t>::max())
{
MinVarInfo *minBlocksInfo = nullptr;
if (MinBlocksInfoMap.find(keyPrefix) == MinBlocksInfoMap.end())
{
VariableBase *VB = m_BP5Deserializer->GetVariableBaseFromBP5VarRec(Req.VarRec);
minBlocksInfo = MinBlocksInfo(*VB, Req.RelStep);
MinBlocksInfoMap[keyPrefix] = minBlocksInfo;
}
else
{
minBlocksInfo = MinBlocksInfoMap[keyPrefix];
}
Req.Start.resize(minBlocksInfo->Dims);
Req.Count.resize(minBlocksInfo->Dims);
for (auto &blockInfo : minBlocksInfo->BlocksInfo)
{
if (Req.BlockID == blockInfo.BlockID)
{
for (int i = 0; i < minBlocksInfo->Dims; i++)
{
Req.Start[i] = blockInfo.Start[i];
Req.Count[i] = blockInfo.Count[i];
}
break;
}
}
}

RequestInfo ReqInfo(Req.Count.size());
ReqInfo.ReqSeq = req_seq;
ReqInfo.TypeSize = helper::GetDataTypeSize(varType);

kvcache::QueryBox targetBox(Req.Start, Req.Count);
std::string keyPrefix = m_Fingerprint + "|" + Req.VarName + std::to_string(Req.RelStep);
std::string targetKey = keyPrefix + targetBox.toString();

// Exact Match: check if targetKey exists
Expand Down
1 change: 1 addition & 0 deletions source/adios2/engine/bp5/BP5Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class BP5Reader : public BP5Engine, public Engine

/* KVCache for remote data */
kvcache::KVCacheCommon m_KVCache;
std::unordered_map<std::string, MinVarInfo *> MinBlocksInfoMap;

/* Fingerprint to verify local validity against remote data */
std::string m_Fingerprint = "";
Expand Down
6 changes: 6 additions & 0 deletions source/adios2/toolkit/format/bp5/BP5Deserializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ class BP5Deserializer : virtual public BP5Base
/* We assume operators are not thread-safe, call Decompress() one at a time
*/
std::mutex mutexDecompress;

public:
VariableBase *GetVariableBaseFromBP5VarRec(void *VarRec)
{
return static_cast<VariableBase *>(static_cast<BP5VarRec *>(VarRec)->Variable);
};
};

} // end namespace format
Expand Down