OmniSciDB  a987f07e93
 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 1306 of file Execute.h.

Constructor & Destructor Documentation

Executor::CgenStateManager::CgenStateManager ( Executor executor)

Definition at line 408 of file Execute.cpp.

References executor_, lock_queue_clock_, and timer_stop().

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

References executor_, lock_queue_clock_, and timer_stop().

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

+ Here is the call graph for this function:

Executor::CgenStateManager::~CgenStateManager ( )

Definition at line 437 of file Execute.cpp.

References Executor::cgen_state_.

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

Member Data Documentation

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

Definition at line 1320 of file Execute.h.

Executor& Executor::CgenStateManager::executor_
private

Definition at line 1317 of file Execute.h.

Referenced by CgenStateManager().

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

Definition at line 1319 of file Execute.h.

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

Definition at line 1318 of file Execute.h.

Referenced by CgenStateManager().


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