OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BoundingBoxIntersectTuningParamRecycler Class Reference

#include <BoundingBoxIntersectTuningParamRecycler.h>

+ Inheritance diagram for BoundingBoxIntersectTuningParamRecycler:
+ Collaboration diagram for BoundingBoxIntersectTuningParamRecycler:

Public Member Functions

 BoundingBoxIntersectTuningParamRecycler ()
 
 std::numeric_limits ()
 
 std::numeric_limits ()
 
std::optional< AutoTunerMetaInfogetItemFromCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
 
void putItemToCache (QueryPlanHash key, std::optional< AutoTunerMetaInfo > item, CacheItemType item_type, DeviceIdentifier device_identifier, size_t item_size, size_t compute_time, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
 
void initCache () override
 
void clearCache () override
 
void markCachedItemAsDirty (size_t table_key, std::unordered_set< QueryPlanHash > &key_set, CacheItemType item_type, DeviceIdentifier device_identifier) override
 
std::string toString () const override
 
- Public Member Functions inherited from DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >
 DataRecycler (const std::vector< CacheItemType > &item_types, size_t total_cache_size, size_t max_item_size, int num_gpus)
 
virtual ~DataRecycler ()=default
 
void markCachedItemAsDirtyImpl (QueryPlanHash key, CachedItemContainer &m) const
 
bool isCachedItemDirty (QueryPlanHash key, CachedItemContainer &m) const
 
std::shared_ptr
< CachedItemContainer
getCachedItemContainer (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
std::optional< CachedItem
< std::optional
< AutoTunerMetaInfo >
, EMPTY_META_INFO > > 
getCachedItemWithoutConsideringMetaInfo (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, CachedItemContainer &m, std::lock_guard< std::mutex > &lock)
 
size_t getCurrentNumCachedItems (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
size_t getCurrentNumDirtyCachedItems (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
size_t getCurrentNumCleanCachedItems (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
size_t getCurrentCacheSizeForDevice (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
std::shared_ptr< CacheItemMetricgetCachedItemMetric (CacheItemType item_type, DeviceIdentifier device_identifier, QueryPlanHash key) const
 
void setTotalCacheSize (CacheItemType item_type, size_t new_total_cache_size)
 
void setMaxCacheItemSize (CacheItemType item_type, size_t new_max_cache_item_size)
 

Private Member Functions

bool hasItemInCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) const override
 
void removeItemFromCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
 
void cleanupCacheForInsertion (CacheItemType item_type, DeviceIdentifier device_identifier, size_t required_size, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
 

Additional Inherited Members

- Public Types inherited from DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >
using CachedItemContainer = std::vector< CachedItem< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >>
 
using PerDeviceCacheItemContainer = std::unordered_map< DeviceIdentifier, std::shared_ptr< CachedItemContainer >>
 
using PerTypeCacheItemContainer = std::unordered_map< CacheItemType, std::shared_ptr< PerDeviceCacheItemContainer >>
 
using PerTypeCacheMetricTracker = std::unordered_map< CacheItemType, CacheMetricTracker >
 
- Protected Member Functions inherited from DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >
void removeCachedItemFromBeginning (CacheItemType item_type, DeviceIdentifier device_identifier, int offset)
 
void sortCacheContainerByQueryMetric (CacheItemType item_type, DeviceIdentifier device_identifier)
 
std::mutex & getCacheLock () const
 
CacheMetricTrackergetMetricTracker (CacheItemType item_type)
 
CacheMetricTracker const & getMetricTracker (CacheItemType item_type) const
 
std::unordered_set
< CacheItemType > const & 
getCacheItemType () const
 
PerTypeCacheItemContainer const & getItemCache () const
 

Detailed Description

Definition at line 32 of file BoundingBoxIntersectTuningParamRecycler.h.

Constructor & Destructor Documentation

BoundingBoxIntersectTuningParamRecycler::BoundingBoxIntersectTuningParamRecycler ( )
inline

Definition at line 38 of file BoundingBoxIntersectTuningParamRecycler.h.

References BBOX_INTERSECT_AUTO_TUNER_PARAM.

DataRecycler(const std::vector< CacheItemType > &item_types, size_t total_cache_size, size_t max_item_size, int num_gpus)
Definition: DataRecycler.h:458

Member Function Documentation

void BoundingBoxIntersectTuningParamRecycler::cleanupCacheForInsertion ( CacheItemType  item_type,
DeviceIdentifier  device_identifier,
size_t  required_size,
std::lock_guard< std::mutex > &  lock,
std::optional< EMPTY_META_INFO meta_info = std::nullopt 
)
inlineoverrideprivatevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 87 of file BoundingBoxIntersectTuningParamRecycler.h.

References UNREACHABLE.

92  {
93  UNREACHABLE();
94  }
#define UNREACHABLE()
Definition: Logger.h:338
void BoundingBoxIntersectTuningParamRecycler::clearCache ( )
overridevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 109 of file BoundingBoxIntersectTuningParamRecycler.cpp.

References BBOX_INTERSECT_AUTO_TUNER_PARAM, DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCacheLock(), DataRecyclerUtil::getDeviceIdentifierString(), PARAM_CACHE_DEVICE_IDENTIFIER, and VLOG.

109  {
110  std::lock_guard<std::mutex> lock(getCacheLock());
111  auto param_cache = getCachedItemContainer(
113  if (!param_cache->empty()) {
116  << "] clear cache (# items: " << param_cache->size() << ")";
117  param_cache->clear();
118  }
119 }
static std::string getDeviceIdentifierString(DeviceIdentifier device_identifier)
Definition: DataRecycler.h:138
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
constexpr DeviceIdentifier PARAM_CACHE_DEVICE_IDENTIFIER
#define VLOG(n)
Definition: Logger.h:388

+ Here is the call graph for this function:

std::optional< AutoTunerMetaInfo > BoundingBoxIntersectTuningParamRecycler::getItemFromCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
std::optional< EMPTY_META_INFO meta_info = std::nullopt 
)
overridevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 20 of file BoundingBoxIntersectTuningParamRecycler.cpp.

References BBOX_INTERSECT_AUTO_TUNER_PARAM, CHECK, CHECK_EQ, EMPTY_HASHED_PLAN_DAG_KEY, g_enable_data_recycler, g_use_hashtable_cache, DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemWithoutConsideringMetaInfo(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCacheLock(), DataRecyclerUtil::getDeviceIdentifierString(), and VLOG.

24  {
27  return std::nullopt;
28  }
30  std::lock_guard<std::mutex> lock(getCacheLock());
31  auto param_cache = getCachedItemContainer(item_type, device_identifier);
32  auto cached_param = getCachedItemWithoutConsideringMetaInfo(
33  key, item_type, device_identifier, *param_cache, lock);
34  if (cached_param) {
35  CHECK(!cached_param->isDirty());
36  VLOG(1) << "[" << item_type << ", "
38  << "] Recycle auto tuner parameters in cache (key: " << key << ")";
39  return cached_param->cached_item;
40  }
41  return std::nullopt;
42 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
static std::string getDeviceIdentifierString(DeviceIdentifier device_identifier)
Definition: DataRecycler.h:138
std::optional< CachedItem< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO > > getCachedItemWithoutConsideringMetaInfo(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, CachedItemContainer &m, std::lock_guard< std::mutex > &lock)
Definition: DataRecycler.h:543
constexpr QueryPlanHash EMPTY_HASHED_PLAN_DAG_KEY
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
bool g_enable_data_recycler
Definition: Execute.cpp:158
#define CHECK(condition)
Definition: Logger.h:291
bool g_use_hashtable_cache
Definition: Execute.cpp:159
#define VLOG(n)
Definition: Logger.h:388

+ Here is the call graph for this function:

bool BoundingBoxIntersectTuningParamRecycler::hasItemInCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
std::lock_guard< std::mutex > &  lock,
std::optional< EMPTY_META_INFO meta_info = std::nullopt 
) const
overrideprivatevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 71 of file BoundingBoxIntersectTuningParamRecycler.cpp.

References BBOX_INTERSECT_AUTO_TUNER_PARAM, CHECK_EQ, EMPTY_HASHED_PLAN_DAG_KEY, g_enable_data_recycler, g_use_hashtable_cache, and DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer().

76  {
79  return false;
80  }
82  auto param_cache = getCachedItemContainer(item_type, device_identifier);
83  auto candidate_it = std::find_if(
84  param_cache->begin(), param_cache->end(), [&key](const auto& cached_item) {
85  return cached_item.key == key;
86  });
87  return candidate_it != param_cache->end();
88 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
constexpr QueryPlanHash EMPTY_HASHED_PLAN_DAG_KEY
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
bool g_enable_data_recycler
Definition: Execute.cpp:158
bool g_use_hashtable_cache
Definition: Execute.cpp:159

+ Here is the call graph for this function:

void BoundingBoxIntersectTuningParamRecycler::initCache ( )
inlineoverridevirtual
void BoundingBoxIntersectTuningParamRecycler::markCachedItemAsDirty ( size_t  table_key,
std::unordered_set< QueryPlanHash > &  key_set,
CacheItemType  item_type,
DeviceIdentifier  device_identifier 
)
overridevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 121 of file BoundingBoxIntersectTuningParamRecycler.cpp.

References BBOX_INTERSECT_AUTO_TUNER_PARAM, CHECK_EQ, g_enable_data_recycler, g_use_hashtable_cache, DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCacheLock(), and DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::markCachedItemAsDirtyImpl().

125  {
126  if (!g_enable_data_recycler || !g_use_hashtable_cache || key_set.empty()) {
127  return;
128  }
130  std::lock_guard<std::mutex> lock(getCacheLock());
131  auto param_cache = getCachedItemContainer(item_type, device_identifier);
132  for (auto key : key_set) {
133  markCachedItemAsDirtyImpl(key, *param_cache);
134  }
135 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
void markCachedItemAsDirtyImpl(QueryPlanHash key, CachedItemContainer &m) const
Definition: DataRecycler.h:504
bool g_enable_data_recycler
Definition: Execute.cpp:158
bool g_use_hashtable_cache
Definition: Execute.cpp:159

+ Here is the call graph for this function:

void BoundingBoxIntersectTuningParamRecycler::putItemToCache ( QueryPlanHash  key,
std::optional< AutoTunerMetaInfo item,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
size_t  item_size,
size_t  compute_time,
std::optional< EMPTY_META_INFO meta_info = std::nullopt 
)
overridevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 44 of file BoundingBoxIntersectTuningParamRecycler.cpp.

References BBOX_INTERSECT_AUTO_TUNER_PARAM, CHECK_EQ, EMPTY_HASHED_PLAN_DAG_KEY, g_enable_data_recycler, g_use_hashtable_cache, DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemWithoutConsideringMetaInfo(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCacheLock(), DataRecyclerUtil::getDeviceIdentifierString(), and VLOG.

51  {
54  return;
55  }
57  std::lock_guard<std::mutex> lock(getCacheLock());
58  auto param_cache = getCachedItemContainer(item_type, device_identifier);
59  auto cached_param = getCachedItemWithoutConsideringMetaInfo(
60  key, item_type, device_identifier, *param_cache, lock);
61  if (cached_param) {
62  return;
63  }
64  param_cache->emplace_back(key, item, nullptr, meta_info);
65  VLOG(1) << "[" << item_type << ", "
67  << "] Put auto tuner parameters to cache (key: " << key << ")";
68  return;
69 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
static std::string getDeviceIdentifierString(DeviceIdentifier device_identifier)
Definition: DataRecycler.h:138
std::optional< CachedItem< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO > > getCachedItemWithoutConsideringMetaInfo(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, CachedItemContainer &m, std::lock_guard< std::mutex > &lock)
Definition: DataRecycler.h:543
constexpr QueryPlanHash EMPTY_HASHED_PLAN_DAG_KEY
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
bool g_enable_data_recycler
Definition: Execute.cpp:158
bool g_use_hashtable_cache
Definition: Execute.cpp:159
#define VLOG(n)
Definition: Logger.h:388

+ Here is the call graph for this function:

void BoundingBoxIntersectTuningParamRecycler::removeItemFromCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
std::lock_guard< std::mutex > &  lock,
std::optional< EMPTY_META_INFO meta_info = std::nullopt 
)
overrideprivatevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 90 of file BoundingBoxIntersectTuningParamRecycler.cpp.

References DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), DataRecyclerUtil::getDeviceIdentifierString(), and VLOG.

95  {
96  auto param_cache = getCachedItemContainer(item_type, device_identifier);
97  auto filter = [key](auto const& item) { return item.key == key; };
98  auto itr = std::find_if(param_cache->cbegin(), param_cache->cend(), filter);
99  if (itr == param_cache->cend()) {
100  return;
101  } else {
102  VLOG(1) << "[" << item_type << ", "
103  << DataRecyclerUtil::getDeviceIdentifierString(device_identifier)
104  << "] remove cached item from cache (key: " << key << ")";
105  param_cache->erase(itr);
106  }
107 }
static std::string getDeviceIdentifierString(DeviceIdentifier device_identifier)
Definition: DataRecycler.h:138
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
#define VLOG(n)
Definition: Logger.h:388

+ Here is the call graph for this function:

BoundingBoxIntersectTuningParamRecycler::std::numeric_limits ( )
BoundingBoxIntersectTuningParamRecycler::std::numeric_limits ( )
std::string BoundingBoxIntersectTuningParamRecycler::toString ( ) const
overridevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 137 of file BoundingBoxIntersectTuningParamRecycler.cpp.

References BBOX_INTERSECT_AUTO_TUNER_PARAM, DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), and PARAM_CACHE_DEVICE_IDENTIFIER.

137  {
138  std::ostringstream oss;
139  oss << "A current status of the Bounding Box Intersection Tuning Parameter Recycler:\n";
140  oss << "\t# cached parameters:\n";
141  oss << "\t\tDevice" << PARAM_CACHE_DEVICE_IDENTIFIER << "\n";
142  auto param_cache = getCachedItemContainer(
143  CacheItemType::BBOX_INTERSECT_AUTO_TUNER_PARAM, PARAM_CACHE_DEVICE_IDENTIFIER);
144  for (auto& cache_container : *param_cache) {
145  oss << "\t\t\tCache_key: " << cache_container.key;
146  if (cache_container.cached_item.has_value()) {
147  oss << ", Max_hashtable_size: " << cache_container.cached_item->max_hashtable_size
148  << ", Bucket_threshold: " << cache_container.cached_item->bucket_threshold
149  << ", Bucket_sizes: " << ::toString(cache_container.cached_item->bucket_sizes)
150  << "\n";
151  } else {
152  oss << ", Params info is not available\n";
153  }
154  }
155  return oss.str();
156 }
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
constexpr DeviceIdentifier PARAM_CACHE_DEVICE_IDENTIFIER

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: