OmniSciDB  c1a53651b2
 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 1299 of file Execute.h.

Constructor & Destructor Documentation

Executor::CgenStateManager::CgenStateManager ( Executor executor)

Definition at line 406 of file Execute.cpp.

References executor_, lock_queue_clock_, and timer_stop().

407  : executor_(executor)
409  , lock_(executor_.compilation_mutex_)
410  , cgen_state_(std::move(executor_.cgen_state_)) // store old CgenState instance
411 {
412  executor_.compilation_queue_time_ms_ += timer_stop(lock_queue_clock_);
413  executor_.cgen_state_.reset(new CgenState(0, false, &executor));
414 }
TypeR::rep timer_stop(Type clock_begin)
Definition: measure.h:48
std::unique_ptr< CgenState > cgen_state_
Definition: Execute.h:1313
std::lock_guard< std::mutex > lock_
Definition: Execute.h:1312
std::chrono::steady_clock::time_point lock_queue_clock_
Definition: Execute.h:1311
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 416 of file Execute.cpp.

References executor_, lock_queue_clock_, and timer_stop().

422  : executor_(executor)
424  , lock_(executor_.compilation_mutex_)
425  , cgen_state_(std::move(executor_.cgen_state_)) // store old CgenState instance
426 {
427  executor_.compilation_queue_time_ms_ += timer_stop(lock_queue_clock_);
428  // nukeOldState creates new CgenState and PlanState instances for
429  // the subsequent code generation. It also resets
430  // kernel_queue_time_ms_ and compilation_queue_time_ms_ that we do
431  // not currently restore.. should we accumulate these timings?
432  executor_.nukeOldState(allow_lazy_fetch, query_infos, deleted_cols_map, ra_exe_unit);
433 }
TypeR::rep timer_stop(Type clock_begin)
Definition: measure.h:48
std::unique_ptr< CgenState > cgen_state_
Definition: Execute.h:1313
std::lock_guard< std::mutex > lock_
Definition: Execute.h:1312
std::chrono::steady_clock::time_point lock_queue_clock_
Definition: Execute.h:1311
Type timer_start()
Definition: measure.h:42

+ Here is the call graph for this function:

Executor::CgenStateManager::~CgenStateManager ( )

Definition at line 435 of file Execute.cpp.

References Executor::cgen_state_, and executor_().

435  {
436  // prevent memory leak from hoisted literals
437  for (auto& p : executor_.cgen_state_->row_func_hoisted_literals_) {
438  auto inst = llvm::dyn_cast<llvm::LoadInst>(p.first);
439  if (inst && inst->getNumUses() == 0 && inst->getParent() == nullptr) {
440  // The llvm::Value instance stored in p.first is created by the
441  // CodeGenerator::codegenHoistedConstantsPlaceholders method.
442  p.first->deleteValue();
443  }
444  }
445  executor_.cgen_state_->row_func_hoisted_literals_.clear();
446 
447  // move generated StringDictionaryTranslationMgrs and InValueBitmaps
448  // to the old CgenState instance as the execution of the generated
449  // code uses these bitmaps
450 
451  for (auto& str_dict_translation_mgr :
452  executor_.cgen_state_->str_dict_translation_mgrs_) {
453  cgen_state_->moveStringDictionaryTranslationMgr(std::move(str_dict_translation_mgr));
454  }
455  executor_.cgen_state_->str_dict_translation_mgrs_.clear();
456 
457  for (auto& bm : executor_.cgen_state_->in_values_bitmaps_) {
458  cgen_state_->moveInValuesBitmap(bm);
459  }
460  executor_.cgen_state_->in_values_bitmaps_.clear();
461 
462  // Delete worker module that may have been set by
463  // set_module_shallow_copy. If QueryMustRunOnCpu is thrown, the
464  // worker module is not instantiated, so the worker module needs to
465  // be deleted conditionally [see "Managing LLVM modules" comment in
466  // CgenState.h]:
467  if (executor_.cgen_state_->module_) {
468  delete executor_.cgen_state_->module_;
469  }
470 
471  // restore the old CgenState instance
472  executor_.cgen_state_.reset(cgen_state_.release());
473 }
std::unique_ptr< CgenState > cgen_state_
Definition: Execute.h:1313

+ Here is the call graph for this function:

Member Data Documentation

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

Definition at line 1313 of file Execute.h.

Executor& Executor::CgenStateManager::executor_
private

Definition at line 1310 of file Execute.h.

Referenced by CgenStateManager().

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

Definition at line 1312 of file Execute.h.

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

Definition at line 1311 of file Execute.h.

Referenced by CgenStateManager().


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