Skip to content

Commit

Permalink
Caching Descriptor Set Location
Browse files Browse the repository at this point in the history
  • Loading branch information
ifadams committed Jul 25, 2024
1 parent 6b80c68 commit 32ca9a4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/DescriptorsCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ DescriptorsCommand::DescriptorsCommand(const std::string &cmd_name)
std::string DescriptorsCommand::get_set_path(PMGDQuery &query_tx,
const std::string &set_name,
int &dim) {

// Check cache for descriptor set, if its found set dimensions and return path,
//otherwise we go forward and query PMGD to locate the descriptor set
auto element = _desc_set_locator.find(set_name);
std::string mapped_path;
if (element != _desc_set_locator.end()) {
mapped_path = element->second;
dim = _desc_set_dims[set_name];
return mapped_path;
}

// Will issue a read-only transaction to check
// if the Set exists
PMGDQuery query(query_tx.get_pmgd_qh());
Expand Down Expand Up @@ -97,6 +108,8 @@ std::string DescriptorsCommand::get_set_path(PMGDQuery &query_tx,
assert(ent.isMember(VDMS_DESC_SET_PATH_PROP));
std::string set_path = ent[VDMS_DESC_SET_PATH_PROP].asString();
dim = ent[VDMS_DESC_SET_DIM_PROP].asInt();
_desc_set_dims[set_name] = dim;
_desc_set_locator[set_name] = set_path;
return set_path;
}

Expand Down
6 changes: 6 additions & 0 deletions src/QueryHandlerPMGD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ using namespace VDMS;

std::unordered_map<std::string, RSCommand *> QueryHandlerPMGD::_rs_cmds;

//Static globals for use in looking up descriptor set locations, defined in RSCommand.h
tbb::concurrent_unordered_map<std::string, std::string>
RSCommand::_desc_set_locator;
tbb::concurrent_unordered_map<std::string, int>
RSCommand::_desc_set_dims;

void QueryHandlerPMGD::init() {
DescriptorsManager::init();

Expand Down
8 changes: 7 additions & 1 deletion src/RSCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017 Intel Corporation
* @copyright Copyright (c) 2024 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -34,13 +34,16 @@
#include <string>
#include <unordered_map>
#include <vector>
#include "tbb/concurrent_unordered_map.h"

#include "PMGDQuery.h"
#include "queryMessage.pb.h"

// Json parsing files
#include <jsoncpp/json/value.h>



namespace VDMS {

// Helper classes for handling various JSON commands.
Expand All @@ -49,6 +52,9 @@ class RSCommand {
const std::string _cmd_name;
std::map<std::string, int> _valid_params_map;

static tbb::concurrent_unordered_map<std::string, std::string> _desc_set_locator;
static tbb::concurrent_unordered_map<std::string, int> _desc_set_dims;

template <typename T>
T get_value(const Json::Value &json, const std::string &key, T def = T());

Expand Down

0 comments on commit 32ca9a4

Please sign in to comment.