OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Execute.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef QUERYENGINE_EXECUTE_H
18 #define QUERYENGINE_EXECUTE_H
19 
20 #include <algorithm>
21 #include <atomic>
22 #include <condition_variable>
23 #include <cstddef>
24 #include <cstdlib>
25 #include <deque>
26 #include <functional>
27 #include <limits>
28 #include <map>
29 #include <mutex>
30 #include <queue>
31 #include <stack>
32 #include <unordered_map>
33 #include <unordered_set>
34 
35 #include <llvm/IR/Function.h>
36 #include <llvm/IR/Value.h>
37 #include <llvm/Linker/Linker.h>
38 #include <llvm/Transforms/Utils/ValueMapper.h>
39 #include <rapidjson/document.h>
40 
44 #include "QueryEngine/CgenState.h"
45 #include "QueryEngine/CodeCache.h"
58 #include "QueryEngine/PlanState.h"
67 
68 #include "DataMgr/Chunk/Chunk.h"
69 #include "Logger/Logger.h"
71 #include "Shared/funcannotations.h"
73 #include "Shared/measure.h"
74 #include "Shared/thread_count.h"
75 #include "Shared/toString.h"
80 
81 using QueryCompilationDescriptorOwned = std::unique_ptr<QueryCompilationDescriptor>;
83 using QueryMemoryDescriptorOwned = std::unique_ptr<QueryMemoryDescriptor>;
84 using QuerySessionId = std::string;
85 using CurrentQueryStatus = std::pair<QuerySessionId, std::string>;
86 using InterruptFlagMap = std::map<QuerySessionId, bool>;
88  // A class that is used to describe the query session's info
89  public:
90  /* todo(yoonmin): support more query status
91  * i.e., RUNNING_SORT, RUNNING_CARD_EST, CLEANUP, ... */
92  enum QueryStatus {
93  UNDEFINED = 0,
99  };
100 
101  QuerySessionStatus(const QuerySessionId& query_session,
102  const std::string& query_str,
103  const std::string& submitted_time)
104  : query_session_(query_session)
105  , executor_id_(0)
106  , query_str_(query_str)
107  , submitted_time_(submitted_time)
109  QuerySessionStatus(const QuerySessionId& query_session,
110  const size_t executor_id,
111  const std::string& query_str,
112  const std::string& submitted_time)
113  : query_session_(query_session)
114  , executor_id_(executor_id)
115  , query_str_(query_str)
116  , submitted_time_(submitted_time)
118  QuerySessionStatus(const QuerySessionId& query_session,
119  const size_t executor_id,
120  const std::string& query_str,
121  const std::string& submitted_time,
122  const QuerySessionStatus::QueryStatus& query_status)
123  : query_session_(query_session)
124  , executor_id_(executor_id)
125  , query_str_(query_str)
126  , submitted_time_(submitted_time)
127  , query_status_(query_status) {}
128 
130  const std::string getQueryStr() { return query_str_; }
131  const size_t getExecutorId() { return executor_id_; }
132  const std::string& getQuerySubmittedTime() { return submitted_time_; }
135  query_status_ = status;
136  }
137  void setExecutorId(const size_t executor_id) { executor_id_ = executor_id; }
138 
139  private:
141  size_t executor_id_;
142  const std::string query_str_;
143  const std::string submitted_time_;
144  // Currently we use three query status:
145  // 1) PENDING_IN_QUEUE: a task is submitted to the dispatch_queue but hangs due to no
146  // existing worker (= executor) 2) PENDING_IN_EXECUTOR: a task is assigned to the
147  // specific executor but waits to get the resource to run 3) RUNNING: a task is assigned
148  // to the specific executor and its execution has been successfully started
149  // 4) RUNNING_REDUCTION: a task is in the reduction phase
151 };
152 using QuerySessionMap =
153  std::map<const QuerySessionId, std::map<std::string, QuerySessionStatus>>;
154 
155 class ColumnFetcher;
156 
157 class WatchdogException : public std::runtime_error {
158  public:
159  WatchdogException(const std::string& cause) : std::runtime_error(cause) {}
160 };
161 
163 
164 class Executor;
165 
166 inline llvm::Value* get_arg_by_name(llvm::Function* func, const std::string& name) {
167  for (auto& arg : func->args()) {
168  if (arg.getName() == name) {
169  return &arg;
170  }
171  }
172  CHECK(false);
173  return nullptr;
174 }
175 
176 inline uint32_t log2_bytes(const uint32_t bytes) {
177  switch (bytes) {
178  case 1:
179  return 0;
180  case 2:
181  return 1;
182  case 4:
183  return 2;
184  case 8:
185  return 3;
186  default:
187  abort();
188  }
189 }
190 
192  const int col_id,
193  const int table_id,
195  CHECK_GT(table_id, 0);
196  const auto col_desc = cat.getMetadataForColumn(table_id, col_id);
197  CHECK(col_desc);
198  return col_desc;
199 }
200 
201 inline const Analyzer::Expr* extract_cast_arg(const Analyzer::Expr* expr) {
202  const auto cast_expr = dynamic_cast<const Analyzer::UOper*>(expr);
203  if (!cast_expr || cast_expr->get_optype() != kCAST) {
204  return expr;
205  }
206  return cast_expr->get_operand();
207 }
208 
209 inline std::string numeric_type_name(const SQLTypeInfo& ti) {
210  CHECK(ti.is_integer() || ti.is_decimal() || ti.is_boolean() || ti.is_time() ||
211  ti.is_fp() || (ti.is_string() && ti.get_compression() == kENCODING_DICT) ||
212  ti.is_timeinterval());
213  if (ti.is_integer() || ti.is_decimal() || ti.is_boolean() || ti.is_time() ||
214  ti.is_string() || ti.is_timeinterval()) {
215  return "int" + std::to_string(ti.get_logical_size() * 8) + "_t";
216  }
217  return ti.get_type() == kDOUBLE ? "double" : "float";
218 }
219 
221  const int col_id,
222  const int table_id,
224  CHECK(table_id);
225  return table_id > 0 ? get_column_descriptor(col_id, table_id, cat) : nullptr;
226 }
227 
228 inline const ResultSetPtr& get_temporary_table(const TemporaryTables* temporary_tables,
229  const int table_id) {
230  CHECK_LT(table_id, 0);
231  const auto it = temporary_tables->find(table_id);
232  CHECK(it != temporary_tables->end());
233  return it->second;
234 }
235 
236 inline const SQLTypeInfo get_column_type(const int col_id,
237  const int table_id,
238  const ColumnDescriptor* cd,
239  const TemporaryTables* temporary_tables) {
240  CHECK(cd || temporary_tables);
241  if (cd) {
242  CHECK_EQ(col_id, cd->columnId);
243  CHECK_EQ(table_id, cd->tableId);
244  return cd->columnType;
245  }
246  const auto& temp = get_temporary_table(temporary_tables, table_id);
247  return temp->getColType(col_id);
248 }
249 
250 class CompilationRetryNoLazyFetch : public std::runtime_error {
251  public:
253  : std::runtime_error("Retry query compilation with no GPU lazy fetch.") {}
254 };
255 
256 class CompilationRetryNewScanLimit : public std::runtime_error {
257  public:
258  CompilationRetryNewScanLimit(const size_t new_scan_limit)
259  : std::runtime_error("Retry query compilation with new scan limit.")
260  , new_scan_limit_(new_scan_limit) {}
261 
263 };
264 
265 class TooManyLiterals : public std::runtime_error {
266  public:
267  TooManyLiterals() : std::runtime_error("Too many literals in the query") {}
268 };
269 
270 class CompilationRetryNoCompaction : public std::runtime_error {
271  public:
273  : std::runtime_error("Retry query compilation with no compaction.") {}
274 };
275 
276 // Throwing QueryMustRunOnCpu allows us retry a query step on CPU if
277 // g_allow_query_step_cpu_retry is true (on by default) by catching
278 // the exception at the query step execution level in RelAlgExecutor,
279 // or if g_allow_query_step_cpu_retry is false but g_allow_cpu_retry is true,
280 // by retrying the entire query on CPU (if both flags are false, we return an
281 // error). This flag is thrown for the following broad categories of conditions:
282 // 1) we have not implemented an operator on GPU and so cannot codegen for GPU
283 // 2) we catch an unexpected GPU compilation/linking error (perhaps due
284 // to an outdated driver/CUDA installation not allowing a modern operator)
285 // 3) when we detect up front that we will not have enough GPU memory to execute
286 // a query.
287 // There is a fourth scenerio where our pre-flight GPU memory check passed but for
288 // whatever reason we still run out of memory. In those cases we go down the
289 // handleOutOfMemoryRetry path, which will first try per-fragment execution on GPU,
290 // and if that fails, CPU execution.
291 // Note that for distributed execution failures on leaves, we do not retry queries
292 // TODO(todd): See if CPU retry of individual steps can be turned on safely for
293 // distributed
294 
295 class QueryMustRunOnCpu : public std::runtime_error {
296  public:
297  QueryMustRunOnCpu() : std::runtime_error("Query must run in cpu mode.") {}
298 
299  QueryMustRunOnCpu(const std::string& err) : std::runtime_error(err) {}
300 };
301 
302 class ParseIRError : public std::runtime_error {
303  public:
304  ParseIRError(const std::string message) : std::runtime_error(message) {}
305 };
306 
307 class StringConstInResultSet : public std::runtime_error {
308  public:
310  : std::runtime_error(
311  "NONE ENCODED String types are not supported as input result set.") {}
312 };
313 
314 class ExtensionFunction;
315 
317 using ColumnToFragmentsMap = std::map<const ColumnDescriptor*, std::set<int32_t>>;
318 using TableToFragmentIds = std::map<int32_t, std::set<int32_t>>;
319 
323 };
324 
326  public:
328 
329  UpdateLogForFragment(FragmentInfoType const& fragment_info,
330  size_t const,
331  const std::shared_ptr<ResultSet>& rs);
332 
333  std::vector<TargetValue> getEntryAt(const size_t index) const override;
334  std::vector<TargetValue> getTranslatedEntryAt(const size_t index) const override;
335 
336  size_t const getRowCount() const override;
338  return rs_->getRowSetMemOwner()->getLiteralStringDictProxy();
339  }
340  size_t const getEntryCount() const override;
341  size_t const getFragmentIndex() const;
342  FragmentInfoType const& getFragmentInfo() const;
345  }
346  decltype(FragmentInfoType::fragmentId) const getFragmentId() const {
347  return fragment_info_.fragmentId;
348  }
349 
350  SQLTypeInfo getColumnType(const size_t col_idx) const;
351 
352  using Callback = std::function<void(const UpdateLogForFragment&, TableUpdateMetadata&)>;
353 
354  auto getResultSet() const { return rs_; }
355 
356  private:
359  std::shared_ptr<ResultSet> rs_;
360 };
361 
362 using LLVMValueVector = std::vector<llvm::Value*>;
363 
365 
366 std::ostream& operator<<(std::ostream&, FetchResult const&);
367 
368 class Executor {
369  static_assert(sizeof(float) == 4 && sizeof(double) == 8,
370  "Host hardware not supported, unexpected size of float / double.");
371  static_assert(sizeof(time_t) == 8,
372  "Host hardware not supported, 64-bit time support is required.");
373 
374  public:
375  using ExecutorId = size_t;
376  static const ExecutorId UNITARY_EXECUTOR_ID = 0;
377  static const ExecutorId INVALID_EXECUTOR_ID = SIZE_MAX;
378 
379  Executor(const ExecutorId id,
380  Data_Namespace::DataMgr* data_mgr,
381  const size_t block_size_x,
382  const size_t grid_size_x,
383  const size_t max_gpu_slab_size,
384  const std::string& debug_dir,
385  const std::string& debug_file);
386 
387  void clearCaches(bool runtime_only = false);
388 
389  std::string dumpCache() const;
390 
391  static void clearExternalCaches(bool for_update,
392  const TableDescriptor* td,
393  const int current_db_id) {
394  bool clearEntireCache = true;
395  if (td) {
396  const auto& table_chunk_key_prefix = td->getTableChunkKey(current_db_id);
397  if (!table_chunk_key_prefix.empty()) {
398  auto table_key = boost::hash_value(table_chunk_key_prefix);
400  if (for_update) {
402  } else {
404  }
405  clearEntireCache = false;
406  }
407  }
408  if (clearEntireCache) {
410  if (for_update) {
412  } else {
414  }
415  }
416  }
417 
418  void reset(bool discard_runtime_modules_only = false);
419 
420  template <typename F>
421  static void registerExtensionFunctions(F register_extension_functions) {
422  // Don't want native code to vanish while executing:
423  mapd_unique_lock<mapd_shared_mutex> flush_lock(execute_mutex_);
424  // Blocks Executor::getExecutor:
425  mapd_unique_lock<mapd_shared_mutex> lock(executors_cache_mutex_);
426  // Lock registration to avoid
427  // java.util.ConcurrentModificationException from calcite server
428  // when client registrations arrive too fast. Also blocks
429  // Executor::get_rt_udf_module for retrieving runtime UDF/UDTF
430  // module until this registration has rebuild it via
431  // Executor::update_after_registration:
432  std::lock_guard<std::mutex> register_lock(
434 
435  // Reset all executors:
436  for (auto& executor_item : Executor::executors_) {
437  executor_item.second->reset(/*discard_runtime_modules_only=*/true);
438  }
439  // Call registration worker, see
440  // DBHandler::register_runtime_extension_functions for details. In
441  // short, updates Executor::extension_module_sources,
442  // table_functions::TableFunctionsFactory, and registers runtime
443  // extension functions with Calcite:
444  register_extension_functions();
445 
446  // Update executors with registered LLVM modules:
447  update_after_registration(/*update_runtime_modules_only=*/true);
448  }
449 
450  static std::shared_ptr<Executor> getExecutor(
451  const ExecutorId id,
452  const std::string& debug_dir = "",
453  const std::string& debug_file = "",
454  const SystemParameters& system_parameters = SystemParameters());
455 
456  static void nukeCacheOfExecutors() {
457  mapd_unique_lock<mapd_shared_mutex> flush_lock(
458  execute_mutex_); // don't want native code to vanish while executing
459  mapd_unique_lock<mapd_shared_mutex> lock(executors_cache_mutex_);
460  (decltype(executors_){}).swap(executors_);
461  }
462 
463  static void clearMemory(const Data_Namespace::MemoryLevel memory_level);
464 
465  static size_t getArenaBlockSize();
466 
467  static void addUdfIrToModule(const std::string& udf_ir_filename, const bool is_cuda_ir);
468 
469  enum class ExtModuleKinds {
470  template_module, // RuntimeFunctions.bc
471  udf_cpu_module, // Load-time UDFs for CPU execution
472  udf_gpu_module, // Load-time UDFs for GPU execution
473  rt_udf_cpu_module, // Run-time UDF/UDTFs for CPU execution
474  rt_udf_gpu_module, // Run-time UDF/UDTFs for GPU execution
475  rt_geos_module, // geos functions
476  rt_libdevice_module // math library functions for GPU execution
477  };
478  // Globally available mapping of extension module sources. Not thread-safe.
479  static std::map<ExtModuleKinds, std::string> extension_module_sources;
481 
482  // Convenience functions for retrieving executor-local extension modules, thread-safe:
483  const std::unique_ptr<llvm::Module>& get_rt_module() const {
485  }
486  const std::unique_ptr<llvm::Module>& get_udf_module(bool is_gpu = false) const {
487  return get_extension_module(
489  }
490  const std::unique_ptr<llvm::Module>& get_rt_udf_module(bool is_gpu = false) const {
491  std::lock_guard<std::mutex> lock(
493  return get_extension_module(
495  }
496  const std::unique_ptr<llvm::Module>& get_geos_module() const {
498  }
499  const std::unique_ptr<llvm::Module>& get_libdevice_module() const {
501  }
502 
503  bool has_rt_module() const {
505  }
506  bool has_udf_module(bool is_gpu = false) const {
507  return has_extension_module(
509  }
510  bool has_rt_udf_module(bool is_gpu = false) const {
511  return has_extension_module(
513  }
514  bool has_geos_module() const {
516  }
517  bool has_libdevice_module() const {
519  }
520 
525 
530  const bool with_generation) const {
532  return getStringDictionaryProxy(dict_id, row_set_mem_owner_, with_generation);
533  }
534 
536  const int dictId,
537  const std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
538  const bool with_generation) const;
539 
541  const int source_dict_id,
542  const int dest_dict_id,
543  const RowSetMemoryOwner::StringTranslationType translation_type,
544  const std::vector<StringOps_Namespace::StringOpInfo>& string_op_infos,
545  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
546  const bool with_generation) const;
547 
549  const StringDictionaryProxy* source_proxy,
550  StringDictionaryProxy* dest_proxy,
551  const std::vector<StringOps_Namespace::StringOpInfo>& source_string_op_infos,
552  const std::vector<StringOps_Namespace::StringOpInfo>& dest_source_string_op_infos,
553  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner) const;
554 
555  bool isCPUOnly() const;
556 
557  bool isArchMaxwell(const ExecutorDeviceType dt) const;
558 
560  return cgen_state_->contains_left_deep_outer_join_;
561  }
562 
564 
566  int) const;
567 
568  const Catalog_Namespace::Catalog* getCatalog() const;
569  void setCatalog(const Catalog_Namespace::Catalog* catalog);
570 
572  CHECK(data_mgr_);
573  return data_mgr_;
574  }
575 
576  const std::shared_ptr<RowSetMemoryOwner> getRowSetMemoryOwner() const;
577 
578  const TemporaryTables* getTemporaryTables() const;
579 
580  Fragmenter_Namespace::TableInfo getTableInfo(const int table_id) const;
581 
582  const TableGeneration& getTableGeneration(const int table_id) const;
583 
585 
586  size_t getNumBytesForFetchedRow(const std::set<int>& table_ids_to_fetch) const;
587 
588  bool hasLazyFetchColumns(const std::vector<Analyzer::Expr*>& target_exprs) const;
589  std::vector<ColumnLazyFetchInfo> getColLazyFetchInfo(
590  const std::vector<Analyzer::Expr*>& target_exprs) const;
591 
592  static void registerActiveModule(void* module, const int device_id);
593  static void unregisterActiveModule(const int device_id);
594  void interrupt(const QuerySessionId& query_session = "",
595  const QuerySessionId& interrupt_session = "");
596  void resetInterrupt();
597 
598  // only for testing usage
599  void enableRuntimeQueryInterrupt(const double runtime_query_check_freq,
600  const unsigned pending_query_check_freq) const;
601 
602  static const size_t high_scan_limit{128000000};
603 
604  int8_t warpSize() const;
605  unsigned gridSize() const;
606  unsigned numBlocksPerMP() const;
607  unsigned blockSize() const;
608  size_t maxGpuSlabSize() const;
609 
610  ResultSetPtr executeWorkUnit(size_t& max_groups_buffer_entry_guess,
611  const bool is_agg,
612  const std::vector<InputTableInfo>&,
613  const RelAlgExecutionUnit&,
614  const CompilationOptions&,
615  const ExecutionOptions& options,
617  RenderInfo* render_info,
618  const bool has_cardinality_estimation,
619  ColumnCacheMap& column_cache);
620 
622  const std::vector<InputTableInfo>& table_infos,
623  const TableDescriptor* updated_table_desc,
624  const CompilationOptions& co,
625  const ExecutionOptions& eo,
627  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
629  const bool is_agg);
630 
632  const RelAlgExecutionUnit& ra_exe_unit,
633  const std::shared_ptr<RowSetMemoryOwner>& row_set_mem_owner);
634 
635  int deviceCount(const ExecutorDeviceType) const;
636 
637  private:
638  void clearMetaInfoCache();
639 
640  int deviceCountForMemoryLevel(const Data_Namespace::MemoryLevel memory_level) const;
641 
642  // Generate code for a window function target.
643  llvm::Value* codegenWindowFunction(const size_t target_index,
644  const CompilationOptions& co);
645 
646  // Generate code for an aggregate window function target.
647  llvm::Value* codegenWindowFunctionAggregate(const CompilationOptions& co);
648 
649  // The aggregate state requires a state reset when starting a new partition. Generate
650  // the new partition check and return the continuation basic block.
651  llvm::BasicBlock* codegenWindowResetStateControlFlow();
652 
653  // Generate code for initializing the state of a window aggregate.
654  void codegenWindowFunctionStateInit(llvm::Value* aggregate_state);
655 
656  // Generates the required calls for an aggregate window function and returns the final
657  // result.
658  llvm::Value* codegenWindowFunctionAggregateCalls(llvm::Value* aggregate_state,
659  const CompilationOptions& co);
660 
661  // The AVG window function requires some post-processing: the sum is divided by count
662  // and the result is stored back for the current row.
663  void codegenWindowAvgEpilogue(llvm::Value* crt_val,
664  llvm::Value* window_func_null_val,
665  llvm::Value* multiplicity_lv);
666 
667  // Generates code which loads the current aggregate value for the window context.
668  llvm::Value* codegenAggregateWindowState();
669 
670  llvm::Value* aggregateWindowStatePtr();
671 
673  CHECK(data_mgr_);
674  auto cuda_mgr = data_mgr_->getCudaMgr();
675  CHECK(cuda_mgr);
676  return cuda_mgr;
677  }
678 
680  if (dt == ExecutorDeviceType::GPU) {
681  return cudaMgr()->isArchPascalOrLater();
682  }
683  return false;
684  }
685 
686  bool needFetchAllFragments(const InputColDescriptor& col_desc,
687  const RelAlgExecutionUnit& ra_exe_unit,
688  const FragmentsList& selected_fragments) const;
689 
691  const InputColDescriptor& inner_col_desc,
692  const RelAlgExecutionUnit& ra_exe_unit,
693  const FragmentsList& selected_fragments,
694  const Data_Namespace::MemoryLevel memory_level) const;
695 
696  using PerFragmentCallBack =
697  std::function<void(ResultSetPtr, const Fragmenter_Namespace::FragmentInfo&)>;
698 
704  void executeWorkUnitPerFragment(const RelAlgExecutionUnit& ra_exe_unit,
705  const InputTableInfo& table_info,
706  const CompilationOptions& co,
707  const ExecutionOptions& eo,
710  const std::set<size_t>& fragment_indexes_param);
711 
713 
720  const std::vector<InputTableInfo>& table_infos,
721  const CompilationOptions& co,
722  const ExecutionOptions& eo,
724 
726  const RelAlgExecutionUnit& ra_exe_unit,
727  const ExecutorDeviceType requested_device_type);
728 
730  SharedKernelContext& shared_context,
731  const RelAlgExecutionUnit& ra_exe_unit,
733  const ExecutorDeviceType device_type,
734  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner);
735 
737  SharedKernelContext& shared_context,
738  const RelAlgExecutionUnit& ra_exe_unit) const;
739 
740  std::unordered_map<int, const Analyzer::BinOper*> getInnerTabIdToJoinCond() const;
741 
746  std::vector<std::unique_ptr<ExecutionKernel>> createKernels(
747  SharedKernelContext& shared_context,
748  const RelAlgExecutionUnit& ra_exe_unit,
749  ColumnFetcher& column_fetcher,
750  const std::vector<InputTableInfo>& table_infos,
751  const ExecutionOptions& eo,
752  const bool is_agg,
753  const bool allow_single_frag_table_opt,
754  const size_t context_count,
755  const QueryCompilationDescriptor& query_comp_desc,
757  RenderInfo* render_info,
758  std::unordered_set<int>& available_gpus,
759  int& available_cpus);
760 
765  void launchKernels(SharedKernelContext& shared_context,
766  std::vector<std::unique_ptr<ExecutionKernel>>&& kernels,
767  const ExecutorDeviceType device_type);
768 
769  std::vector<size_t> getTableFragmentIndices(
770  const RelAlgExecutionUnit& ra_exe_unit,
771  const ExecutorDeviceType device_type,
772  const size_t table_idx,
773  const size_t outer_frag_idx,
774  std::map<int, const TableFragments*>& selected_tables_fragments,
775  const std::unordered_map<int, const Analyzer::BinOper*>&
776  inner_table_id_to_join_condition);
777 
778  bool skipFragmentPair(const Fragmenter_Namespace::FragmentInfo& outer_fragment_info,
779  const Fragmenter_Namespace::FragmentInfo& inner_fragment_info,
780  const int inner_table_id,
781  const std::unordered_map<int, const Analyzer::BinOper*>&
782  inner_table_id_to_join_condition,
783  const RelAlgExecutionUnit& ra_exe_unit,
784  const ExecutorDeviceType device_type);
785 
787  const RelAlgExecutionUnit& ra_exe_unit,
788  const int device_id,
790  const std::map<int, const TableFragments*>&,
791  const FragmentsList& selected_fragments,
793  std::list<ChunkIter>&,
794  std::list<std::shared_ptr<Chunk_NS::Chunk>>&,
795  DeviceAllocator* device_allocator,
796  const size_t thread_idx,
797  const bool allow_runtime_interrupt);
798 
800  const RelAlgExecutionUnit& ra_exe_unit,
801  const int device_id,
803  const std::map<int, const TableFragments*>&,
804  const FragmentsList& selected_fragments,
806  std::list<ChunkIter>&,
807  std::list<std::shared_ptr<Chunk_NS::Chunk>>&,
808  DeviceAllocator* device_allocator,
809  const size_t thread_idx,
810  const bool allow_runtime_interrupt);
811 
812  std::pair<std::vector<std::vector<int64_t>>, std::vector<std::vector<uint64_t>>>
814  const RelAlgExecutionUnit& ra_exe_unit,
815  const CartesianProduct<std::vector<std::vector<size_t>>>& frag_ids_crossjoin,
816  const std::vector<InputDescriptor>& input_descs,
817  const std::map<int, const TableFragments*>& all_tables_fragments);
818 
820  std::vector<std::vector<size_t>>& selected_fragments_crossjoin,
821  std::vector<size_t>& local_col_to_frag_pos,
822  const std::list<std::shared_ptr<const InputColDescriptor>>& col_global_ids,
823  const FragmentsList& selected_fragments,
824  const RelAlgExecutionUnit& ra_exe_unit);
825 
827  std::vector<std::vector<size_t>>& selected_fragments_crossjoin,
828  std::vector<size_t>& local_col_to_frag_pos,
829  const std::list<std::shared_ptr<const InputColDescriptor>>& col_global_ids,
830  const FragmentsList& selected_fragments,
831  const RelAlgExecutionUnit& ra_exe_unit);
832 
833  std::vector<size_t> getFragmentCount(const FragmentsList& selected_fragments,
834  const size_t scan_idx,
835  const RelAlgExecutionUnit& ra_exe_unit);
836 
837  // pass nullptr to results if it shouldn't be extracted from the execution context
838  int32_t executePlanWithGroupBy(const RelAlgExecutionUnit& ra_exe_unit,
839  const CompilationResult&,
840  const bool hoist_literals,
841  ResultSetPtr* results,
842  const ExecutorDeviceType device_type,
843  std::vector<std::vector<const int8_t*>>& col_buffers,
844  const std::vector<size_t> outer_tab_frag_ids,
846  const std::vector<std::vector<int64_t>>& num_rows,
847  const std::vector<std::vector<uint64_t>>& frag_offsets,
849  const int device_id,
850  const int outer_table_id,
851  const int64_t limit,
852  const uint32_t start_rowid,
853  const uint32_t num_tables,
854  const bool allow_runtime_interrupt,
855  RenderInfo* render_info,
856  const int64_t rows_to_process = -1);
857  // pass nullptr to results if it shouldn't be extracted from the execution context
859  const RelAlgExecutionUnit& ra_exe_unit,
860  const CompilationResult&,
861  const bool hoist_literals,
862  ResultSetPtr* results,
863  const std::vector<Analyzer::Expr*>& target_exprs,
864  const ExecutorDeviceType device_type,
865  std::vector<std::vector<const int8_t*>>& col_buffers,
866  QueryExecutionContext* query_exe_context,
867  const std::vector<std::vector<int64_t>>& num_rows,
868  const std::vector<std::vector<uint64_t>>& frag_offsets,
869  Data_Namespace::DataMgr* data_mgr,
870  const int device_id,
871  const uint32_t start_rowid,
872  const uint32_t num_tables,
873  const bool allow_runtime_interrupt,
874  RenderInfo* render_info,
875  const int64_t rows_to_process = -1);
876 
877  public: // Temporary, ask saman about this
878  static std::pair<int64_t, int32_t> reduceResults(const SQLAgg agg,
879  const SQLTypeInfo& ti,
880  const int64_t agg_init_val,
881  const int8_t out_byte_width,
882  const int64_t* out_vec,
883  const size_t out_vec_sz,
884  const bool is_group_by,
885  const bool float_argument_input);
886 
887  private:
889  const RelAlgExecutionUnit& ra_exe_unit);
890  std::vector<int8_t*> getJoinHashTablePtrs(const ExecutorDeviceType device_type,
891  const int device_id);
893  const RelAlgExecutionUnit&,
894  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>>& all_fragment_results,
895  std::shared_ptr<RowSetMemoryOwner>,
896  const QueryMemoryDescriptor&) const;
898  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>>& all_fragment_results,
899  std::shared_ptr<RowSetMemoryOwner>,
900  const QueryMemoryDescriptor&) const;
902  const RelAlgExecutionUnit&,
903  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>>& all_fragment_results,
904  std::shared_ptr<RowSetMemoryOwner>,
905  const QueryMemoryDescriptor&) const;
906 
907  ResultSetPtr executeWorkUnitImpl(size_t& max_groups_buffer_entry_guess,
908  const bool is_agg,
909  const bool allow_single_frag_table_opt,
910  const std::vector<InputTableInfo>&,
911  const RelAlgExecutionUnit&,
912  const CompilationOptions&,
913  const ExecutionOptions& options,
915  std::shared_ptr<RowSetMemoryOwner>,
916  RenderInfo* render_info,
917  const bool has_cardinality_estimation,
918  ColumnCacheMap& column_cache);
919 
920  std::vector<llvm::Value*> inlineHoistedLiterals();
921 
923 
924  std::tuple<CompilationResult, std::unique_ptr<QueryMemoryDescriptor>> compileWorkUnit(
925  const std::vector<InputTableInfo>& query_infos,
926  const PlanState::DeletedColumnsMap& deleted_cols_map,
927  const RelAlgExecutionUnit& ra_exe_unit,
928  const CompilationOptions& co,
929  const ExecutionOptions& eo,
930  const CudaMgr_Namespace::CudaMgr* cuda_mgr,
931  const bool allow_lazy_fetch,
932  std::shared_ptr<RowSetMemoryOwner>,
933  const size_t max_groups_buffer_entry_count,
934  const int8_t crt_min_byte_width,
935  const bool has_cardinality_estimation,
936  ColumnCacheMap& column_cache,
937  RenderInfo* render_info = nullptr);
938  // Generate code to skip the deleted rows in the outermost table.
939  llvm::BasicBlock* codegenSkipDeletedOuterTableRow(
940  const RelAlgExecutionUnit& ra_exe_unit,
941  const CompilationOptions& co);
942  std::vector<JoinLoop> buildJoinLoops(RelAlgExecutionUnit& ra_exe_unit,
943  const CompilationOptions& co,
944  const ExecutionOptions& eo,
945  const std::vector<InputTableInfo>& query_infos,
946  ColumnCacheMap& column_cache);
947  // Create a callback which hoists left hand side filters above the join for left joins,
948  // eliminating extra computation of the probe and matches if the row does not pass the
949  // filters
951  const RelAlgExecutionUnit& ra_exe_unit,
952  const size_t level_idx,
953  const int inner_table_id,
954  const CompilationOptions& co);
955  // Create a callback which generates code which returns true iff the row on the given
956  // level is deleted.
957  std::function<llvm::Value*(const std::vector<llvm::Value*>&, llvm::Value*)>
958  buildIsDeletedCb(const RelAlgExecutionUnit& ra_exe_unit,
959  const size_t level_idx,
960  const CompilationOptions& co);
961  // Builds a join hash table for the provided conditions on the current level.
962  // Returns null iff on failure and provides the reasons in `fail_reasons`.
963  std::shared_ptr<HashJoin> buildCurrentLevelHashTable(
964  const JoinCondition& current_level_join_conditions,
965  size_t level_idx,
966  RelAlgExecutionUnit& ra_exe_unit,
967  const CompilationOptions& co,
968  const std::vector<InputTableInfo>& query_infos,
969  ColumnCacheMap& column_cache,
970  std::vector<std::string>& fail_reasons);
972  llvm::Value* addJoinLoopIterator(const std::vector<llvm::Value*>& prev_iters,
973  const size_t level_idx);
974  void codegenJoinLoops(const std::vector<JoinLoop>& join_loops,
975  const RelAlgExecutionUnit& ra_exe_unit,
976  GroupByAndAggregate& group_by_and_aggregate,
977  llvm::Function* query_func,
978  llvm::BasicBlock* entry_bb,
980  const CompilationOptions& co,
981  const ExecutionOptions& eo);
982  bool compileBody(const RelAlgExecutionUnit& ra_exe_unit,
983  GroupByAndAggregate& group_by_and_aggregate,
985  const CompilationOptions& co,
986  const GpuSharedMemoryContext& gpu_smem_context = {});
987 
988  void createErrorCheckControlFlow(llvm::Function* query_func,
989  bool run_with_dynamic_watchdog,
990  bool run_with_allowing_runtime_interrupt,
991  const std::vector<JoinLoop>& join_loops,
992  ExecutorDeviceType device_type,
993  const std::vector<InputTableInfo>& input_table_infos);
994 
995  void insertErrorCodeChecker(llvm::Function* query_func,
996  bool hoist_literals,
997  bool allow_runtime_query_interrupt);
998 
999  void preloadFragOffsets(const std::vector<InputDescriptor>& input_descs,
1000  const std::vector<InputTableInfo>& query_infos);
1001 
1003  std::shared_ptr<HashJoin> hash_table;
1004  std::string fail_reason;
1005  };
1006 
1008  const std::shared_ptr<Analyzer::BinOper>& qual_bin_oper,
1009  const std::vector<InputTableInfo>& query_infos,
1010  const MemoryLevel memory_level,
1011  const JoinType join_type,
1012  const HashType preferred_hash_type,
1013  ColumnCacheMap& column_cache,
1014  const HashTableBuildDagMap& hashtable_build_dag_map,
1015  const RegisteredQueryHint& query_hint,
1016  const TableIdToNodeMap& table_id_to_node_map);
1017  void nukeOldState(const bool allow_lazy_fetch,
1018  const std::vector<InputTableInfo>& query_infos,
1019  const PlanState::DeletedColumnsMap& deleted_cols_map,
1020  const RelAlgExecutionUnit* ra_exe_unit);
1021 
1022  std::shared_ptr<CompilationContext> optimizeAndCodegenCPU(
1023  llvm::Function*,
1024  llvm::Function*,
1025  const std::unordered_set<llvm::Function*>&,
1026  const CompilationOptions&);
1027  std::shared_ptr<CompilationContext> optimizeAndCodegenGPU(
1028  llvm::Function*,
1029  llvm::Function*,
1030  std::unordered_set<llvm::Function*>&,
1031  const bool no_inline,
1032  const CudaMgr_Namespace::CudaMgr* cuda_mgr,
1033  const bool is_gpu_smem_used,
1034  const CompilationOptions&);
1035  std::string generatePTX(const std::string&) const;
1036  void initializeNVPTXBackend() const;
1037 
1038  int64_t deviceCycles(int milliseconds) const;
1039 
1041  llvm::Value* translated_value;
1042  llvm::Value* original_value;
1043  };
1044 
1046  const size_t col_width,
1047  const CompilationOptions&,
1048  const bool translate_null_val,
1049  const int64_t translated_null_val,
1050  DiamondCodegen&,
1051  std::stack<llvm::BasicBlock*>&,
1052  const bool thread_mem_shared);
1053 
1054  llvm::Value* castToFP(llvm::Value*,
1055  SQLTypeInfo const& from_ti,
1056  SQLTypeInfo const& to_ti);
1057  llvm::Value* castToIntPtrTyIn(llvm::Value* val, const size_t bit_width);
1058 
1059  std::tuple<RelAlgExecutionUnit, PlanState::DeletedColumnsMap> addDeletedColumn(
1060  const RelAlgExecutionUnit& ra_exe_unit,
1061  const CompilationOptions& co);
1062 
1063  bool isFragmentFullyDeleted(const int table_id,
1064  const Fragmenter_Namespace::FragmentInfo& fragment);
1065 
1067  const Analyzer::BinOper* comp_expr,
1068  const Analyzer::ColumnVar* lhs_col,
1069  const Fragmenter_Namespace::FragmentInfo& fragment,
1070  const Analyzer::Constant* rhs_const) const;
1071 
1072  std::pair<bool, int64_t> skipFragment(
1073  const InputDescriptor& table_desc,
1074  const Fragmenter_Namespace::FragmentInfo& frag_info,
1075  const std::list<std::shared_ptr<Analyzer::Expr>>& simple_quals,
1076  const std::vector<uint64_t>& frag_offsets,
1077  const size_t frag_idx);
1078 
1079  std::pair<bool, int64_t> skipFragmentInnerJoins(
1080  const InputDescriptor& table_desc,
1081  const RelAlgExecutionUnit& ra_exe_unit,
1082  const Fragmenter_Namespace::FragmentInfo& fragment,
1083  const std::vector<uint64_t>& frag_offsets,
1084  const size_t frag_idx);
1085 
1087  const std::unordered_set<PhysicalInput>& phys_inputs);
1089  const std::unordered_set<PhysicalInput>& phys_inputs);
1090  TableGenerations computeTableGenerations(std::unordered_set<int> phys_table_ids);
1091 
1092  public:
1093  void setupCaching(const std::unordered_set<PhysicalInput>& phys_inputs,
1094  const std::unordered_set<int>& phys_table_ids);
1095  void setColRangeCache(const AggregatedColRange& aggregated_col_range) {
1096  agg_col_range_cache_ = aggregated_col_range;
1097  }
1099  QuerySessionId& getCurrentQuerySession(mapd_shared_lock<mapd_shared_mutex>& read_lock);
1101  const QuerySessionId& candidate_query_session,
1102  mapd_shared_lock<mapd_shared_mutex>& read_lock);
1103  bool checkCurrentQuerySession(const std::string& candidate_query_session,
1104  mapd_shared_lock<mapd_shared_mutex>& read_lock);
1105  void invalidateRunningQuerySession(mapd_unique_lock<mapd_shared_mutex>& write_lock);
1106  bool addToQuerySessionList(const QuerySessionId& query_session,
1107  const std::string& query_str,
1108  const std::string& submitted,
1109  const size_t executor_id,
1110  const QuerySessionStatus::QueryStatus query_status,
1111  mapd_unique_lock<mapd_shared_mutex>& write_lock);
1112  bool removeFromQuerySessionList(const QuerySessionId& query_session,
1113  const std::string& submitted_time_str,
1114  mapd_unique_lock<mapd_shared_mutex>& write_lock);
1115  void setQuerySessionAsInterrupted(const QuerySessionId& query_session,
1116  mapd_unique_lock<mapd_shared_mutex>& write_lock);
1117  bool checkIsQuerySessionInterrupted(const std::string& query_session,
1118  mapd_shared_lock<mapd_shared_mutex>& read_lock);
1119  bool checkIsQuerySessionEnrolled(const QuerySessionId& query_session,
1120  mapd_shared_lock<mapd_shared_mutex>& read_lock);
1122  const QuerySessionId& query_session,
1123  const std::string& submitted_time_str,
1124  const QuerySessionStatus::QueryStatus updated_query_status,
1125  mapd_unique_lock<mapd_shared_mutex>& write_lock);
1127  const QuerySessionId& query_session,
1128  const std::string& submitted_time_str,
1129  const size_t executor_id,
1130  mapd_unique_lock<mapd_shared_mutex>& write_lock);
1131  std::vector<QuerySessionStatus> getQuerySessionInfo(
1132  const QuerySessionId& query_session,
1133  mapd_shared_lock<mapd_shared_mutex>& read_lock);
1134 
1137  const QuerySessionId& query_session_id,
1138  const std::string& query_str,
1139  const std::string& query_submitted_time);
1140  void checkPendingQueryStatus(const QuerySessionId& query_session);
1141  void clearQuerySessionStatus(const QuerySessionId& query_session,
1142  const std::string& submitted_time_str);
1143  void updateQuerySessionStatus(const QuerySessionId& query_session,
1144  const std::string& submitted_time_str,
1145  const QuerySessionStatus::QueryStatus new_query_status);
1146  void enrollQuerySession(const QuerySessionId& query_session,
1147  const std::string& query_str,
1148  const std::string& submitted_time_str,
1149  const size_t executor_id,
1150  const QuerySessionStatus::QueryStatus query_session_status);
1151  size_t getNumCurentSessionsEnrolled() const;
1152  // get a set of executor ids that a given session has fired regardless of
1153  // each executor's status: pending or running
1154  const std::vector<size_t> getExecutorIdsRunningQuery(
1155  const QuerySessionId& interrupt_session) const;
1156  // check whether the current session that this executor manages is interrupted
1157  // while performing non-kernel time task
1158  bool checkNonKernelTimeInterrupted() const;
1159  void registerExtractedQueryPlanDag(const QueryPlanDAG& query_plan_dag);
1161 
1162  // true when we have matched cardinality, and false otherwise
1163  using CachedCardinality = std::pair<bool, size_t>;
1164  void addToCardinalityCache(const std::string& cache_key, const size_t cache_value);
1165  CachedCardinality getCachedCardinality(const std::string& cache_key);
1166 
1170 
1171  CgenState* getCgenStatePtr() const { return cgen_state_.get(); }
1172  PlanState* getPlanStatePtr() const { return plan_state_.get(); }
1173 
1174  llvm::LLVMContext& getContext() { return *context_.get(); }
1175  void update_extension_modules(bool update_runtime_modules_only = false);
1176 
1177  static void update_after_registration(bool update_runtime_modules_only = false) {
1178  for (auto executor_item : Executor::executors_) {
1179  executor_item.second->update_extension_modules(update_runtime_modules_only);
1180  }
1181  }
1182 
1183  private:
1184  std::vector<int8_t> serializeLiterals(
1185  const std::unordered_map<int, CgenState::LiteralValues>& literals,
1186  const int device_id);
1187 
1188  static size_t align(const size_t off_in, const size_t alignment) {
1189  size_t off = off_in;
1190  if (off % alignment != 0) {
1191  off += (alignment - off % alignment);
1192  }
1193  return off;
1194  }
1195 
1197  std::unique_ptr<llvm::LLVMContext> context_;
1198 
1199  public:
1200  // CgenStateManager uses RAII pattern to ensure that recursive code
1201  // generation (e.g. as in multi-step multi-subqueries) uses a new
1202  // CgenState instance for each recursion depth while restoring the
1203  // old CgenState instances when returning from recursion.
1205  public:
1206  CgenStateManager(Executor& executor);
1207  CgenStateManager(Executor& executor,
1208  const bool allow_lazy_fetch,
1209  const std::vector<InputTableInfo>& query_infos,
1210  const PlanState::DeletedColumnsMap& deleted_cols_map,
1211  const RelAlgExecutionUnit* ra_exe_unit);
1213 
1214  private:
1216  std::chrono::steady_clock::time_point lock_queue_clock_;
1217  std::lock_guard<std::mutex> lock_;
1218  std::unique_ptr<CgenState> cgen_state_;
1219  };
1220 
1221  private:
1222  std::unique_ptr<CgenState> cgen_state_;
1223 
1224  const std::unique_ptr<llvm::Module>& get_extension_module(ExtModuleKinds kind) const {
1225  auto it = extension_modules_.find(kind);
1226  if (it != extension_modules_.end()) {
1227  return it->second;
1228  }
1229  static const std::unique_ptr<llvm::Module> empty;
1230  return empty;
1231  }
1232 
1234  return extension_modules_.find(kind) != extension_modules_.end();
1235  }
1236 
1237  std::map<ExtModuleKinds, std::unique_ptr<llvm::Module>> extension_modules_;
1238 
1240  public:
1242  : cgen_state_(cgen_state), saved_fetch_cache(cgen_state_->fetch_cache_) {}
1244 
1245  private:
1247  std::unordered_map<int, std::vector<llvm::Value*>> saved_fetch_cache;
1248  };
1249 
1250  llvm::Value* spillDoubleElement(llvm::Value* elem_val, llvm::Type* elem_ty);
1251 
1252  std::unique_ptr<PlanState> plan_state_;
1253  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner_;
1254 
1255  static const int max_gpu_count{16};
1257 
1258  static std::mutex gpu_active_modules_mutex_;
1261  // indicates whether this executor has been interrupted
1262  std::atomic<bool> interrupted_;
1263 
1264  mutable std::mutex str_dict_mutex_;
1265 
1266  mutable std::unique_ptr<llvm::TargetMachine> nvptx_target_machine_;
1267 
1268  public:
1274 
1275  private:
1276  static const size_t baseline_threshold{
1277  1000000}; // if a perfect hash needs more entries, use baseline
1278  static const size_t code_cache_size{1000};
1279 
1280  const unsigned block_size_x_;
1281  const unsigned grid_size_x_;
1282  const size_t max_gpu_slab_size_;
1283  const std::string debug_dir_;
1284  const std::string debug_file_;
1285 
1290 
1293 
1294  // Singleton instance used for an execution unit which is a project with window
1295  // functions.
1296  std::unique_ptr<WindowProjectNodeContext> window_project_node_context_owned_;
1297  // The active window function.
1299 
1304  // a query session that this executor manages
1306  // a pair of <QuerySessionId, interrupted_flag>
1308  // a pair of <QuerySessionId, query_session_status>
1310  static std::map<int, std::shared_ptr<Executor>> executors_;
1311 
1312  // SQL queries take a shared lock, exclusive options (cache clear, memory clear) take a
1313  // write lock
1315 
1317  mapd_shared_lock<mapd_shared_mutex> shared_lock;
1318  mapd_unique_lock<mapd_shared_mutex> unique_lock;
1319  };
1321  ExecutorMutexHolder ret;
1323  // Only one unitary executor can run at a time
1324  ret.unique_lock = mapd_unique_lock<mapd_shared_mutex>(execute_mutex_);
1325  } else {
1326  ret.shared_lock = mapd_shared_lock<mapd_shared_mutex>(execute_mutex_);
1327  }
1328  return ret;
1329  }
1330 
1332 
1335  static std::unordered_map<std::string, size_t> cardinality_cache_;
1337 
1338  // a variable used for testing query plan DAG extractor when a query has a table
1339  // function
1341 
1342  public:
1343  static const int32_t ERR_DIV_BY_ZERO{1};
1344  static const int32_t ERR_OUT_OF_GPU_MEM{2};
1345  static const int32_t ERR_OUT_OF_SLOTS{3};
1346  static const int32_t ERR_UNSUPPORTED_SELF_JOIN{4};
1347  static const int32_t ERR_OUT_OF_RENDER_MEM{5};
1348  static const int32_t ERR_OUT_OF_CPU_MEM{6};
1349  static const int32_t ERR_OVERFLOW_OR_UNDERFLOW{7};
1350  static const int32_t ERR_OUT_OF_TIME{9};
1351  static const int32_t ERR_INTERRUPTED{10};
1352  static const int32_t ERR_COLUMNAR_CONVERSION_NOT_SUPPORTED{11};
1353  static const int32_t ERR_TOO_MANY_LITERALS{12};
1354  static const int32_t ERR_STRING_CONST_IN_RESULTSET{13};
1356  static const int32_t ERR_SINGLE_VALUE_FOUND_MULTIPLE_VALUES{15};
1357  static const int32_t ERR_GEOS{16};
1358  static const int32_t ERR_WIDTH_BUCKET_INVALID_ARGUMENT{17};
1359 
1360  // Although compilation is Executor-local, an executor may trigger
1361  // threaded compilations (see executeWorkUnitPerFragment) that share
1362  // executor cgen_state and LLVM context, for instance.
1363  //
1364  // Rule of thumb: when `executor->thread_id_ != logger::thread_id()`
1365  // and executor LLVM Context is being modified (modules are cloned,
1366  // etc), one should protect such a code with
1367  //
1368  // std::lock_guard<std::mutex> compilation_lock(executor->compilation_mutex_);
1369  //
1370  // to ensure thread safety.
1373 
1374  // Runtime extension function registration updates
1375  // extension_modules_ that needs to be kept blocked from codegen
1376  // until the update is complete.
1378  static std::mutex kernel_mutex_; // TODO: should this be executor-local mutex?
1379 
1381  friend class CodeGenerator;
1382  friend class ColumnFetcher;
1383  friend struct DiamondCodegen; // cgen_state_
1384  friend class ExecutionKernel;
1385  friend class KernelSubtask;
1386  friend class HashJoin; // cgen_state_
1388  friend class RangeJoinHashTable;
1389  friend class GroupByAndAggregate;
1395  friend class ResultSet;
1396  friend class InValuesBitmap;
1398  friend class LeafAggregator;
1399  friend class PerfectJoinHashTable;
1400  friend class QueryRewriter;
1402  friend class RelAlgExecutor;
1403  friend class TableOptimizer;
1407  friend struct TargetExprCodegen;
1409 };
1410 
1411 inline std::string get_null_check_suffix(const SQLTypeInfo& lhs_ti,
1412  const SQLTypeInfo& rhs_ti) {
1413  if (lhs_ti.get_notnull() && rhs_ti.get_notnull()) {
1414  return "";
1415  }
1416  std::string null_check_suffix{"_nullable"};
1417  if (lhs_ti.get_notnull()) {
1418  CHECK(!rhs_ti.get_notnull());
1419  null_check_suffix += "_rhs";
1420  } else if (rhs_ti.get_notnull()) {
1421  CHECK(!lhs_ti.get_notnull());
1422  null_check_suffix += "_lhs";
1423  }
1424  return null_check_suffix;
1425 }
1426 
1427 inline bool is_unnest(const Analyzer::Expr* expr) {
1428  return dynamic_cast<const Analyzer::UOper*>(expr) &&
1429  static_cast<const Analyzer::UOper*>(expr)->get_optype() == kUNNEST;
1430 }
1431 
1432 inline bool is_constructed_point(const Analyzer::Expr* expr) {
1433  auto uoper = dynamic_cast<const Analyzer::UOper*>(expr);
1434  auto oper = (uoper && uoper->get_optype() == kCAST) ? uoper->get_operand() : expr;
1435  auto arr = dynamic_cast<const Analyzer::ArrayExpr*>(oper);
1436  return (arr && arr->isLocalAlloc() && arr->get_type_info().is_fixlen_array());
1437 }
1438 
1439 bool is_trivial_loop_join(const std::vector<InputTableInfo>& query_infos,
1440  const RelAlgExecutionUnit& ra_exe_unit);
1441 
1442 std::unordered_set<int> get_available_gpus(const Catalog_Namespace::Catalog& cat);
1443 
1444 size_t get_context_count(const ExecutorDeviceType device_type,
1445  const size_t cpu_count,
1446  const size_t gpu_count);
1447 
1448 extern "C" RUNTIME_EXPORT void register_buffer_with_executor_rsm(int64_t exec,
1449  int8_t* buffer);
1450 
1452 
1453 inline std::string toString(const Executor::ExtModuleKinds& kind) {
1454  switch (kind) {
1456  return "template_module";
1458  return "rt_geos_module";
1460  return "rt_libdevice_module";
1462  return "udf_cpu_module";
1464  return "udf_gpu_module";
1466  return "rt_udf_cpu_module";
1468  return "rt_udf_gpu_module";
1469  }
1470  LOG(FATAL) << "Invalid LLVM module kind.";
1471  return "";
1472 }
1473 
1474 namespace foreign_storage {
1475 void populate_string_dictionary(const int32_t table_id,
1476  const int32_t col_id,
1478 }
1479 
1480 #endif // QUERYENGINE_EXECUTE_H
void createErrorCheckControlFlow(llvm::Function *query_func, bool run_with_dynamic_watchdog, bool run_with_allowing_runtime_interrupt, const std::vector< JoinLoop > &join_loops, ExecutorDeviceType device_type, const std::vector< InputTableInfo > &input_table_infos)
bool updateQuerySessionStatusWithLock(const QuerySessionId &query_session, const std::string &submitted_time_str, const QuerySessionStatus::QueryStatus updated_query_status, mapd_unique_lock< mapd_shared_mutex > &write_lock)
Definition: Execute.cpp:4616
SQLTypeInfo getColumnType(const size_t col_idx) const
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:222
const std::string debug_dir_
Definition: Execute.h:1283
QuerySessionId & getCurrentQuerySession(mapd_shared_lock< mapd_shared_mutex > &read_lock)
Definition: Execute.cpp:4446
llvm::Value * translated_value
Definition: Execute.h:1041
void executeWorkUnitPerFragment(const RelAlgExecutionUnit &ra_exe_unit, const InputTableInfo &table_info, const CompilationOptions &co, const ExecutionOptions &eo, const Catalog_Namespace::Catalog &cat, PerFragmentCallBack &cb, const std::set< size_t > &fragment_indexes_param)
Compiles and dispatches a work unit per fragment processing results with the per fragment callback...
Definition: Execute.cpp:1981
bool is_agg(const Analyzer::Expr *expr)
static void invalidateCachesByTable(size_t table_key)
static CodeCacheAccessor< CpuCompilationContext > s_code_accessor
Definition: Execute.h:1270
static mapd_shared_mutex executor_session_mutex_
Definition: Execute.h:1303
AggregatedColRange computeColRangesCache(const std::unordered_set< PhysicalInput > &phys_inputs)
Definition: Execute.cpp:4356
void enableRuntimeQueryInterrupt(const double runtime_query_check_freq, const unsigned pending_query_check_freq) const
Definition: Execute.cpp:4732
SQLAgg
Definition: sqldefs.h:73
#define CHECK_EQ(x, y)
Definition: Logger.h:231
const QueryPlanDAG getLatestQueryPlanDagExtracted() const
Definition: Execute.cpp:4819
std::vector< std::unique_ptr< ExecutionKernel > > createKernels(SharedKernelContext &shared_context, const RelAlgExecutionUnit &ra_exe_unit, ColumnFetcher &column_fetcher, const std::vector< InputTableInfo > &table_infos, const ExecutionOptions &eo, const bool is_agg, const bool allow_single_frag_table_opt, const size_t context_count, const QueryCompilationDescriptor &query_comp_desc, const QueryMemoryDescriptor &query_mem_desc, RenderInfo *render_info, std::unordered_set< int > &available_gpus, int &available_cpus)
Definition: Execute.cpp:2518
ExtModuleKinds
Definition: Execute.h:469
void codegenJoinLoops(const std::vector< JoinLoop > &join_loops, const RelAlgExecutionUnit &ra_exe_unit, GroupByAndAggregate &group_by_and_aggregate, llvm::Function *query_func, llvm::BasicBlock *entry_bb, QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, const ExecutionOptions &eo)
Definition: IRCodegen.cpp:1112
const std::unique_ptr< llvm::Module > & get_udf_module(bool is_gpu=false) const
Definition: Execute.h:486
static QuerySessionMap queries_session_map_
Definition: Execute.h:1309
CudaMgr_Namespace::CudaMgr * cudaMgr() const
Definition: Execute.h:672
static mapd_shared_mutex execute_mutex_
Definition: Execute.h:1314
int32_t executePlanWithGroupBy(const RelAlgExecutionUnit &ra_exe_unit, const CompilationResult &, const bool hoist_literals, ResultSetPtr *results, const ExecutorDeviceType device_type, std::vector< std::vector< const int8_t * >> &col_buffers, const std::vector< size_t > outer_tab_frag_ids, QueryExecutionContext *, const std::vector< std::vector< int64_t >> &num_rows, const std::vector< std::vector< uint64_t >> &frag_offsets, Data_Namespace::DataMgr *, const int device_id, const int outer_table_id, const int64_t limit, const uint32_t start_rowid, const uint32_t num_tables, const bool allow_runtime_interrupt, RenderInfo *render_info, const int64_t rows_to_process=-1)
Definition: Execute.cpp:3563
std::unique_ptr< llvm::TargetMachine > nvptx_target_machine_
Definition: Execute.h:1266
bool has_libdevice_module() const
Definition: Execute.h:517
int64_t kernel_queue_time_ms_
Definition: Execute.h:1291
JoinType
Definition: sqldefs.h:136
size_t maxGpuSlabSize() const
Definition: Execute.cpp:3872
ExecutorMutexHolder acquireExecuteMutex()
Definition: Execute.h:1320
Data_Namespace::DataMgr * data_mgr_
Definition: Execute.h:1287
int64_t compilation_queue_time_ms_
Definition: Execute.h:1292
const std::string & getQuerySubmittedTime()
Definition: Execute.h:132
friend class ResultSet
Definition: Execute.h:1395
std::map< const ColumnDescriptor *, std::set< int32_t >> ColumnToFragmentsMap
Definition: Execute.h:317
const std::unique_ptr< llvm::Module > & get_geos_module() const
Definition: Execute.h:496
std::string cat(Ts &&...args)
void invalidateRunningQuerySession(mapd_unique_lock< mapd_shared_mutex > &write_lock)
Definition: Execute.cpp:4472
static void initialize_extension_module_sources()
Definition: Execute.cpp:284
void checkPendingQueryStatus(const QuerySessionId &query_session)
Definition: Execute.cpp:4494
const StringDictionaryProxy::IdMap * getJoinIntersectionStringProxyTranslationMap(const StringDictionaryProxy *source_proxy, StringDictionaryProxy *dest_proxy, const std::vector< StringOps_Namespace::StringOpInfo > &source_string_op_infos, const std::vector< StringOps_Namespace::StringOpInfo > &dest_source_string_op_infos, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner) const
Definition: Execute.cpp:592
static void registerActiveModule(void *module, const int device_id)
static const int32_t ERR_INTERRUPTED
Definition: Execute.h:1351
const Analyzer::Expr * remove_cast_to_int(const Analyzer::Expr *expr)
Definition: ColumnIR.cpp:541
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:114
std::vector< int8_t * > getJoinHashTablePtrs(const ExecutorDeviceType device_type, const int device_id)
Definition: Execute.cpp:3750
bool is_trivial_loop_join(const std::vector< InputTableInfo > &query_infos, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:1560
FetchCacheAnchor(CgenState *cgen_state)
Definition: Execute.h:1241
const std::unique_ptr< llvm::Module > & get_extension_module(ExtModuleKinds kind) const
Definition: Execute.h:1224
const std::shared_ptr< RowSetMemoryOwner > getRowSetMemoryOwner() const
Definition: Execute.cpp:666
StringDictionaryProxy * getLiteralDictionary() const override
Definition: Execute.h:337
std::atomic< bool > interrupted_
Definition: Execute.h:1262
static ResultSetRecyclerHolder resultset_recycler_holder_
Definition: Execute.h:1336
std::vector< size_t > getTableFragmentIndices(const RelAlgExecutionUnit &ra_exe_unit, const ExecutorDeviceType device_type, const size_t table_idx, const size_t outer_frag_idx, std::map< int, const TableFragments * > &selected_tables_fragments, const std::unordered_map< int, const Analyzer::BinOper * > &inner_table_id_to_join_condition)
Definition: Execute.cpp:2704
ExecutorDeviceType
ResultSetPtr executeTableFunction(const TableFunctionExecutionUnit exe_unit, const std::vector< InputTableInfo > &table_infos, const CompilationOptions &co, const ExecutionOptions &eo, const Catalog_Namespace::Catalog &cat)
Compiles and dispatches a table function; that is, a function that takes as input one or more columns...
Definition: Execute.cpp:2061
Fragmenter_Namespace::RowDataProvider RowDataProvider
Definition: Execute.h:316
static CodeCacheAccessor< CpuCompilationContext > s_stubs_accessor
Definition: Execute.h:1269
static const int max_gpu_count
Definition: Execute.h:1255
GroupColLLVMValue groupByColumnCodegen(Analyzer::Expr *group_by_col, const size_t col_width, const CompilationOptions &, const bool translate_null_val, const int64_t translated_null_val, DiamondCodegen &, std::stack< llvm::BasicBlock * > &, const bool thread_mem_shared)
Definition: IRCodegen.cpp:1292
std::map< const QuerySessionId, std::map< std::string, QuerySessionStatus >> QuerySessionMap
Definition: Execute.h:153
size_t const getFragmentIndex() const
static const size_t code_cache_size
Definition: Execute.h:1278
#define LOG(tag)
Definition: Logger.h:217
std::string QueryPlanDAG
bool isArchPascalOrLater(const ExecutorDeviceType dt) const
Definition: Execute.h:679
void AutoTrackBuffersInRuntimeIR()
std::ostream & operator<<(std::ostream &os, const SessionInfo &session_info)
Definition: SessionInfo.cpp:57
bool is_fp() const
Definition: sqltypes.h:514
std::pair< QuerySessionId, std::string > CurrentQueryStatus
Definition: Execute.h:85
bool is_constructed_point(const Analyzer::Expr *expr)
Definition: Execute.h:1432
static mapd_shared_mutex executors_cache_mutex_
Definition: Execute.h:1331
std::function< llvm::BasicBlock *(llvm::BasicBlock *, llvm::BasicBlock *, const std::string &, llvm::Function *, CgenState *)> HoistedFiltersCallback
Definition: JoinLoop.h:61
std::vector< ColumnLazyFetchInfo > getColLazyFetchInfo(const std::vector< Analyzer::Expr * > &target_exprs) const
Definition: Execute.cpp:729
static const size_t baseline_threshold
Definition: Execute.h:1276
void updateQuerySessionStatus(const QuerySessionId &query_session, const std::string &submitted_time_str, const QuerySessionStatus::QueryStatus new_query_status)
Definition: Execute.cpp:4534
const std::unique_ptr< llvm::Module > & get_rt_udf_module(bool is_gpu=false) const
Definition: Execute.h:490
std::unordered_set< int > get_available_gpus(const Data_Namespace::DataMgr *data_mgr)
Definition: Execute.cpp:1438
std::tuple< RelAlgExecutionUnit, PlanState::DeletedColumnsMap > addDeletedColumn(const RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co)
Definition: Execute.cpp:3954
TableGenerations computeTableGenerations(std::unordered_set< int > phys_table_ids)
Definition: Execute.cpp:4407
bool isArchPascalOrLater() const
Definition: CudaMgr.h:149
TableToFragmentIds fragments_with_deleted_rows
Definition: Execute.h:322
bool hasLazyFetchColumns(const std::vector< Analyzer::Expr * > &target_exprs) const
Definition: Execute.cpp:718
const SQLTypeInfo get_column_type(const int col_id, const int table_id, const ColumnDescriptor *cd, const TemporaryTables *temporary_tables)
Definition: Execute.h:236
llvm::Value * aggregateWindowStatePtr()
Driver for running cleanup processes on a table. TableOptimizer provides functions for various cleanu...
static std::pair< int64_t, int32_t > reduceResults(const SQLAgg agg, const SQLTypeInfo &ti, const int64_t agg_init_val, const int8_t out_byte_width, const int64_t *out_vec, const size_t out_vec_sz, const bool is_group_by, const bool float_argument_input)
Definition: Execute.cpp:1053
Definition: sqldefs.h:49
QuerySessionId current_query_session_
Definition: Execute.h:1305
const Analyzer::Expr * extract_cast_arg(const Analyzer::Expr *expr)
Definition: Execute.h:201
bool checkCurrentQuerySession(const std::string &candidate_query_session, mapd_shared_lock< mapd_shared_mutex > &read_lock)
Definition: Execute.cpp:4451
int32_t executePlanWithoutGroupBy(const RelAlgExecutionUnit &ra_exe_unit, const CompilationResult &, const bool hoist_literals, ResultSetPtr *results, const std::vector< Analyzer::Expr * > &target_exprs, const ExecutorDeviceType device_type, std::vector< std::vector< const int8_t * >> &col_buffers, QueryExecutionContext *query_exe_context, const std::vector< std::vector< int64_t >> &num_rows, const std::vector< std::vector< uint64_t >> &frag_offsets, Data_Namespace::DataMgr *data_mgr, const int device_id, const uint32_t start_rowid, const uint32_t num_tables, const bool allow_runtime_interrupt, RenderInfo *render_info, const int64_t rows_to_process=-1)
Definition: Execute.cpp:3343
const QuerySessionStatus::QueryStatus getQueryStatus()
Definition: Execute.h:133
static const int32_t ERR_GEOS
Definition: Execute.h:1357
const std::string query_str_
Definition: Execute.h:142
QuerySessionStatus(const QuerySessionId &query_session, const std::string &query_str, const std::string &submitted_time)
Definition: Execute.h:101
AggregatedColRange agg_col_range_cache_
Definition: Execute.h:1301
std::shared_ptr< ResultSet > ResultSetPtr
static void * gpu_active_modules_[max_gpu_count]
Definition: Execute.h:1260
std::unique_ptr< CgenState > cgen_state_
Definition: Execute.h:1222
static const int32_t ERR_TOO_MANY_LITERALS
Definition: Execute.h:1353
llvm::Value * original_value
Definition: Execute.h:1042
void enrollQuerySession(const QuerySessionId &query_session, const std::string &query_str, const std::string &submitted_time_str, const size_t executor_id, const QuerySessionStatus::QueryStatus query_session_status)
Definition: Execute.cpp:4550
ParseIRError(const std::string message)
Definition: Execute.h:304
static uint32_t gpu_active_modules_device_mask_
Definition: Execute.h:1259
void launchKernels(SharedKernelContext &shared_context, std::vector< std::unique_ptr< ExecutionKernel >> &&kernels, const ExecutorDeviceType device_type)
Definition: Execute.cpp:2652
TableUpdateMetadata executeUpdate(const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &table_infos, const TableDescriptor *updated_table_desc, const CompilationOptions &co, const ExecutionOptions &eo, const Catalog_Namespace::Catalog &cat, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const UpdateLogForFragment::Callback &cb, const bool is_agg)
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
FragmentSkipStatus canSkipFragmentForFpQual(const Analyzer::BinOper *comp_expr, const Analyzer::ColumnVar *lhs_col, const Fragmenter_Namespace::FragmentInfo &fragment, const Analyzer::Constant *rhs_const) const
Definition: Execute.cpp:4066
static void invalidateCaches()
void buildSelectedFragsMappingForUnion(std::vector< std::vector< size_t >> &selected_fragments_crossjoin, std::vector< size_t > &local_col_to_frag_pos, const std::list< std::shared_ptr< const InputColDescriptor >> &col_global_ids, const FragmentsList &selected_fragments, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:3290
int deviceCount(const ExecutorDeviceType) const
Definition: Execute.cpp:1038
llvm::Value * castToIntPtrTyIn(llvm::Value *val, const size_t bit_width)
Definition: Execute.cpp:3908
size_t getNumBytesForFetchedRow(const std::set< int > &table_ids_to_fetch) const
Definition: Execute.cpp:686
void reset(bool discard_runtime_modules_only=false)
Definition: Execute.cpp:313
static std::mutex kernel_mutex_
Definition: Execute.h:1378
unsigned numBlocksPerMP() const
Definition: Execute.cpp:3857
std::unique_ptr< CgenState > cgen_state_
Definition: Execute.h:1218
#define CHECK_GT(x, y)
Definition: Logger.h:235
Container for compilation results and assorted options for a single execution unit.
bool isCPUOnly() const
Definition: Execute.cpp:636
void clearCaches(bool runtime_only=false)
std::unique_ptr< WindowProjectNodeContext > window_project_node_context_owned_
Definition: Execute.h:1296
std::vector< QuerySessionStatus > getQuerySessionInfo(const QuerySessionId &query_session, mapd_shared_lock< mapd_shared_mutex > &read_lock)
Definition: Execute.cpp:4766
void addTransientStringLiterals(const RelAlgExecutionUnit &ra_exe_unit, const std::shared_ptr< RowSetMemoryOwner > &row_set_mem_owner)
Definition: Execute.cpp:2143
std::vector< FragmentsPerTable > FragmentsList
bool is_time() const
Definition: sqltypes.h:516
bool needFetchAllFragments(const InputColDescriptor &col_desc, const RelAlgExecutionUnit &ra_exe_unit, const FragmentsList &selected_fragments) const
Definition: Execute.cpp:2886
const QuerySessionId query_session_
Definition: Execute.h:140
std::shared_ptr< HashJoin > hash_table
Definition: Execute.h:1003
std::string to_string(char const *&&v)
bool checkIsQuerySessionInterrupted(const std::string &query_session, mapd_shared_lock< mapd_shared_mutex > &read_lock)
Definition: Execute.cpp:4712
const StringDictionaryProxy::IdMap * getStringProxyTranslationMap(const int source_dict_id, const int dest_dict_id, const RowSetMemoryOwner::StringTranslationType translation_type, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const bool with_generation) const
Definition: Execute.cpp:573
mapd_shared_mutex & getSessionLock()
Definition: Execute.cpp:4442
bool checkNonKernelTimeInterrupted() const
Definition: Execute.cpp:4800
static void clearMemory(const Data_Namespace::MemoryLevel memory_level)
Definition: Execute.cpp:507
QuerySessionStatus(const QuerySessionId &query_session, const size_t executor_id, const std::string &query_str, const std::string &submitted_time)
Definition: Execute.h:109
std::function< void(const UpdateLogForFragment &, TableUpdateMetadata &)> Callback
Definition: Execute.h:352
void populate_string_dictionary(const int32_t table_id, const int32_t col_id, const Catalog_Namespace::Catalog &catalog)
Definition: Execute.cpp:221
Fragmenter_Namespace::TableInfo getTableInfo(const int table_id) const
Definition: Execute.cpp:674
RUNTIME_EXPORT void register_buffer_with_executor_rsm(int64_t exec, int8_t *buffer)
static const size_t high_scan_limit
Definition: Execute.h:602
const std::unique_ptr< llvm::Module > & get_libdevice_module() const
Definition: Execute.h:499
QueryMustRunOnCpu(const std::string &err)
Definition: Execute.h:299
static const int32_t ERR_STRING_CONST_IN_RESULTSET
Definition: Execute.h:1354
void codegenWindowAvgEpilogue(llvm::Value *crt_val, llvm::Value *window_func_null_val, llvm::Value *multiplicity_lv)
static std::shared_ptr< Executor > getExecutor(const ExecutorId id, const std::string &debug_dir="", const std::string &debug_file="", const SystemParameters &system_parameters=SystemParameters())
Definition: Execute.cpp:483
void preloadFragOffsets(const std::vector< InputDescriptor > &input_descs, const std::vector< InputTableInfo > &query_infos)
Definition: Execute.cpp:3785
bool isFragmentFullyDeleted(const int table_id, const Fragmenter_Namespace::FragmentInfo &fragment)
Definition: Execute.cpp:4033
bool checkIsQuerySessionEnrolled(const QuerySessionId &query_session, mapd_shared_lock< mapd_shared_mutex > &read_lock)
Definition: Execute.cpp:4723
void setQueryStatus(const QuerySessionStatus::QueryStatus &status)
Definition: Execute.h:134
std::unordered_map< int, const ResultSetPtr & > TemporaryTables
Definition: InputMetadata.h:31
FetchResult fetchUnionChunks(const ColumnFetcher &, const RelAlgExecutionUnit &ra_exe_unit, const int device_id, const Data_Namespace::MemoryLevel, const std::map< int, const TableFragments * > &, const FragmentsList &selected_fragments, const Catalog_Namespace::Catalog &, std::list< ChunkIter > &, std::list< std::shared_ptr< Chunk_NS::Chunk >> &, DeviceAllocator *device_allocator, const size_t thread_idx, const bool allow_runtime_interrupt)
Definition: Execute.cpp:3067
static const int32_t ERR_STREAMING_TOP_N_NOT_SUPPORTED_IN_RENDER_QUERY
Definition: Execute.h:1355
const ExecutorId executor_id_
Definition: Execute.h:1196
static const int32_t ERR_COLUMNAR_CONVERSION_NOT_SUPPORTED
Definition: Execute.h:1352
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:228
int8_t warpSize() const
Definition: Execute.cpp:3840
std::map< QuerySessionId, bool > InterruptFlagMap
Definition: Execute.h:86
const size_t max_gpu_slab_size_
Definition: Execute.h:1282
ResultSetPtr reduceSpeculativeTopN(const RelAlgExecutionUnit &, std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &all_fragment_results, std::shared_ptr< RowSetMemoryOwner >, const QueryMemoryDescriptor &) const
Definition: Execute.cpp:1411
ResultSetPtr collectAllDeviceResults(SharedKernelContext &shared_context, const RelAlgExecutionUnit &ra_exe_unit, const QueryMemoryDescriptor &query_mem_desc, const ExecutorDeviceType device_type, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner)
Definition: Execute.cpp:2327
const ColumnDescriptor * getPhysicalColumnDescriptor(const Analyzer::ColumnVar *, int) const
Definition: Execute.cpp:647
std::lock_guard< std::mutex > lock_
Definition: Execute.h:1217
static void unregisterActiveModule(const int device_id)
static const int32_t ERR_DIV_BY_ZERO
Definition: Execute.h:1343
std::tuple< CompilationResult, std::unique_ptr< QueryMemoryDescriptor > > compileWorkUnit(const std::vector< InputTableInfo > &query_infos, const PlanState::DeletedColumnsMap &deleted_cols_map, const RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co, const ExecutionOptions &eo, const CudaMgr_Namespace::CudaMgr *cuda_mgr, const bool allow_lazy_fetch, std::shared_ptr< RowSetMemoryOwner >, const size_t max_groups_buffer_entry_count, const int8_t crt_min_byte_width, const bool has_cardinality_estimation, ColumnCacheMap &column_cache, RenderInfo *render_info=nullptr)
static CodeCacheAccessor< CpuCompilationContext > cpu_code_accessor
Definition: Execute.h:1271
TableIdToNodeMap table_id_to_node_map_
Definition: Execute.h:1289
bool addToQuerySessionList(const QuerySessionId &query_session, const std::string &query_str, const std::string &submitted, const size_t executor_id, const QuerySessionStatus::QueryStatus query_status, mapd_unique_lock< mapd_shared_mutex > &write_lock)
Definition: Execute.cpp:4579
bool compileBody(const RelAlgExecutionUnit &ra_exe_unit, GroupByAndAggregate &group_by_and_aggregate, QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, const GpuSharedMemoryContext &gpu_smem_context={})
std::unordered_map< size_t, HashTableBuildDag > HashTableBuildDagMap
llvm::Value * get_arg_by_name(llvm::Function *func, const std::string &name)
Definition: Execute.h:166
std::vector< llvm::Value * > LLVMValueVector
Definition: Execute.h:362
size_t get_context_count(const ExecutorDeviceType device_type, const size_t cpu_count, const size_t gpu_count)
Definition: Execute.cpp:1452
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:220
std::vector< TargetValue > getEntryAt(const size_t index) const override
int get_logical_size() const
Definition: sqltypes.h:349
std::unordered_map< int, std::vector< llvm::Value * > > fetch_cache_
Definition: CgenState.h:362
decltype(FragmentInfoType::fragmentId) const getFragmentId() const
Definition: Execute.h:346
int64_t deviceCycles(int milliseconds) const
Definition: Execute.cpp:3876
std::string generatePTX(const std::string &) const
std::mutex str_dict_mutex_
Definition: Execute.h:1264
bool is_integer() const
Definition: sqltypes.h:512
const Catalog_Namespace::Catalog * catalog_
Definition: Execute.h:1286
friend class PendingExecutionClosure
Definition: Execute.h:1401
void setQuerySessionAsInterrupted(const QuerySessionId &query_session, mapd_unique_lock< mapd_shared_mutex > &write_lock)
Definition: Execute.cpp:4701
static const int32_t ERR_OUT_OF_RENDER_MEM
Definition: Execute.h:1347
std::unordered_map< TableId, const ColumnDescriptor * > DeletedColumnsMap
Definition: PlanState.h:44
ResultSetPtr reduceMultiDeviceResults(const RelAlgExecutionUnit &, std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &all_fragment_results, std::shared_ptr< RowSetMemoryOwner >, const QueryMemoryDescriptor &) const
Definition: Execute.cpp:1304
std::shared_timed_mutex mapd_shared_mutex
const std::string debug_file_
Definition: Execute.h:1284
ResultSetPtr collectAllDeviceShardedTopResults(SharedKernelContext &shared_context, const RelAlgExecutionUnit &ra_exe_unit) const
Definition: Execute.cpp:2442
CachedCardinality getCachedCardinality(const std::string &cache_key)
Definition: Execute.cpp:4756
decltype(FragmentInfoType::physicalTableId) const getPhysicalTableId() const
Definition: Execute.h:343
std::unordered_map< int, const RelAlgNode * > TableIdToNodeMap
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
Definition: Execute.h:1253
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:86
void setColRangeCache(const AggregatedColRange &aggregated_col_range)
Definition: Execute.h:1095
bool containsLeftDeepOuterJoin() const
Definition: Execute.h:559
static QueryPlanDAG latest_query_plan_extracted_
Definition: Execute.h:1340
void setCatalog(const Catalog_Namespace::Catalog *catalog)
Definition: Execute.cpp:662
size_t getNumCurentSessionsEnrolled() const
Definition: Execute.cpp:4574
bool has_rt_module() const
Definition: Execute.h:503
StringDictionaryProxy * getStringDictionaryProxy(const int dict_id, const bool with_generation) const
Definition: Execute.h:529
std::shared_ptr< CompilationContext > optimizeAndCodegenCPU(llvm::Function *, llvm::Function *, const std::unordered_set< llvm::Function * > &, const CompilationOptions &)
static const int32_t ERR_OVERFLOW_OR_UNDERFLOW
Definition: Execute.h:1349
bool is_timeinterval() const
Definition: sqltypes.h:521
static std::unordered_map< std::string, size_t > cardinality_cache_
Definition: Execute.h:1335
static InterruptFlagMap queries_interrupt_flag_
Definition: Execute.h:1307
FragmentInfoType const & getFragmentInfo() const
const logger::ThreadId thread_id_
Definition: Execute.h:1372
std::unique_ptr< PlanState > plan_state_
Definition: Execute.h:1252
void insertErrorCodeChecker(llvm::Function *query_func, bool hoist_literals, bool allow_runtime_query_interrupt)
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
static const int32_t ERR_OUT_OF_TIME
Definition: Execute.h:1350
void initializeNVPTXBackend() const
mapd_unique_lock< mapd_shared_mutex > unique_lock
Definition: Execute.h:1318
std::map< int32_t, std::set< int32_t >> TableToFragmentIds
Definition: Execute.h:318
const std::string submitted_time_
Definition: Execute.h:143
const TableGeneration & getTableGeneration(const int table_id) const
Definition: Execute.cpp:678
llvm::Value * castToFP(llvm::Value *, SQLTypeInfo const &from_ti, SQLTypeInfo const &to_ti)
Definition: Execute.cpp:3881
size_t fragment_index_
Definition: Execute.h:358
std::pair< bool, size_t > CachedCardinality
Definition: Execute.h:1163
const ColumnDescriptor * getColumnDescriptor(const Analyzer::ColumnVar *) const
Definition: Execute.cpp:641
static const int32_t ERR_UNSUPPORTED_SELF_JOIN
Definition: Execute.h:1346
const unsigned block_size_x_
Definition: Execute.h:1280
const unsigned grid_size_x_
Definition: Execute.h:1281
specifies the content in-memory of a row in the column metadata table
bool is_boolean() const
Definition: sqltypes.h:517
std::vector< TargetValue > getTranslatedEntryAt(const size_t index) const override
static const int32_t ERR_SINGLE_VALUE_FOUND_MULTIPLE_VALUES
Definition: Execute.h:1356
static std::map< int, std::shared_ptr< Executor > > executors_
Definition: Execute.h:1310
static const int32_t ERR_OUT_OF_GPU_MEM
Definition: Execute.h:1344
std::string toString(const Executor::ExtModuleKinds &kind)
Definition: Execute.h:1453
const TemporaryTables * getTemporaryTables()
Definition: Execute.h:524
std::string get_null_check_suffix(const SQLTypeInfo &lhs_ti, const SQLTypeInfo &rhs_ti)
Definition: Execute.h:1411
const std::unique_ptr< llvm::Module > & get_rt_module() const
Definition: Execute.h:483
static const ExecutorId INVALID_EXECUTOR_ID
Definition: Execute.h:377
const Catalog_Namespace::Catalog * getCatalog() const
Definition: Execute.cpp:658
#define RUNTIME_EXPORT
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults >>> ColumnCacheMap
bool updateQuerySessionExecutorAssignment(const QuerySessionId &query_session, const std::string &submitted_time_str, const size_t executor_id, mapd_unique_lock< mapd_shared_mutex > &write_lock)
Definition: Execute.cpp:4642
Executor(const ExecutorId id, Data_Namespace::DataMgr *data_mgr, const size_t block_size_x, const size_t grid_size_x, const size_t max_gpu_slab_size, const std::string &debug_dir, const std::string &debug_file)
Definition: Execute.cpp:260
std::string dumpCache() const
Definition: Execute.cpp:4852
ColumnToFragmentsMap columns_for_metadata_update
Definition: Execute.h:321
const std::vector< size_t > getExecutorIdsRunningQuery(const QuerySessionId &interrupt_session) const
Definition: Execute.cpp:4784
#define CHECK_LT(x, y)
Definition: Logger.h:233
ResultSetPtr resultsUnion(SharedKernelContext &shared_context, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:1277
void registerExtractedQueryPlanDag(const QueryPlanDAG &query_plan_dag)
Definition: Execute.cpp:4813
std::shared_ptr< ResultSet > rs_
Definition: Execute.h:359
JoinHashTableOrError buildHashTableForQualifier(const std::shared_ptr< Analyzer::BinOper > &qual_bin_oper, const std::vector< InputTableInfo > &query_infos, const MemoryLevel memory_level, const JoinType join_type, const HashType preferred_hash_type, ColumnCacheMap &column_cache, const HashTableBuildDagMap &hashtable_build_dag_map, const RegisteredQueryHint &query_hint, const TableIdToNodeMap &table_id_to_node_map)
Definition: Execute.cpp:3806
std::vector< size_t > getFragmentCount(const FragmentsList &selected_fragments, const size_t scan_idx, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:3245
static void addUdfIrToModule(const std::string &udf_ir_filename, const bool is_cuda_ir)
llvm::BasicBlock * codegenSkipDeletedOuterTableRow(const RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co)
std::unique_ptr< QueryCompilationDescriptor > QueryCompilationDescriptorOwned
Definition: Execute.h:81
size_t ExecutorId
Definition: Execute.h:375
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
std::shared_ptr< HashJoin > buildCurrentLevelHashTable(const JoinCondition &current_level_join_conditions, size_t level_idx, RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co, const std::vector< InputTableInfo > &query_infos, ColumnCacheMap &column_cache, std::vector< std::string > &fail_reasons)
Definition: IRCodegen.cpp:935
static void update_after_registration(bool update_runtime_modules_only=false)
Definition: Execute.h:1177
std::vector< int8_t > serializeLiterals(const std::unordered_map< int, CgenState::LiteralValues > &literals, const int device_id)
Definition: Execute.cpp:776
std::shared_ptr< CompilationContext > optimizeAndCodegenGPU(llvm::Function *, llvm::Function *, std::unordered_set< llvm::Function * > &, const bool no_inline, const CudaMgr_Namespace::CudaMgr *cuda_mgr, const bool is_gpu_smem_used, const CompilationOptions &)
mapd_shared_mutex & getDataRecyclerLock()
Definition: Execute.cpp:4430
InputTableInfoCache input_table_info_cache_
Definition: Execute.h:1300
const Expr * get_operand() const
Definition: Analyzer.h:378
std::chrono::steady_clock::time_point lock_queue_clock_
Definition: Execute.h:1216
void codegenWindowFunctionStateInit(llvm::Value *aggregate_state)
static CodeCacheAccessor< CompilationContext > tf_code_accessor
Definition: Execute.h:1273
std::pair< bool, int64_t > skipFragment(const InputDescriptor &table_desc, const Fragmenter_Namespace::FragmentInfo &frag_info, const std::list< std::shared_ptr< Analyzer::Expr >> &simple_quals, const std::vector< uint64_t > &frag_offsets, const size_t frag_idx)
Definition: Execute.cpp:4126
unsigned gridSize() const
Definition: Execute.cpp:3848
llvm::Value * spillDoubleElement(llvm::Value *elem_val, llvm::Type *elem_ty)
std::pair< std::vector< std::vector< int64_t > >, std::vector< std::vector< uint64_t > > > getRowCountAndOffsetForAllFrags(const RelAlgExecutionUnit &ra_exe_unit, const CartesianProduct< std::vector< std::vector< size_t >>> &frag_ids_crossjoin, const std::vector< InputDescriptor > &input_descs, const std::map< int, const TableFragments * > &all_tables_fragments)
Definition: Execute.cpp:2837
friend class KernelSubtask
Definition: Execute.h:1385
PlanState * getPlanStatePtr() const
Definition: Execute.h:1172
uint64_t ThreadId
Definition: Logger.h:363
static std::map< ExtModuleKinds, std::string > extension_module_sources
Definition: Execute.h:479
StringDictionaryGenerations computeStringDictionaryGenerations(const std::unordered_set< PhysicalInput > &phys_inputs)
Definition: Execute.cpp:4382
bool has_udf_module(bool is_gpu=false) const
Definition: Execute.h:506
static const int32_t ERR_WIDTH_BUCKET_INVALID_ARGUMENT
Definition: Execute.h:1358
Data_Namespace::DataMgr * getDataMgr() const
Definition: Execute.h:571
bool needLinearizeAllFragments(const ColumnDescriptor *cd, const InputColDescriptor &inner_col_desc, const RelAlgExecutionUnit &ra_exe_unit, const FragmentsList &selected_fragments, const Data_Namespace::MemoryLevel memory_level) const
Definition: Execute.cpp:2905
void setExecutorId(const size_t executor_id)
Definition: Execute.h:137
std::unique_ptr< llvm::LLVMContext > context_
Definition: Execute.h:1197
CgenState * getCgenStatePtr() const
Definition: Execute.h:1171
FragmentInfoType const & fragment_info_
Definition: Execute.h:357
void nukeOldState(const bool allow_lazy_fetch, const std::vector< InputTableInfo > &query_infos, const PlanState::DeletedColumnsMap &deleted_cols_map, const RelAlgExecutionUnit *ra_exe_unit)
Definition: Execute.cpp:3765
const std::string getQueryStr()
Definition: Execute.h:130
QuerySessionStatus::QueryStatus getQuerySessionStatus(const QuerySessionId &candidate_query_session, mapd_shared_lock< mapd_shared_mutex > &read_lock)
Definition: Execute.cpp:4460
std::pair< bool, int64_t > skipFragmentInnerJoins(const InputDescriptor &table_desc, const RelAlgExecutionUnit &ra_exe_unit, const Fragmenter_Namespace::FragmentInfo &fragment, const std::vector< uint64_t > &frag_offsets, const size_t frag_idx)
Definition: Execute.cpp:4323
void buildSelectedFragsMapping(std::vector< std::vector< size_t >> &selected_fragments_crossjoin, std::vector< size_t > &local_col_to_frag_pos, const std::list< std::shared_ptr< const InputColDescriptor >> &col_global_ids, const FragmentsList &selected_fragments, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:3259
llvm::Value * codegenAggregateWindowState()
TableGenerations table_generations_
Definition: Execute.h:1302
std::function< void(ResultSetPtr, const Fragmenter_Namespace::FragmentInfo &)> PerFragmentCallBack
Definition: Execute.h:697
void resetInterrupt()
mapd_shared_lock< mapd_shared_mutex > read_lock
const size_t getExecutorId()
Definition: Execute.h:131
size_t executor_id_
Definition: Execute.h:141
bool removeFromQuerySessionList(const QuerySessionId &query_session, const std::string &submitted_time_str, mapd_unique_lock< mapd_shared_mutex > &write_lock)
Definition: Execute.cpp:4667
static void registerExtensionFunctions(F register_extension_functions)
Definition: Execute.h:421
std::string QuerySessionId
Definition: Execute.h:84
llvm::Value * addJoinLoopIterator(const std::vector< llvm::Value * > &prev_iters, const size_t level_idx)
Definition: IRCodegen.cpp:1094
ResultSetPtr reduceMultiDeviceResultSets(std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &all_fragment_results, std::shared_ptr< RowSetMemoryOwner >, const QueryMemoryDescriptor &) const
Definition: Execute.cpp:1351
llvm::Value * codegenWindowFunctionAggregate(const CompilationOptions &co)
void addToCardinalityCache(const std::string &cache_key, const size_t cache_value)
Definition: Execute.cpp:4747
#define CHECK(condition)
Definition: Logger.h:223
QueryPlanDagCache & getQueryPlanDagCache()
Definition: Execute.cpp:4434
bool has_extension_module(ExtModuleKinds kind) const
Definition: Execute.h:1233
static const int32_t ERR_OUT_OF_SLOTS
Definition: Execute.h:1345
static void clearExternalCaches(bool for_update, const TableDescriptor *td, const int current_db_id)
Definition: Execute.h:391
CgenStateManager(Executor &executor)
Definition: Execute.cpp:423
std::mutex compilation_mutex_
Definition: Execute.h:1371
void interrupt(const QuerySessionId &query_session="", const QuerySessionId &interrupt_session="")
bool has_rt_udf_module(bool is_gpu=false) const
Definition: Execute.h:510
std::vector< llvm::Value * > inlineHoistedLiterals()
static CodeCacheAccessor< GpuCompilationContext > gpu_code_accessor
Definition: Execute.h:1272
FetchResult fetchChunks(const ColumnFetcher &, const RelAlgExecutionUnit &ra_exe_unit, const int device_id, const Data_Namespace::MemoryLevel, const std::map< int, const TableFragments * > &, const FragmentsList &selected_fragments, const Catalog_Namespace::Catalog &, std::list< ChunkIter > &, std::list< std::shared_ptr< Chunk_NS::Chunk >> &, DeviceAllocator *device_allocator, const size_t thread_idx, const bool allow_runtime_interrupt)
Definition: Execute.cpp:2928
mapd_shared_lock< mapd_shared_mutex > shared_lock
Definition: Execute.h:1317
ResultSetPtr executeWorkUnitImpl(size_t &max_groups_buffer_entry_guess, const bool is_agg, const bool allow_single_frag_table_opt, const std::vector< InputTableInfo > &, const RelAlgExecutionUnit &, const CompilationOptions &, const ExecutionOptions &options, const Catalog_Namespace::Catalog &, std::shared_ptr< RowSetMemoryOwner >, RenderInfo *render_info, const bool has_cardinality_estimation, ColumnCacheMap &column_cache)
Definition: Execute.cpp:1814
std::unordered_map< int, const Analyzer::BinOper * > getInnerTabIdToJoinCond() const
Definition: Execute.cpp:2492
ExecutorDeviceType getDeviceTypeForTargets(const RelAlgExecutionUnit &ra_exe_unit, const ExecutorDeviceType requested_device_type)
Definition: Execute.cpp:2194
JoinLoop::HoistedFiltersCallback buildHoistLeftHandSideFiltersCb(const RelAlgExecutionUnit &ra_exe_unit, const size_t level_idx, const int inner_table_id, const CompilationOptions &co)
Definition: IRCodegen.cpp:768
uint32_t log2_bytes(const uint32_t bytes)
Definition: Execute.h:176
ExpressionRange getColRange(const PhysicalInput &) const
Definition: Execute.cpp:682
std::string numeric_type_name(const SQLTypeInfo &ti)
Definition: Execute.h:209
CurrentQueryStatus attachExecutorToQuerySession(const QuerySessionId &query_session_id, const std::string &query_str, const std::string &query_submitted_time)
Definition: Execute.cpp:4477
mapd_unique_lock< mapd_shared_mutex > write_lock
void redeclareFilterFunction()
Definition: IRCodegen.cpp:995
SQLTypeInfo columnType
QuerySessionStatus(const QuerySessionId &query_session, const size_t executor_id, const std::string &query_str, const std::string &submitted_time, const QuerySessionStatus::QueryStatus &query_status)
Definition: Execute.h:118
UpdateLogForFragment(FragmentInfoType const &fragment_info, size_t const, const std::shared_ptr< ResultSet > &rs)
bool is_unnest(const Analyzer::Expr *expr)
Definition: Execute.h:1427
bool is_string() const
Definition: sqltypes.h:510
std::vector< JoinLoop > buildJoinLoops(RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co, const ExecutionOptions &eo, const std::vector< InputTableInfo > &query_infos, ColumnCacheMap &column_cache)
Definition: IRCodegen.cpp:523
std::function< llvm::Value *(const std::vector< llvm::Value * > &, llvm::Value *)> buildIsDeletedCb(const RelAlgExecutionUnit &ra_exe_unit, const size_t level_idx, const CompilationOptions &co)
Definition: IRCodegen.cpp:876
auto getResultSet() const
Definition: Execute.h:354
unsigned blockSize() const
Definition: Execute.cpp:3862
string name
Definition: setup.in.py:72
static std::mutex register_runtime_extension_functions_mutex_
Definition: Execute.h:1377
Execution unit for relational algebra. It&#39;s a low-level description of any relational algebra operati...
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:336
std::unordered_map< int, std::vector< llvm::Value * > > saved_fetch_cache
Definition: Execute.h:1247
ExecutorId getExecutorId() const
Definition: Execute.h:1098
static size_t align(const size_t off_in, const size_t alignment)
Definition: Execute.h:1188
std::unique_ptr< QueryMemoryDescriptor > QueryMemoryDescriptorOwned
Definition: Execute.h:83
size_t const getRowCount() const override
const QuerySessionId getQuerySession()
Definition: Execute.h:129
void clearQuerySessionStatus(const QuerySessionId &query_session, const std::string &submitted_time_str)
Definition: Execute.cpp:4520
static const int32_t ERR_OUT_OF_CPU_MEM
Definition: Execute.h:1348
QuerySessionStatus::QueryStatus query_status_
Definition: Execute.h:150
bool is_decimal() const
Definition: sqltypes.h:513
int deviceCountForMemoryLevel(const Data_Namespace::MemoryLevel memory_level) const
Definition: Execute.cpp:1046
Descriptor for the fragments required for an execution kernel.
llvm::Value * codegenWindowFunctionAggregateCalls(llvm::Value *aggregate_state, const CompilationOptions &co)
Fragmenter_Namespace::FragmentInfo FragmentInfoType
Definition: Execute.h:327
static size_t getArenaBlockSize()
Definition: Execute.cpp:533
ResultSetPtr executeWorkUnit(size_t &max_groups_buffer_entry_guess, const bool is_agg, const std::vector< InputTableInfo > &, const RelAlgExecutionUnit &, const CompilationOptions &, const ExecutionOptions &options, const Catalog_Namespace::Catalog &, RenderInfo *render_info, const bool has_cardinality_estimation, ColumnCacheMap &column_cache)
Definition: Execute.cpp:1746
std::mutex gpu_exec_mutex_[max_gpu_count]
Definition: Execute.h:1256
HashType
Definition: HashTable.h:19
DEVICE void swap(ARGS &&...args)
Definition: gpu_enabled.h:114
llvm::LLVMContext & getContext()
Definition: Execute.h:1174
static mapd_shared_mutex recycler_mutex_
Definition: Execute.h:1334
llvm::Value * codegenWindowFunction(const size_t target_index, const CompilationOptions &co)
std::vector< int > getTableChunkKey(const int getCurrentDBId) const
SQLOps get_optype() const
Definition: Analyzer.h:377
static QueryPlanDagCache query_plan_dag_cache_
Definition: Execute.h:1333
WindowFunctionContext * active_window_function_
Definition: Execute.h:1298
static std::mutex gpu_active_modules_mutex_
Definition: Execute.h:1258
void setupCaching(const std::unordered_set< PhysicalInput > &phys_inputs, const std::unordered_set< int > &phys_table_ids)
Definition: Execute.cpp:4419
static void nukeCacheOfExecutors()
Definition: Execute.h:456
void clearMetaInfoCache()
Definition: Execute.cpp:770
FragmentSkipStatus
Definition: Execute.h:162
const ColumnDescriptor * get_column_descriptor(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:191
size_t const getEntryCount() const override
llvm::BasicBlock * codegenWindowResetStateControlFlow()
const TemporaryTables * temporary_tables_
Definition: Execute.h:1288
CompilationRetryNewScanLimit(const size_t new_scan_limit)
Definition: Execute.h:258
WatchdogException(const std::string &cause)
Definition: Execute.h:159
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:376
bool has_geos_module() const
Definition: Execute.h:514
void update_extension_modules(bool update_runtime_modules_only=false)
Definition: Execute.cpp:335
ResultSetRecyclerHolder & getRecultSetRecyclerHolder()
Definition: Execute.cpp:4438
bool isArchMaxwell(const ExecutorDeviceType dt) const
bool skipFragmentPair(const Fragmenter_Namespace::FragmentInfo &outer_fragment_info, const Fragmenter_Namespace::FragmentInfo &inner_fragment_info, const int inner_table_id, const std::unordered_map< int, const Analyzer::BinOper * > &inner_table_id_to_join_condition, const RelAlgExecutionUnit &ra_exe_unit, const ExecutorDeviceType device_type)
Definition: Execute.cpp:2746
ResultSetPtr executeExplain(const QueryCompilationDescriptor &)
Definition: Execute.cpp:2139
std::map< ExtModuleKinds, std::unique_ptr< llvm::Module > > extension_modules_
Definition: Execute.h:1237