OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Executor::CgenStateManager Class Reference

#include <Execute.h>

+ Collaboration diagram for Executor::CgenStateManager:

Public Member Functions

 CgenStateManager (Executor &executor)
 
 CgenStateManager (Executor &executor, const bool allow_lazy_fetch, const std::vector< InputTableInfo > &query_infos, const PlanState::DeletedColumnsMap &deleted_cols_map, const RelAlgExecutionUnit *ra_exe_unit)
 
 ~CgenStateManager ()
 

Private Attributes

Executorexecutor_
 
std::chrono::steady_clock::time_point lock_queue_clock_
 
std::lock_guard< std::mutex > lock_
 
std::unique_ptr< CgenStatecgen_state_
 

Detailed Description

Definition at line 1484 of file Execute.h.

Constructor & Destructor Documentation

Executor::CgenStateManager::CgenStateManager ( Executor executor)

Definition at line 434 of file Execute.cpp.

References executor_, lock_queue_clock_, and timer_stop().

435  : executor_(executor)
437  , lock_(executor_.compilation_mutex_)
438  , cgen_state_(std::move(executor_.cgen_state_)) // store old CgenState instance
439 {
440  executor_.compilation_queue_time_ms_ += timer_stop(lock_queue_clock_);
441  executor_.cgen_state_.reset(new CgenState(0, false, &executor));
442 }
TypeR::rep timer_stop(Type clock_begin)
Definition: measure.h:48
std::unique_ptr< CgenState > cgen_state_
Definition: Execute.h:1498
std::lock_guard< std::mutex > lock_
Definition: Execute.h:1497
std::chrono::steady_clock::time_point lock_queue_clock_
Definition: Execute.h:1496
Type timer_start()
Definition: measure.h:42

+ Here is the call graph for this function:

Executor::CgenStateManager::CgenStateManager ( Executor executor,
const bool  allow_lazy_fetch,
const std::vector< InputTableInfo > &  query_infos,
const PlanState::DeletedColumnsMap deleted_cols_map,
const RelAlgExecutionUnit ra_exe_unit 
)

Definition at line 444 of file Execute.cpp.

References executor_, lock_queue_clock_, and timer_stop().

450  : executor_(executor)
452  , lock_(executor_.compilation_mutex_)
453  , cgen_state_(std::move(executor_.cgen_state_)) // store old CgenState instance
454 {
455  executor_.compilation_queue_time_ms_ += timer_stop(lock_queue_clock_);
456  // nukeOldState creates new CgenState and PlanState instances for
457  // the subsequent code generation. It also resets
458  // kernel_queue_time_ms_ and compilation_queue_time_ms_ that we do
459  // not currently restore.. should we accumulate these timings?
460  executor_.nukeOldState(allow_lazy_fetch, query_infos, deleted_cols_map, ra_exe_unit);
461 }
TypeR::rep timer_stop(Type clock_begin)
Definition: measure.h:48
std::unique_ptr< CgenState > cgen_state_
Definition: Execute.h:1498
std::lock_guard< std::mutex > lock_
Definition: Execute.h:1497
std::chrono::steady_clock::time_point lock_queue_clock_
Definition: Execute.h:1496
Type timer_start()
Definition: measure.h:42

+ Here is the call graph for this function:

Executor::CgenStateManager::~CgenStateManager ( )

Definition at line 463 of file Execute.cpp.

References Executor::cgen_state_, and executor_().

463  {
464  // prevent memory leak from hoisted literals
465  for (auto& p : executor_.cgen_state_->row_func_hoisted_literals_) {
466  auto inst = llvm::dyn_cast<llvm::LoadInst>(p.first);
467  if (inst && inst->getNumUses() == 0 && inst->getParent() == nullptr) {
468  // The llvm::Value instance stored in p.first is created by the
469  // CodeGenerator::codegenHoistedConstantsPlaceholders method.
470  p.first->deleteValue();
471  }
472  }
473  executor_.cgen_state_->row_func_hoisted_literals_.clear();
474 
475  // move generated StringDictionaryTranslationMgrs and InValueBitmaps
476  // to the old CgenState instance as the execution of the generated
477  // code uses these bitmaps
478 
479  for (auto& bm : executor_.cgen_state_->in_values_bitmaps_) {
480  cgen_state_->moveInValuesBitmap(bm);
481  }
482  executor_.cgen_state_->in_values_bitmaps_.clear();
483 
484  for (auto& str_dict_translation_mgr :
485  executor_.cgen_state_->str_dict_translation_mgrs_) {
486  cgen_state_->moveStringDictionaryTranslationMgr(std::move(str_dict_translation_mgr));
487  }
488  executor_.cgen_state_->str_dict_translation_mgrs_.clear();
489 
490  for (auto& tree_model_prediction_mgr :
491  executor_.cgen_state_->tree_model_prediction_mgrs_) {
492  cgen_state_->moveTreeModelPredictionMgr(std::move(tree_model_prediction_mgr));
493  }
494  executor_.cgen_state_->tree_model_prediction_mgrs_.clear();
495 
496  // Delete worker module that may have been set by
497  // set_module_shallow_copy. If QueryMustRunOnCpu is thrown, the
498  // worker module is not instantiated, so the worker module needs to
499  // be deleted conditionally [see "Managing LLVM modules" comment in
500  // CgenState.h]:
501  if (executor_.cgen_state_->module_) {
502  delete executor_.cgen_state_->module_;
503  }
504 
505  // restore the old CgenState instance
506  executor_.cgen_state_.reset(cgen_state_.release());
507 }
std::unique_ptr< CgenState > cgen_state_
Definition: Execute.h:1498

+ Here is the call graph for this function:

Member Data Documentation

std::unique_ptr<CgenState> Executor::CgenStateManager::cgen_state_
private

Definition at line 1498 of file Execute.h.

Executor& Executor::CgenStateManager::executor_
private

Definition at line 1495 of file Execute.h.

Referenced by CgenStateManager().

std::lock_guard<std::mutex> Executor::CgenStateManager::lock_
private

Definition at line 1497 of file Execute.h.

std::chrono::steady_clock::time_point Executor::CgenStateManager::lock_queue_clock_
private

Definition at line 1496 of file Execute.h.

Referenced by CgenStateManager().


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