OmniSciDB  a5dc49c757
 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 438 of file Execute.cpp.

References executor_, lock_queue_clock_, and timer_stop().

439  : executor_(executor)
441  , lock_(executor_.compilation_mutex_)
442  , cgen_state_(std::move(executor_.cgen_state_)) // store old CgenState instance
443 {
444  executor_.compilation_queue_time_ms_ += timer_stop(lock_queue_clock_);
445  executor_.cgen_state_.reset(new CgenState(0, false, &executor));
446 }
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 448 of file Execute.cpp.

References executor_, lock_queue_clock_, and timer_stop().

454  : executor_(executor)
456  , lock_(executor_.compilation_mutex_)
457  , cgen_state_(std::move(executor_.cgen_state_)) // store old CgenState instance
458 {
459  executor_.compilation_queue_time_ms_ += timer_stop(lock_queue_clock_);
460  // nukeOldState creates new CgenState and PlanState instances for
461  // the subsequent code generation. It also resets
462  // kernel_queue_time_ms_ and compilation_queue_time_ms_ that we do
463  // not currently restore.. should we accumulate these timings?
464  executor_.nukeOldState(allow_lazy_fetch, query_infos, deleted_cols_map, ra_exe_unit);
465 }
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 467 of file Execute.cpp.

References Executor::cgen_state_, and executor_().

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