OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 "AggregatedColRange.h"
21 #include "BufferCompaction.h"
22 #include "CartesianProduct.h"
23 #include "CgenState.h"
24 #include "CodeCache.h"
25 #include "DateTimeUtils.h"
27 #include "ExecutionKernel.h"
28 #include "GpuSharedMemoryContext.h"
29 #include "GroupByAndAggregate.h"
32 #include "NvidiaKernel.h"
33 #include "PlanState.h"
34 #include "RelAlgExecutionUnit.h"
35 #include "RelAlgTranslator.h"
37 #include "TableGenerations.h"
38 #include "TargetMetaInfo.h"
39 #include "WindowContext.h"
40 
42 
43 #include "../Logger/Logger.h"
44 #include "../Shared/SystemParameters.h"
45 #include "../Shared/mapd_shared_mutex.h"
46 #include "../Shared/measure.h"
47 #include "../Shared/thread_count.h"
48 #include "../StringDictionary/LruCache.hpp"
49 #include "../StringDictionary/StringDictionary.h"
50 #include "../StringDictionary/StringDictionaryProxy.h"
51 #include "DataMgr/Chunk/Chunk.h"
53 
54 #include <llvm/IR/Function.h>
55 #include <llvm/IR/Value.h>
56 #include <llvm/Linker/Linker.h>
57 #include <llvm/Transforms/Utils/ValueMapper.h>
58 #include <rapidjson/document.h>
59 
60 #include <algorithm>
61 #include <atomic>
62 #include <condition_variable>
63 #include <cstddef>
64 #include <cstdlib>
65 #include <deque>
66 #include <functional>
67 #include <limits>
68 #include <map>
69 #include <mutex>
70 #include <stack>
71 #include <unordered_map>
72 #include <unordered_set>
73 
74 using QueryCompilationDescriptorOwned = std::unique_ptr<QueryCompilationDescriptor>;
76 using QueryMemoryDescriptorOwned = std::unique_ptr<QueryMemoryDescriptor>;
77 using InterruptFlagMap = std::map<std::string, bool>;
79  public:
81  const std::string& query_session,
82  const std::string& query_str,
83  const std::chrono::time_point<std::chrono::system_clock> submitted_time)
84  : query_session_(query_session)
85  , query_str_(query_str)
86  , submitted_time_(submitted_time)
87  , query_status_("Pending") {}
89  const std::string& query_session,
90  const std::string& query_str,
91  const std::chrono::time_point<std::chrono::system_clock> submitted_time,
92  const std::string& query_status)
93  : query_session_(query_session)
94  , query_str_(query_str)
95  , submitted_time_(submitted_time)
96  , query_status_(query_status) {}
97 
98  const std::string getQuerySession() { return query_session_; }
99  const std::string getQueryStr() { return query_str_; }
100  const std::chrono::time_point<std::chrono::system_clock> getQuerySubmittedTime() {
101  return submitted_time_;
102  }
103  const std::string getQueryStatus() { return query_status_; }
104  void setQueryStatusAsRunning() { query_status_ = "Running"; }
105 
106  private:
107  const std::string query_session_;
108  const std::string query_str_;
109  const std::chrono::time_point<std::chrono::system_clock> submitted_time_;
110  std::string query_status_;
111 };
112 using QuerySessionMap = std::map<const std::string, QuerySessionStatus>;
113 extern void read_udf_gpu_module(const std::string& udf_ir_filename);
114 extern void read_udf_cpu_module(const std::string& udf_ir_filename);
115 extern bool is_udf_module_present(bool cpu_only = false);
116 extern void read_rt_udf_gpu_module(const std::string& udf_ir);
117 extern void read_rt_udf_cpu_module(const std::string& udf_ir);
118 extern bool is_rt_udf_module_present(bool cpu_only = false);
119 
120 class ColumnFetcher;
121 
122 class WatchdogException : public std::runtime_error {
123  public:
124  WatchdogException(const std::string& cause) : std::runtime_error(cause) {}
125 };
126 
127 class Executor;
128 
129 inline llvm::Value* get_arg_by_name(llvm::Function* func, const std::string& name) {
130  for (auto& arg : func->args()) {
131  if (arg.getName() == name) {
132  return &arg;
133  }
134  }
135  CHECK(false);
136  return nullptr;
137 }
138 
139 inline uint32_t log2_bytes(const uint32_t bytes) {
140  switch (bytes) {
141  case 1:
142  return 0;
143  case 2:
144  return 1;
145  case 4:
146  return 2;
147  case 8:
148  return 3;
149  default:
150  abort();
151  }
152 }
153 
155  const int col_id,
156  const int table_id,
158  CHECK_GT(table_id, 0);
159  const auto col_desc = cat.getMetadataForColumn(table_id, col_id);
160  CHECK(col_desc);
161  return col_desc;
162 }
163 
164 inline const Analyzer::Expr* extract_cast_arg(const Analyzer::Expr* expr) {
165  const auto cast_expr = dynamic_cast<const Analyzer::UOper*>(expr);
166  if (!cast_expr || cast_expr->get_optype() != kCAST) {
167  return expr;
168  }
169  return cast_expr->get_operand();
170 }
171 
172 inline std::string numeric_type_name(const SQLTypeInfo& ti) {
173  CHECK(ti.is_integer() || ti.is_decimal() || ti.is_boolean() || ti.is_time() ||
174  ti.is_fp() || (ti.is_string() && ti.get_compression() == kENCODING_DICT) ||
175  ti.is_timeinterval());
176  if (ti.is_integer() || ti.is_decimal() || ti.is_boolean() || ti.is_time() ||
177  ti.is_string() || ti.is_timeinterval()) {
178  return "int" + std::to_string(ti.get_logical_size() * 8) + "_t";
179  }
180  return ti.get_type() == kDOUBLE ? "double" : "float";
181 }
182 
184  const int col_id,
185  const int table_id,
187  CHECK(table_id);
188  return table_id > 0 ? get_column_descriptor(col_id, table_id, cat) : nullptr;
189 }
190 
191 inline const ResultSetPtr& get_temporary_table(const TemporaryTables* temporary_tables,
192  const int table_id) {
193  CHECK_LT(table_id, 0);
194  const auto it = temporary_tables->find(table_id);
195  CHECK(it != temporary_tables->end());
196  return it->second;
197 }
198 
199 inline const SQLTypeInfo get_column_type(const int col_id,
200  const int table_id,
201  const ColumnDescriptor* cd,
202  const TemporaryTables* temporary_tables) {
203  CHECK(cd || temporary_tables);
204  if (cd) {
205  CHECK_EQ(col_id, cd->columnId);
206  CHECK_EQ(table_id, cd->tableId);
207  return cd->columnType;
208  }
209  const auto& temp = get_temporary_table(temporary_tables, table_id);
210  return temp->getColType(col_id);
211 }
212 
213 template <typename PtrTy>
215  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
216  const PtrTy& result,
217  const int number) {
218  std::vector<SQLTypeInfo> col_types;
219  for (size_t i = 0; i < result->colCount(); ++i) {
220  col_types.push_back(get_logical_type_info(result->getColType(i)));
221  }
222  return new ColumnarResults(row_set_mem_owner, *result, number, col_types);
223 }
224 
225 // TODO(alex): Adjust interfaces downstream and make this not needed.
226 inline std::vector<Analyzer::Expr*> get_exprs_not_owned(
227  const std::vector<std::shared_ptr<Analyzer::Expr>>& exprs) {
228  std::vector<Analyzer::Expr*> exprs_not_owned;
229  for (const auto& expr : exprs) {
230  exprs_not_owned.push_back(expr.get());
231  }
232  return exprs_not_owned;
233 }
234 
236  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
237  const ResultSetPtr& result,
238  const int frag_id) {
240  CHECK_EQ(0, frag_id);
241  return rows_to_columnar_results(row_set_mem_owner, result, result->colCount());
242 }
243 
244 class CompilationRetryNoLazyFetch : public std::runtime_error {
245  public:
247  : std::runtime_error("Retry query compilation with no GPU lazy fetch.") {}
248 };
249 
250 class CompilationRetryNewScanLimit : public std::runtime_error {
251  public:
252  CompilationRetryNewScanLimit(const size_t new_scan_limit)
253  : std::runtime_error("Retry query compilation with new scan limit.")
254  , new_scan_limit_(new_scan_limit) {}
255 
257 };
258 
259 class TooManyLiterals : public std::runtime_error {
260  public:
261  TooManyLiterals() : std::runtime_error("Too many literals in the query") {}
262 };
263 
264 class CompilationRetryNoCompaction : public std::runtime_error {
265  public:
267  : std::runtime_error("Retry query compilation with no compaction.") {}
268 };
269 
270 class QueryMustRunOnCpu : public std::runtime_error {
271  public:
272  QueryMustRunOnCpu() : std::runtime_error("Query must run in cpu mode.") {}
273 };
274 
275 class SringConstInResultSet : public std::runtime_error {
276  public:
278  : std::runtime_error(
279  "NONE ENCODED String types are not supported as input result set.") {}
280 };
281 
282 class ExtensionFunction;
283 
285 
287  public:
289 
290  UpdateLogForFragment(FragmentInfoType const& fragment_info,
291  size_t const,
292  const std::shared_ptr<ResultSet>& rs);
293 
294  std::vector<TargetValue> getEntryAt(const size_t index) const override;
295  std::vector<TargetValue> getTranslatedEntryAt(const size_t index) const override;
296 
297  size_t const getRowCount() const override;
299  return rs_->getRowSetMemOwner()->getLiteralStringDictProxy();
300  }
301  size_t const getEntryCount() const override;
302  size_t const getFragmentIndex() const;
303  FragmentInfoType const& getFragmentInfo() const;
306  }
307  decltype(FragmentInfoType::fragmentId) const getFragmentId() const {
308  return fragment_info_.fragmentId;
309  }
310 
311  SQLTypeInfo getColumnType(const size_t col_idx) const;
312 
313  using Callback = std::function<void(const UpdateLogForFragment&)>;
314 
315  auto getResultSet() const { return rs_; }
316 
317  private:
320  std::shared_ptr<ResultSet> rs_;
321 };
322 
323 using LLVMValueVector = std::vector<llvm::Value*>;
324 
326 
327 std::ostream& operator<<(std::ostream&, FetchResult const&);
328 
329 class Executor {
330  static_assert(sizeof(float) == 4 && sizeof(double) == 8,
331  "Host hardware not supported, unexpected size of float / double.");
332  static_assert(sizeof(time_t) == 8,
333  "Host hardware not supported, 64-bit time support is required.");
334 
335  public:
336  using ExecutorId = size_t;
337  static const ExecutorId UNITARY_EXECUTOR_ID = 0;
338 
339  Executor(const ExecutorId id,
340  const size_t block_size_x,
341  const size_t grid_size_x,
342  const size_t max_gpu_slab_size,
343  const std::string& debug_dir,
344  const std::string& debug_file);
345 
346  static std::shared_ptr<Executor> getExecutor(
347  const ExecutorId id,
348  const std::string& debug_dir = "",
349  const std::string& debug_file = "",
350  const SystemParameters system_parameters = SystemParameters());
351 
352  static void nukeCacheOfExecutors() {
353  mapd_unique_lock<mapd_shared_mutex> flush_lock(
354  execute_mutex_); // don't want native code to vanish while executing
355  mapd_unique_lock<mapd_shared_mutex> lock(executors_cache_mutex_);
356  (decltype(executors_){}).swap(executors_);
357  }
358 
359  static void clearMemory(const Data_Namespace::MemoryLevel memory_level);
360 
361  static size_t getArenaBlockSize();
362 
364  const int dictId,
365  const std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
366  const bool with_generation) const;
367 
368  bool isCPUOnly() const;
369 
370  bool isArchMaxwell(const ExecutorDeviceType dt) const;
371 
373  return cgen_state_->contains_left_deep_outer_join_;
374  }
375 
377 
379  int) const;
380 
381  const Catalog_Namespace::Catalog* getCatalog() const;
382  void setCatalog(const Catalog_Namespace::Catalog* catalog);
383 
384  const std::shared_ptr<RowSetMemoryOwner> getRowSetMemoryOwner() const;
385 
386  const TemporaryTables* getTemporaryTables() const;
387 
388  Fragmenter_Namespace::TableInfo getTableInfo(const int table_id) const;
389 
390  const TableGeneration& getTableGeneration(const int table_id) const;
391 
393 
394  size_t getNumBytesForFetchedRow(const std::set<int>& table_ids_to_fetch) const;
395 
396  std::vector<ColumnLazyFetchInfo> getColLazyFetchInfo(
397  const std::vector<Analyzer::Expr*>& target_exprs) const;
398 
399  void registerActiveModule(void* module, const int device_id) const;
400  void unregisterActiveModule(void* module, const int device_id) const;
401  void interrupt(const std::string& query_session = "",
402  const std::string& interrupt_session = "");
403  void resetInterrupt();
404 
405  // only for testing usage
406  void enableRuntimeQueryInterrupt(const double runtime_query_check_freq,
407  const unsigned pending_query_check_freq) const;
408 
409  static const size_t high_scan_limit{32000000};
410 
411  int8_t warpSize() const;
412  unsigned gridSize() const;
413  unsigned numBlocksPerMP() const;
414  unsigned blockSize() const;
415  size_t maxGpuSlabSize() const;
416 
417  ResultSetPtr executeWorkUnit(size_t& max_groups_buffer_entry_guess,
418  const bool is_agg,
419  const std::vector<InputTableInfo>&,
420  const RelAlgExecutionUnit&,
421  const CompilationOptions&,
422  const ExecutionOptions& options,
424  RenderInfo* render_info,
425  const bool has_cardinality_estimation,
426  ColumnCacheMap& column_cache);
427 
428  void executeUpdate(const RelAlgExecutionUnit& ra_exe_unit,
429  const std::vector<InputTableInfo>& table_infos,
430  const CompilationOptions& co,
431  const ExecutionOptions& eo,
433  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
435  const bool is_agg);
436 
437  private:
438  void clearMetaInfoCache();
439 
440  int deviceCount(const ExecutorDeviceType) const;
441  int deviceCountForMemoryLevel(const Data_Namespace::MemoryLevel memory_level) const;
442 
443  // Generate code for a window function target.
444  llvm::Value* codegenWindowFunction(const size_t target_index,
445  const CompilationOptions& co);
446 
447  // Generate code for an aggregate window function target.
448  llvm::Value* codegenWindowFunctionAggregate(const CompilationOptions& co);
449 
450  // The aggregate state requires a state reset when starting a new partition. Generate
451  // the new partition check and return the continuation basic block.
452  llvm::BasicBlock* codegenWindowResetStateControlFlow();
453 
454  // Generate code for initializing the state of a window aggregate.
455  void codegenWindowFunctionStateInit(llvm::Value* aggregate_state);
456 
457  // Generates the required calls for an aggregate window function and returns the final
458  // result.
459  llvm::Value* codegenWindowFunctionAggregateCalls(llvm::Value* aggregate_state,
460  const CompilationOptions& co);
461 
462  // The AVG window function requires some post-processing: the sum is divided by count
463  // and the result is stored back for the current row.
464  void codegenWindowAvgEpilogue(llvm::Value* crt_val,
465  llvm::Value* window_func_null_val,
466  llvm::Value* multiplicity_lv);
467 
468  // Generates code which loads the current aggregate value for the window context.
469  llvm::Value* codegenAggregateWindowState();
470 
471  llvm::Value* aggregateWindowStatePtr();
472 
474  if (dt == ExecutorDeviceType::GPU) {
475  const auto cuda_mgr = catalog_->getDataMgr().getCudaMgr();
476  LOG_IF(FATAL, cuda_mgr == nullptr)
477  << "No CudaMgr instantiated, unable to check device architecture";
478  return cuda_mgr->isArchPascalOrLater();
479  }
480  return false;
481  }
482 
483  bool needFetchAllFragments(const InputColDescriptor& col_desc,
484  const RelAlgExecutionUnit& ra_exe_unit,
485  const FragmentsList& selected_fragments) const;
486 
487  using PerFragmentCallBack =
488  std::function<void(ResultSetPtr, const Fragmenter_Namespace::FragmentInfo&)>;
489 
495  void executeWorkUnitPerFragment(const RelAlgExecutionUnit& ra_exe_unit,
496  const InputTableInfo& table_info,
497  const CompilationOptions& co,
498  const ExecutionOptions& eo,
500  PerFragmentCallBack& cb);
501 
503 
510  const std::vector<InputTableInfo>& table_infos,
511  const CompilationOptions& co,
512  const ExecutionOptions& eo,
514 
516  const RelAlgExecutionUnit& ra_exe_unit,
517  const ExecutorDeviceType requested_device_type);
518 
520  SharedKernelContext& shared_context,
521  const RelAlgExecutionUnit& ra_exe_unit,
523  const ExecutorDeviceType device_type,
524  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner);
525 
527  SharedKernelContext& shared_context,
528  const RelAlgExecutionUnit& ra_exe_unit) const;
529 
530  std::unordered_map<int, const Analyzer::BinOper*> getInnerTabIdToJoinCond() const;
531 
536  std::vector<std::unique_ptr<ExecutionKernel>> createKernels(
537  SharedKernelContext& shared_context,
538  const RelAlgExecutionUnit& ra_exe_unit,
539  ColumnFetcher& column_fetcher,
540  const std::vector<InputTableInfo>& table_infos,
541  const ExecutionOptions& eo,
542  const bool is_agg,
543  const bool allow_single_frag_table_opt,
544  const size_t context_count,
545  const QueryCompilationDescriptor& query_comp_desc,
547  RenderInfo* render_info,
548  std::unordered_set<int>& available_gpus,
549  int& available_cpus);
550 
555  template <typename THREAD_POOL>
556  void launchKernels(SharedKernelContext& shared_context,
557  std::vector<std::unique_ptr<ExecutionKernel>>&& kernels);
558 
559  std::vector<size_t> getTableFragmentIndices(
560  const RelAlgExecutionUnit& ra_exe_unit,
561  const ExecutorDeviceType device_type,
562  const size_t table_idx,
563  const size_t outer_frag_idx,
564  std::map<int, const TableFragments*>& selected_tables_fragments,
565  const std::unordered_map<int, const Analyzer::BinOper*>&
566  inner_table_id_to_join_condition);
567 
568  bool skipFragmentPair(const Fragmenter_Namespace::FragmentInfo& outer_fragment_info,
569  const Fragmenter_Namespace::FragmentInfo& inner_fragment_info,
570  const int inner_table_id,
571  const std::unordered_map<int, const Analyzer::BinOper*>&
572  inner_table_id_to_join_condition,
573  const RelAlgExecutionUnit& ra_exe_unit,
574  const ExecutorDeviceType device_type);
575 
577  const RelAlgExecutionUnit& ra_exe_unit,
578  const int device_id,
580  const std::map<int, const TableFragments*>&,
581  const FragmentsList& selected_fragments,
583  std::list<ChunkIter>&,
584  std::list<std::shared_ptr<Chunk_NS::Chunk>>&,
585  DeviceAllocator* device_allocator);
586 
588  const RelAlgExecutionUnit& ra_exe_unit,
589  const int device_id,
591  const std::map<int, const TableFragments*>&,
592  const FragmentsList& selected_fragments,
594  std::list<ChunkIter>&,
595  std::list<std::shared_ptr<Chunk_NS::Chunk>>&,
596  DeviceAllocator* device_allocator);
597 
598  std::pair<std::vector<std::vector<int64_t>>, std::vector<std::vector<uint64_t>>>
600  const RelAlgExecutionUnit& ra_exe_unit,
601  const CartesianProduct<std::vector<std::vector<size_t>>>& frag_ids_crossjoin,
602  const std::vector<InputDescriptor>& input_descs,
603  const std::map<int, const TableFragments*>& all_tables_fragments);
604 
606  std::vector<std::vector<size_t>>& selected_fragments_crossjoin,
607  std::vector<size_t>& local_col_to_frag_pos,
608  const std::list<std::shared_ptr<const InputColDescriptor>>& col_global_ids,
609  const FragmentsList& selected_fragments,
610  const RelAlgExecutionUnit& ra_exe_unit);
611 
613  std::vector<std::vector<size_t>>& selected_fragments_crossjoin,
614  std::vector<size_t>& local_col_to_frag_pos,
615  const std::list<std::shared_ptr<const InputColDescriptor>>& col_global_ids,
616  const FragmentsList& selected_fragments,
617  const RelAlgExecutionUnit& ra_exe_unit);
618 
619  std::vector<size_t> getFragmentCount(const FragmentsList& selected_fragments,
620  const size_t scan_idx,
621  const RelAlgExecutionUnit& ra_exe_unit);
622 
623  int32_t executePlanWithGroupBy(const RelAlgExecutionUnit& ra_exe_unit,
624  const CompilationResult&,
625  const bool hoist_literals,
626  ResultSetPtr& results,
627  const ExecutorDeviceType device_type,
628  std::vector<std::vector<const int8_t*>>& col_buffers,
629  const std::vector<size_t> outer_tab_frag_ids,
631  const std::vector<std::vector<int64_t>>& num_rows,
632  const std::vector<std::vector<uint64_t>>& frag_offsets,
634  const int device_id,
635  const int outer_table_id,
636  const int64_t limit,
637  const uint32_t start_rowid,
638  const uint32_t num_tables,
639  RenderInfo* render_info);
641  const RelAlgExecutionUnit& ra_exe_unit,
642  const CompilationResult&,
643  const bool hoist_literals,
644  ResultSetPtr& results,
645  const std::vector<Analyzer::Expr*>& target_exprs,
646  const ExecutorDeviceType device_type,
647  std::vector<std::vector<const int8_t*>>& col_buffers,
648  QueryExecutionContext* query_exe_context,
649  const std::vector<std::vector<int64_t>>& num_rows,
650  const std::vector<std::vector<uint64_t>>& frag_offsets,
651  Data_Namespace::DataMgr* data_mgr,
652  const int device_id,
653  const uint32_t start_rowid,
654  const uint32_t num_tables,
655  RenderInfo* render_info);
656 
657  public: // Temporary, ask saman about this
658  static std::pair<int64_t, int32_t> reduceResults(const SQLAgg agg,
659  const SQLTypeInfo& ti,
660  const int64_t agg_init_val,
661  const int8_t out_byte_width,
662  const int64_t* out_vec,
663  const size_t out_vec_sz,
664  const bool is_group_by,
665  const bool float_argument_input);
666 
667  static void addCodeToCache(const CodeCacheKey&,
668  std::shared_ptr<CompilationContext>,
669  llvm::Module*,
670  CodeCache&);
671 
672  private:
674  const RelAlgExecutionUnit& ra_exe_unit);
675  std::vector<int64_t> getJoinHashTablePtrs(const ExecutorDeviceType device_type,
676  const int device_id);
678  const RelAlgExecutionUnit&,
679  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>>& all_fragment_results,
680  std::shared_ptr<RowSetMemoryOwner>,
681  const QueryMemoryDescriptor&) const;
683  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>>& all_fragment_results,
684  std::shared_ptr<RowSetMemoryOwner>,
685  const QueryMemoryDescriptor&) const;
687  const RelAlgExecutionUnit&,
688  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>>& all_fragment_results,
689  std::shared_ptr<RowSetMemoryOwner>,
690  const QueryMemoryDescriptor&) const;
691 
692  ResultSetPtr executeWorkUnitImpl(size_t& max_groups_buffer_entry_guess,
693  const bool is_agg,
694  const bool allow_single_frag_table_opt,
695  const std::vector<InputTableInfo>&,
696  const RelAlgExecutionUnit&,
697  const CompilationOptions&,
698  const ExecutionOptions& options,
700  std::shared_ptr<RowSetMemoryOwner>,
701  RenderInfo* render_info,
702  const bool has_cardinality_estimation,
703  ColumnCacheMap& column_cache);
704 
705  std::vector<llvm::Value*> inlineHoistedLiterals();
706 
707  std::tuple<CompilationResult, std::unique_ptr<QueryMemoryDescriptor>> compileWorkUnit(
708  const std::vector<InputTableInfo>& query_infos,
709  const PlanState::DeletedColumnsMap& deleted_cols_map,
710  const RelAlgExecutionUnit& ra_exe_unit,
711  const CompilationOptions& co,
712  const ExecutionOptions& eo,
713  const CudaMgr_Namespace::CudaMgr* cuda_mgr,
714  const bool allow_lazy_fetch,
715  std::shared_ptr<RowSetMemoryOwner>,
716  const size_t max_groups_buffer_entry_count,
717  const int8_t crt_min_byte_width,
718  const bool has_cardinality_estimation,
719  ColumnCacheMap& column_cache,
720  RenderInfo* render_info = nullptr);
721  // Generate code to skip the deleted rows in the outermost table.
722  llvm::BasicBlock* codegenSkipDeletedOuterTableRow(
723  const RelAlgExecutionUnit& ra_exe_unit,
724  const CompilationOptions& co);
725  std::vector<JoinLoop> buildJoinLoops(RelAlgExecutionUnit& ra_exe_unit,
726  const CompilationOptions& co,
727  const ExecutionOptions& eo,
728  const std::vector<InputTableInfo>& query_infos,
729  ColumnCacheMap& column_cache);
730  // Create a callback which generates code which returns true iff the row on the given
731  // level is deleted.
732  std::function<llvm::Value*(const std::vector<llvm::Value*>&, llvm::Value*)>
733  buildIsDeletedCb(const RelAlgExecutionUnit& ra_exe_unit,
734  const size_t level_idx,
735  const CompilationOptions& co);
736  // Builds a join hash table for the provided conditions on the current level.
737  // Returns null iff on failure and provides the reasons in `fail_reasons`.
738  std::shared_ptr<JoinHashTableInterface> buildCurrentLevelHashTable(
739  const JoinCondition& current_level_join_conditions,
740  RelAlgExecutionUnit& ra_exe_unit,
741  const CompilationOptions& co,
742  const std::vector<InputTableInfo>& query_infos,
743  ColumnCacheMap& column_cache,
744  std::vector<std::string>& fail_reasons);
746  llvm::Value* addJoinLoopIterator(const std::vector<llvm::Value*>& prev_iters,
747  const size_t level_idx);
748  void codegenJoinLoops(const std::vector<JoinLoop>& join_loops,
749  const RelAlgExecutionUnit& ra_exe_unit,
750  GroupByAndAggregate& group_by_and_aggregate,
751  llvm::Function* query_func,
752  llvm::BasicBlock* entry_bb,
754  const CompilationOptions& co,
755  const ExecutionOptions& eo);
756  bool compileBody(const RelAlgExecutionUnit& ra_exe_unit,
757  GroupByAndAggregate& group_by_and_aggregate,
759  const CompilationOptions& co,
760  const GpuSharedMemoryContext& gpu_smem_context = {});
761 
762  void createErrorCheckControlFlow(llvm::Function* query_func,
763  bool run_with_dynamic_watchdog,
764  bool run_with_allowing_runtime_interrupt,
765  ExecutorDeviceType device_type,
766  const std::vector<InputTableInfo>& input_table_infos);
767 
768  void insertErrorCodeChecker(llvm::Function* query_func, bool hoist_literals);
769 
770  void preloadFragOffsets(const std::vector<InputDescriptor>& input_descs,
771  const std::vector<InputTableInfo>& query_infos);
772 
774  std::shared_ptr<JoinHashTableInterface> hash_table;
775  std::string fail_reason;
776  };
777 
779  const std::shared_ptr<Analyzer::BinOper>& qual_bin_oper,
780  const std::vector<InputTableInfo>& query_infos,
781  const MemoryLevel memory_level,
782  const JoinHashTableInterface::HashType preferred_hash_type,
783  ColumnCacheMap& column_cache);
784  void nukeOldState(const bool allow_lazy_fetch,
785  const std::vector<InputTableInfo>& query_infos,
786  const PlanState::DeletedColumnsMap& deleted_cols_map,
787  const RelAlgExecutionUnit* ra_exe_unit);
788 
789  std::shared_ptr<CompilationContext> optimizeAndCodegenCPU(
790  llvm::Function*,
791  llvm::Function*,
792  const std::unordered_set<llvm::Function*>&,
793  const CompilationOptions&);
794  std::shared_ptr<CompilationContext> optimizeAndCodegenGPU(
795  llvm::Function*,
796  llvm::Function*,
797  std::unordered_set<llvm::Function*>&,
798  const bool no_inline,
799  const CudaMgr_Namespace::CudaMgr* cuda_mgr,
800  const CompilationOptions&);
801  std::string generatePTX(const std::string&) const;
802  void initializeNVPTXBackend() const;
803 
804  int64_t deviceCycles(int milliseconds) const;
805 
807  llvm::Value* translated_value;
808  llvm::Value* original_value;
809  };
810 
812  const size_t col_width,
813  const CompilationOptions&,
814  const bool translate_null_val,
815  const int64_t translated_null_val,
817  std::stack<llvm::BasicBlock*>&,
818  const bool thread_mem_shared);
819 
820  llvm::Value* castToFP(llvm::Value* val);
821  llvm::Value* castToIntPtrTyIn(llvm::Value* val, const size_t bit_width);
822 
823  std::tuple<RelAlgExecutionUnit, PlanState::DeletedColumnsMap> addDeletedColumn(
824  const RelAlgExecutionUnit& ra_exe_unit,
825  const CompilationOptions& co);
826 
827  std::pair<bool, int64_t> skipFragment(
828  const InputDescriptor& table_desc,
829  const Fragmenter_Namespace::FragmentInfo& frag_info,
830  const std::list<std::shared_ptr<Analyzer::Expr>>& simple_quals,
831  const std::vector<uint64_t>& frag_offsets,
832  const size_t frag_idx);
833 
834  std::pair<bool, int64_t> skipFragmentInnerJoins(
835  const InputDescriptor& table_desc,
836  const RelAlgExecutionUnit& ra_exe_unit,
837  const Fragmenter_Namespace::FragmentInfo& fragment,
838  const std::vector<uint64_t>& frag_offsets,
839  const size_t frag_idx);
840 
842  const std::unordered_set<PhysicalInput>& phys_inputs);
844  const std::unordered_set<PhysicalInput>& phys_inputs);
845  TableGenerations computeTableGenerations(std::unordered_set<int> phys_table_ids);
846 
847  public:
848  void setupCaching(const std::unordered_set<PhysicalInput>& phys_inputs,
849  const std::unordered_set<int>& phys_table_ids);
850  void setColRangeCache(const AggregatedColRange& aggregated_col_range) {
851  agg_col_range_cache_ = aggregated_col_range;
852  }
853 
854  template <typename SESSION_MAP_LOCK>
855  void setCurrentQuerySession(const std::string& query_session,
856  SESSION_MAP_LOCK& write_lock);
857  template <typename SESSION_MAP_LOCK>
858  std::string& getCurrentQuerySession(SESSION_MAP_LOCK& read_lock);
859  template <typename SESSION_MAP_LOCK>
860  bool checkCurrentQuerySession(const std::string& candidate_query_session,
861  SESSION_MAP_LOCK& read_lock);
862  template <typename SESSION_MAP_LOCK>
863  void invalidateRunningQuerySession(SESSION_MAP_LOCK& write_lock);
864  template <typename SESSION_MAP_LOCK>
865  bool addToQuerySessionList(const std::string& query_session,
866  const std::string& query_str,
867  SESSION_MAP_LOCK& write_lock);
868  template <typename SESSION_MAP_LOCK>
869  bool removeFromQuerySessionList(const std::string& query_session,
870  SESSION_MAP_LOCK& write_lock);
871  template <typename SESSION_MAP_LOCK>
872  void setQuerySessionAsInterrupted(const std::string& query_session,
873  SESSION_MAP_LOCK& write_lock);
874  template <typename SESSION_MAP_LOCK>
875  bool checkIsQuerySessionInterrupted(const std::string& query_session,
876  SESSION_MAP_LOCK& read_lock);
877  std::optional<QuerySessionStatus> getQuerySessionInfo(
878  const std::string& query_session,
879  mapd_shared_lock<mapd_shared_mutex>& read_lock);
881 
882  // true when we have matched cardinality, and false otherwise
883  using CachedCardinality = std::pair<bool, size_t>;
884  void addToCardinalityCache(const std::string& cache_key, const size_t cache_value);
885  CachedCardinality getCachedCardinality(const std::string& cache_key);
886 
887  private:
888  std::shared_ptr<CompilationContext> getCodeFromCache(const CodeCacheKey&,
889  const CodeCache&);
890 
891  std::vector<int8_t> serializeLiterals(
892  const std::unordered_map<int, CgenState::LiteralValues>& literals,
893  const int device_id);
894 
895  static size_t align(const size_t off_in, const size_t alignment) {
896  size_t off = off_in;
897  if (off % alignment != 0) {
898  off += (alignment - off % alignment);
899  }
900  return off;
901  }
902 
903  std::unique_ptr<CgenState> cgen_state_;
904 
906  public:
908  : cgen_state_(cgen_state), saved_fetch_cache(cgen_state_->fetch_cache_) {}
910 
911  private:
913  std::unordered_map<int, std::vector<llvm::Value*>> saved_fetch_cache;
914  };
915 
916  llvm::Value* spillDoubleElement(llvm::Value* elem_val, llvm::Type* elem_ty);
917 
918  std::unique_ptr<PlanState> plan_state_;
919  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner_;
920 
921  static const int max_gpu_count{16};
923 
924  static std::mutex gpu_active_modules_mutex_;
927  static std::atomic<bool> interrupted_;
928 
929  mutable std::shared_ptr<StringDictionaryProxy> lit_str_dict_proxy_;
930  mutable std::mutex str_dict_mutex_;
931 
932  mutable std::unique_ptr<llvm::TargetMachine> nvptx_target_machine_;
933 
936 
937  static const size_t baseline_threshold{
938  1000000}; // if a perfect hash needs more entries, use baseline
939  static const size_t code_cache_size{1000};
940 
941  const unsigned block_size_x_;
942  const unsigned grid_size_x_;
943  const size_t max_gpu_slab_size_;
944  const std::string debug_dir_;
945  const std::string debug_file_;
946 
950 
953 
954  // Singleton instance used for an execution unit which is a project with window
955  // functions.
956  std::unique_ptr<WindowProjectNodeContext> window_project_node_context_owned_;
957  // The active window function.
959 
965  static std::string current_query_session_;
966  // a pair of <query_session, interrupted_flag>
968  // a pair of <query_session, query_session_status>
970 
971  static std::map<int, std::shared_ptr<Executor>> executors_;
972  static std::atomic_flag execute_spin_lock_;
973 
974  // SQL queries take a shared lock, exclusive options (cache clear, memory clear) take a
975  // write lock
978 
979  // for now we use recycler_mutex only for cardinality_cache_
980  // and will expand its coverage for more interesting caches for query excution
982  static std::unordered_map<std::string, size_t> cardinality_cache_;
983 
984  public:
985  static const int32_t ERR_DIV_BY_ZERO{1};
986  static const int32_t ERR_OUT_OF_GPU_MEM{2};
987  static const int32_t ERR_OUT_OF_SLOTS{3};
988  static const int32_t ERR_UNSUPPORTED_SELF_JOIN{4};
989  static const int32_t ERR_OUT_OF_RENDER_MEM{5};
990  static const int32_t ERR_OUT_OF_CPU_MEM{6};
991  static const int32_t ERR_OVERFLOW_OR_UNDERFLOW{7};
992  static const int32_t ERR_OUT_OF_TIME{9};
993  static const int32_t ERR_INTERRUPTED{10};
994  static const int32_t ERR_COLUMNAR_CONVERSION_NOT_SUPPORTED{11};
995  static const int32_t ERR_TOO_MANY_LITERALS{12};
996  static const int32_t ERR_STRING_CONST_IN_RESULTSET{13};
998  static const int32_t ERR_SINGLE_VALUE_FOUND_MULTIPLE_VALUES{15};
999  static const int32_t ERR_GEOS{16};
1000 
1001  static std::mutex compilation_mutex_;
1002  static std::mutex kernel_mutex_;
1003 
1005  friend class CodeGenerator;
1006  friend class ColumnFetcher;
1007  friend class ExecutionKernel;
1009  friend class GroupByAndAggregate;
1015  friend class ResultSet;
1016  friend class InValuesBitmap;
1017  friend class JoinHashTable;
1018  friend class LeafAggregator;
1019  friend class QueryRewriter;
1021  friend class RelAlgExecutor;
1022  friend class TableOptimizer;
1026  friend struct TargetExprCodegen;
1028 };
1029 
1030 inline std::string get_null_check_suffix(const SQLTypeInfo& lhs_ti,
1031  const SQLTypeInfo& rhs_ti) {
1032  if (lhs_ti.get_notnull() && rhs_ti.get_notnull()) {
1033  return "";
1034  }
1035  std::string null_check_suffix{"_nullable"};
1036  if (lhs_ti.get_notnull()) {
1037  CHECK(!rhs_ti.get_notnull());
1038  null_check_suffix += "_rhs";
1039  } else if (rhs_ti.get_notnull()) {
1040  CHECK(!lhs_ti.get_notnull());
1041  null_check_suffix += "_lhs";
1042  }
1043  return null_check_suffix;
1044 }
1045 
1046 inline bool is_unnest(const Analyzer::Expr* expr) {
1047  return dynamic_cast<const Analyzer::UOper*>(expr) &&
1048  static_cast<const Analyzer::UOper*>(expr)->get_optype() == kUNNEST;
1049 }
1050 
1051 bool is_trivial_loop_join(const std::vector<InputTableInfo>& query_infos,
1052  const RelAlgExecutionUnit& ra_exe_unit);
1053 
1054 std::unordered_set<int> get_available_gpus(const Catalog_Namespace::Catalog& cat);
1055 
1056 size_t get_context_count(const ExecutorDeviceType device_type,
1057  const size_t cpu_count,
1058  const size_t gpu_count);
1059 
1060 extern "C" void register_buffer_with_executor_rsm(int64_t exec, int8_t* buffer);
1061 
1063 
1064 #endif // QUERYENGINE_EXECUTE_H
void read_rt_udf_gpu_module(const std::string &udf_ir)
SQLTypeInfo getColumnType(const size_t col_idx) const
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:206
const std::string debug_dir_
Definition: Execute.h:944
llvm::Value * translated_value
Definition: Execute.h:807
bool is_agg(const Analyzer::Expr *expr)
static mapd_shared_mutex executor_session_mutex_
Definition: Execute.h:964
QuerySessionStatus(const std::string &query_session, const std::string &query_str, const std::chrono::time_point< std::chrono::system_clock > submitted_time, const std::string &query_status)
Definition: Execute.h:88
AggregatedColRange computeColRangesCache(const std::unordered_set< PhysicalInput > &phys_inputs)
Definition: Execute.cpp:3469
void enableRuntimeQueryInterrupt(const double runtime_query_check_freq, const unsigned pending_query_check_freq) const
Definition: Execute.cpp:3608
SQLAgg
Definition: sqldefs.h:71
#define CHECK_EQ(x, y)
Definition: Logger.h:205
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:1939
static QuerySessionMap queries_session_map_
Definition: Execute.h:969
static mapd_shared_mutex execute_mutex_
Definition: Execute.h:976
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)
Definition: Execute.cpp:2400
std::unique_ptr< llvm::TargetMachine > nvptx_target_machine_
Definition: Execute.h:932
int64_t kernel_queue_time_ms_
Definition: Execute.h:951
size_t maxGpuSlabSize() const
Definition: Execute.cpp:3131
llvm::Value * castToFP(llvm::Value *val)
Definition: Execute.cpp:3143
int64_t compilation_queue_time_ms_
Definition: Execute.h:952
friend class ResultSet
Definition: Execute.h:1015
std::string cat(Ts &&...args)
static const int32_t ERR_INTERRUPTED
Definition: Execute.h:993
const Analyzer::Expr * remove_cast_to_int(const Analyzer::Expr *expr)
Definition: ColumnIR.cpp:538
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:97
bool addToQuerySessionList(const std::string &query_session, const std::string &query_str, SESSION_MAP_LOCK &write_lock)
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_
Definition: Execute.h:929
bool is_trivial_loop_join(const std::vector< InputTableInfo > &query_infos, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:1116
FetchCacheAnchor(CgenState *cgen_state)
Definition: Execute.h:907
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, const QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, const ExecutionOptions &eo)
Definition: IRCodegen.cpp:653
const std::chrono::time_point< std::chrono::system_clock > getQuerySubmittedTime()
Definition: Execute.h:100
const std::shared_ptr< RowSetMemoryOwner > getRowSetMemoryOwner() const
Definition: Execute.cpp:256
StringDictionaryProxy * getLiteralDictionary() const override
Definition: Execute.h:298
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:2095
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:1598
void read_rt_udf_cpu_module(const std::string &udf_ir)
Fragmenter_Namespace::RowDataProvider RowDataProvider
Definition: Execute.h:284
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:211
std::unordered_set< int > get_available_gpus(const Catalog_Namespace::Catalog &cat)
Definition: Execute.cpp:996
static const int max_gpu_count
Definition: Execute.h:921
void invalidateRunningQuerySession(SESSION_MAP_LOCK &write_lock)
size_t const getFragmentIndex() const
static const size_t code_cache_size
Definition: Execute.h:939
void setQueryStatusAsRunning()
Definition: Execute.h:104
bool isArchPascalOrLater(const ExecutorDeviceType dt) const
Definition: Execute.h:473
std::string & getCurrentQuerySession(SESSION_MAP_LOCK &read_lock)
std::ostream & operator<<(std::ostream &os, const SessionInfo &session_info)
Definition: SessionInfo.cpp:53
static std::atomic_flag execute_spin_lock_
Definition: Execute.h:972
bool is_fp() const
Definition: sqltypes.h:491
static mapd_shared_mutex executors_cache_mutex_
Definition: Execute.h:977
bool is_udf_module_present(bool cpu_only=false)
std::vector< ColumnLazyFetchInfo > getColLazyFetchInfo(const std::vector< Analyzer::Expr * > &target_exprs) const
Definition: Execute.cpp:306
static const size_t baseline_threshold
Definition: Execute.h:937
void registerActiveModule(void *module, const int device_id) const
const std::string getQuerySession()
Definition: Execute.h:98
std::tuple< RelAlgExecutionUnit, PlanState::DeletedColumnsMap > addDeletedColumn(const RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co)
Definition: Execute.cpp:3195
TableGenerations computeTableGenerations(std::unordered_set< int > phys_table_ids)
Definition: Execute.cpp:3516
const SQLTypeInfo get_column_type(const int col_id, const int table_id, const ColumnDescriptor *cd, const TemporaryTables *temporary_tables)
Definition: Execute.h:199
llvm::Value * aggregateWindowStatePtr()
void read_udf_cpu_module(const std::string &udf_ir_filename)
Driver for running cleanup processes on a table. TableOptimizer provides functions for various cleanu...
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:899
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:633
void read_udf_gpu_module(const std::string &udf_ir_filename)
Definition: sqldefs.h:49
std::vector< std::string > CodeCacheKey
Definition: CodeCache.h:25
const Analyzer::Expr * extract_cast_arg(const Analyzer::Expr *expr)
Definition: Execute.h:164
const ColumnarResults * rows_to_columnar_results(std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const PtrTy &result, const int number)
Definition: Execute.h:214
static const int32_t ERR_GEOS
Definition: Execute.h:999
const std::string query_str_
Definition: Execute.h:108
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:150
AggregatedColRange agg_col_range_cache_
Definition: Execute.h:961
void setQuerySessionAsInterrupted(const std::string &query_session, SESSION_MAP_LOCK &write_lock)
std::shared_ptr< ResultSet > ResultSetPtr
static void * gpu_active_modules_[max_gpu_count]
Definition: Execute.h:926
std::unique_ptr< CgenState > cgen_state_
Definition: Execute.h:903
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)
Definition: Execute.cpp:2301
static const int32_t ERR_TOO_MANY_LITERALS
Definition: Execute.h:995
llvm::Value * original_value
Definition: Execute.h:808
std::vector< Analyzer::Expr * > get_exprs_not_owned(const std::vector< std::shared_ptr< Analyzer::Expr >> &exprs)
Definition: Execute.h:226
static uint32_t gpu_active_modules_device_mask_
Definition: Execute.h:925
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
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:2595
int deviceCount(const ExecutorDeviceType) const
Definition: Execute.cpp:616
llvm::Value * castToIntPtrTyIn(llvm::Value *val, const size_t bit_width)
Definition: Execute.cpp:3164
size_t getNumBytesForFetchedRow(const std::set< int > &table_ids_to_fetch) const
Definition: Execute.cpp:276
static std::mutex kernel_mutex_
Definition: Execute.h:1002
unsigned numBlocksPerMP() const
Definition: Execute.cpp:3115
#define CHECK_GT(x, y)
Definition: Logger.h:209
Container for compilation results and assorted options for a single execution unit.
bool isCPUOnly() const
Definition: Execute.cpp:226
std::unique_ptr< WindowProjectNodeContext > window_project_node_context_owned_
Definition: Execute.h:956
std::vector< FragmentsPerTable > FragmentsList
bool is_time() const
Definition: sqltypes.h:493
bool needFetchAllFragments(const InputColDescriptor &col_desc, const RelAlgExecutionUnit &ra_exe_unit, const FragmentsList &selected_fragments) const
Definition: Execute.cpp:2276
std::string to_string(char const *&&v)
std::function< void(const UpdateLogForFragment &)> Callback
Definition: Execute.h:313
mapd_shared_mutex & getSessionLock()
Definition: Execute.cpp:3537
#define LOG_IF(severity, condition)
Definition: Logger.h:287
static void clearMemory(const Data_Namespace::MemoryLevel memory_level)
Definition: Execute.cpp:172
Fragmenter_Namespace::TableInfo getTableInfo(const int table_id) const
Definition: Execute.cpp:264
std::shared_ptr< CompilationContext > getCodeFromCache(const CodeCacheKey &, const CodeCache &)
static const size_t high_scan_limit
Definition: Execute.h:409
CodeCache gpu_code_cache_
Definition: Execute.h:935
static const int32_t ERR_STRING_CONST_IN_RESULTSET
Definition: Execute.h:996
void codegenWindowAvgEpilogue(llvm::Value *crt_val, llvm::Value *window_func_null_val, llvm::Value *multiplicity_lv)
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, RenderInfo *render_info)
Definition: Execute.cpp:2848
std::vector< int64_t > getJoinHashTablePtrs(const ExecutorDeviceType device_type, const int device_id)
Definition: Execute.cpp:3014
void preloadFragOffsets(const std::vector< InputDescriptor > &input_descs, const std::vector< InputTableInfo > &query_infos)
Definition: Execute.cpp:3048
void insertErrorCodeChecker(llvm::Function *query_func, bool hoist_literals)
std::unordered_map< int, const ResultSetPtr & > TemporaryTables
Definition: InputMetadata.h:31
static const int32_t ERR_STREAMING_TOP_N_NOT_SUPPORTED_IN_RENDER_QUERY
Definition: Execute.h:997
const ExecutorId executor_id_
Definition: Execute.h:947
static const int32_t ERR_COLUMNAR_CONVERSION_NOT_SUPPORTED
Definition: Execute.h:994
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:191
int8_t warpSize() const
Definition: Execute.cpp:3099
const size_t max_gpu_slab_size_
Definition: Execute.h:943
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:969
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:1750
const ColumnDescriptor * getPhysicalColumnDescriptor(const Analyzer::ColumnVar *, int) const
Definition: Execute.cpp:237
bool compileBody(const RelAlgExecutionUnit &ra_exe_unit, GroupByAndAggregate &group_by_and_aggregate, const QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, const GpuSharedMemoryContext &gpu_smem_context={})
static const int32_t ERR_DIV_BY_ZERO
Definition: Execute.h:985
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)
llvm::Value * get_arg_by_name(llvm::Function *func, const std::string &name)
Definition: Execute.h:129
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 CompilationOptions &)
std::map< std::string, bool > InterruptFlagMap
Definition: Execute.h:77
std::vector< llvm::Value * > LLVMValueVector
Definition: Execute.h:323
size_t get_context_count(const ExecutorDeviceType device_type, const size_t cpu_count, const size_t gpu_count)
Definition: Execute.cpp:1008
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:183
std::vector< TargetValue > getEntryAt(const size_t index) const override
int get_logical_size() const
Definition: sqltypes.h:341
std::unordered_map< int, std::vector< llvm::Value * > > fetch_cache_
Definition: CgenState.h:330
decltype(FragmentInfoType::fragmentId) const getFragmentId() const
Definition: Execute.h:307
int64_t deviceCycles(int milliseconds) const
Definition: Execute.cpp:3135
std::string generatePTX(const std::string &) const
std::mutex str_dict_mutex_
Definition: Execute.h:930
bool is_integer() const
Definition: sqltypes.h:489
const Catalog_Namespace::Catalog * catalog_
Definition: Execute.h:948
#define INJECT_TIMER(DESC)
Definition: measure.h:93
friend class PendingExecutionClosure
Definition: Execute.h:1020
static const int32_t ERR_OUT_OF_RENDER_MEM
Definition: Execute.h:989
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:869
std::shared_timed_mutex mapd_shared_mutex
const std::string debug_file_
Definition: Execute.h:945
std::map< const std::string, QuerySessionStatus > QuerySessionMap
Definition: Execute.h:112
ResultSetPtr collectAllDeviceShardedTopResults(SharedKernelContext &shared_context, const RelAlgExecutionUnit &ra_exe_unit) const
Definition: Execute.cpp:1865
CachedCardinality getCachedCardinality(const std::string &cache_key)
Definition: Execute.cpp:3632
decltype(FragmentInfoType::physicalTableId) const getPhysicalTableId() const
Definition: Execute.h:304
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
Definition: Execute.h:919
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:78
void setColRangeCache(const AggregatedColRange &aggregated_col_range)
Definition: Execute.h:850
bool containsLeftDeepOuterJoin() const
Definition: Execute.h:372
void setCatalog(const Catalog_Namespace::Catalog *catalog)
Definition: Execute.cpp:252
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:991
bool is_timeinterval() const
Definition: sqltypes.h:498
static std::unordered_map< std::string, size_t > cardinality_cache_
Definition: Execute.h:982
static InterruptFlagMap queries_interrupt_flag_
Definition: Execute.h:967
std::optional< QuerySessionStatus > getQuerySessionInfo(const std::string &query_session, mapd_shared_lock< mapd_shared_mutex > &read_lock)
Definition: Execute.cpp:3642
FragmentInfoType const & getFragmentInfo() const
std::unique_ptr< PlanState > plan_state_
Definition: Execute.h:918
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
static const int32_t ERR_OUT_OF_TIME
Definition: Execute.h:992
void initializeNVPTXBackend() const
const TableGeneration & getTableGeneration(const int table_id) const
Definition: Execute.cpp:268
size_t fragment_index_
Definition: Execute.h:319
std::string query_status_
Definition: Execute.h:110
std::pair< bool, size_t > CachedCardinality
Definition: Execute.h:883
void interrupt(const std::string &query_session="", const std::string &interrupt_session="")
const ColumnDescriptor * getColumnDescriptor(const Analyzer::ColumnVar *) const
Definition: Execute.cpp:231
static const int32_t ERR_UNSUPPORTED_SELF_JOIN
Definition: Execute.h:988
const unsigned block_size_x_
Definition: Execute.h:941
const unsigned grid_size_x_
Definition: Execute.h:942
specifies the content in-memory of a row in the column metadata table
bool is_boolean() const
Definition: sqltypes.h:494
std::vector< TargetValue > getTranslatedEntryAt(const size_t index) const override
static const int32_t ERR_SINGLE_VALUE_FOUND_MULTIPLE_VALUES
Definition: Execute.h:998
static std::map< int, std::shared_ptr< Executor > > executors_
Definition: Execute.h:971
static const int32_t ERR_OUT_OF_GPU_MEM
Definition: Execute.h:986
std::string get_null_check_suffix(const SQLTypeInfo &lhs_ti, const SQLTypeInfo &rhs_ti)
Definition: Execute.h:1030
static void addCodeToCache(const CodeCacheKey &, std::shared_ptr< CompilationContext >, llvm::Module *, CodeCache &)
const Catalog_Namespace::Catalog * getCatalog() const
Definition: Execute.cpp:248
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults >>> ColumnCacheMap
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, RenderInfo *render_info)
Definition: Execute.cpp:2648
std::shared_ptr< JoinHashTableInterface > hash_table
Definition: Execute.h:774
const std::string query_session_
Definition: Execute.h:107
#define CHECK_LT(x, y)
Definition: Logger.h:207
ResultSetPtr resultsUnion(SharedKernelContext &shared_context, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:843
static std::string current_query_session_
Definition: Execute.h:965
std::shared_ptr< ResultSet > rs_
Definition: Execute.h:320
std::vector< size_t > getFragmentCount(const FragmentsList &selected_fragments, const size_t scan_idx, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:2550
llvm::BasicBlock * codegenSkipDeletedOuterTableRow(const RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co)
std::unique_ptr< QueryCompilationDescriptor > QueryCompilationDescriptorOwned
Definition: Execute.h:74
size_t ExecutorId
Definition: Execute.h:336
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:338
const ColumnarResults * columnarize_result(std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const ResultSetPtr &result, const int frag_id)
Definition: Execute.h:235
std::vector< int8_t > serializeLiterals(const std::unordered_map< int, CgenState::LiteralValues > &literals, const int device_id)
Definition: Execute.cpp:354
StringDictionaryGenerations string_dictionary_generations_
Definition: Execute.h:962
InputTableInfoCache input_table_info_cache_
Definition: Execute.h:960
void codegenWindowFunctionStateInit(llvm::Value *aggregate_state)
void launchKernels(SharedKernelContext &shared_context, std::vector< std::unique_ptr< ExecutionKernel >> &&kernels)
CodeCache cpu_code_cache_
Definition: Execute.h:934
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:3278
unsigned gridSize() const
Definition: Execute.cpp:3108
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:2227
StringDictionaryGenerations computeStringDictionaryGenerations(const std::unordered_set< PhysicalInput > &phys_inputs)
Definition: Execute.cpp:3495
bool removeFromQuerySessionList(const std::string &query_session, SESSION_MAP_LOCK &write_lock)
FragmentInfoType const & fragment_info_
Definition: Execute.h:318
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:3029
bool checkIsQuerySessionInterrupted(const std::string &query_session, SESSION_MAP_LOCK &read_lock)
const std::string getQueryStr()
Definition: Execute.h:99
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:3436
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:2564
llvm::Value * codegenAggregateWindowState()
TableGenerations table_generations_
Definition: Execute.h:963
void unregisterActiveModule(void *module, const int device_id) const
std::function< void(ResultSetPtr, const Fragmenter_Namespace::FragmentInfo &)> PerFragmentCallBack
Definition: Execute.h:488
void resetInterrupt()
mapd_shared_lock< mapd_shared_mutex > read_lock
llvm::Value * addJoinLoopIterator(const std::vector< llvm::Value * > &prev_iters, const size_t level_idx)
Definition: IRCodegen.cpp:635
ResultSetPtr reduceMultiDeviceResultSets(std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &all_fragment_results, std::shared_ptr< RowSetMemoryOwner >, const QueryMemoryDescriptor &) const
Definition: Execute.cpp:911
llvm::Value * codegenWindowFunctionAggregate(const CompilationOptions &co)
void addToCardinalityCache(const std::string &cache_key, const size_t cache_value)
Definition: Execute.cpp:3623
static std::atomic< bool > interrupted_
Definition: Execute.h:927
#define CHECK(condition)
Definition: Logger.h:197
static const int32_t ERR_OUT_OF_SLOTS
Definition: Execute.h:987
static std::mutex compilation_mutex_
Definition: Execute.h:1001
std::vector< llvm::Value * > inlineHoistedLiterals()
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:1372
std::unordered_map< int, const Analyzer::BinOper * > getInnerTabIdToJoinCond() const
Definition: Execute.cpp:1913
ExecutorDeviceType getDeviceTypeForTargets(const RelAlgExecutionUnit &ra_exe_unit, const ExecutorDeviceType requested_device_type)
Definition: Execute.cpp:1623
Executor(const ExecutorId id, 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:131
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, GroupByAndAggregate::DiamondCodegen &, std::stack< llvm::BasicBlock * > &, const bool thread_mem_shared)
Definition: IRCodegen.cpp:703
uint32_t log2_bytes(const uint32_t bytes)
Definition: Execute.h:139
bool checkCurrentQuerySession(const std::string &candidate_query_session, SESSION_MAP_LOCK &read_lock)
ExpressionRange getColRange(const PhysicalInput &) const
Definition: Execute.cpp:272
std::string numeric_type_name(const SQLTypeInfo &ti)
Definition: Execute.h:172
mapd_unique_lock< mapd_shared_mutex > write_lock
void redeclareFilterFunction()
Definition: IRCodegen.cpp:537
SQLTypeInfo columnType
UpdateLogForFragment(FragmentInfoType const &fragment_info, size_t const, const std::shared_ptr< ResultSet > &rs)
bool is_unnest(const Analyzer::Expr *expr)
Definition: Execute.h:1046
bool is_string() const
Definition: sqltypes.h:487
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:260
void executeWorkUnitPerFragment(const RelAlgExecutionUnit &ra_exe_unit, const InputTableInfo &table_info, const CompilationOptions &co, const ExecutionOptions &eo, const Catalog_Namespace::Catalog &cat, PerFragmentCallBack &cb)
Compiles and dispatches a work unit per fragment processing results with the per fragment callback...
Definition: Execute.cpp:1527
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:431
auto getResultSet() const
Definition: Execute.h:315
unsigned blockSize() const
Definition: Execute.cpp:3123
string name
Definition: setup.py:35
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:337
QuerySessionStatus(const std::string &query_session, const std::string &query_str, const std::chrono::time_point< std::chrono::system_clock > submitted_time)
Definition: Execute.h:80
std::unordered_map< int, std::vector< llvm::Value * > > saved_fetch_cache
Definition: Execute.h:913
CgenState * cgen_state_
Definition: Execute.h:912
static size_t align(const size_t off_in, const size_t alignment)
Definition: Execute.h:895
std::unique_ptr< QueryMemoryDescriptor > QueryMemoryDescriptorOwned
Definition: Execute.h:76
size_t const getRowCount() const override
const std::chrono::time_point< std::chrono::system_clock > submitted_time_
Definition: Execute.h:109
static const int32_t ERR_OUT_OF_CPU_MEM
Definition: Execute.h:990
bool is_decimal() const
Definition: sqltypes.h:490
int deviceCountForMemoryLevel(const Data_Namespace::MemoryLevel memory_level) const
Definition: Execute.cpp:626
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:288
bool is_rt_udf_module_present(bool cpu_only=false)
static size_t getArenaBlockSize()
Definition: Execute.cpp:197
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:1311
std::mutex gpu_exec_mutex_[max_gpu_count]
Definition: Execute.h:922
JoinHashTableOrError buildHashTableForQualifier(const std::shared_ptr< Analyzer::BinOper > &qual_bin_oper, const std::vector< InputTableInfo > &query_infos, const MemoryLevel memory_level, const JoinHashTableInterface::HashType preferred_hash_type, ColumnCacheMap &column_cache)
Definition: Execute.cpp:3069
static mapd_shared_mutex recycler_mutex_
Definition: Execute.h:981
void register_buffer_with_executor_rsm(int64_t exec, int8_t *buffer)
StringDictionaryProxy * getStringDictionaryProxy(const int dictId, const std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const bool with_generation) const
Definition: Execute.cpp:201
llvm::Value * codegenWindowFunction(const size_t target_index, const CompilationOptions &co)
SQLOps get_optype() const
Definition: Analyzer.h:370
std::shared_ptr< JoinHashTableInterface > buildCurrentLevelHashTable(const JoinCondition &current_level_join_conditions, 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:490
WindowFunctionContext * active_window_function_
Definition: Execute.h:958
const TemporaryTables * getTemporaryTables() const
Definition: Execute.cpp:260
static std::mutex gpu_active_modules_mutex_
Definition: Execute.h:924
void setupCaching(const std::unordered_set< PhysicalInput > &phys_inputs, const std::unordered_set< int > &phys_table_ids)
Definition: Execute.cpp:3528
static void nukeCacheOfExecutors()
Definition: Execute.h:352
void clearMetaInfoCache()
Definition: Execute.cpp:347
const ColumnDescriptor * get_column_descriptor(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:154
void createErrorCheckControlFlow(llvm::Function *query_func, bool run_with_dynamic_watchdog, bool run_with_allowing_runtime_interrupt, ExecutorDeviceType device_type, const std::vector< InputTableInfo > &input_table_infos)
size_t const getEntryCount() const override
llvm::BasicBlock * codegenWindowResetStateControlFlow()
const TemporaryTables * temporary_tables_
Definition: Execute.h:949
void executeUpdate(const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &table_infos, 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)
CompilationRetryNewScanLimit(const size_t new_scan_limit)
Definition: Execute.h:252
WatchdogException(const std::string &cause)
Definition: Execute.h:124
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:337
void setCurrentQuerySession(const std::string &query_session, SESSION_MAP_LOCK &write_lock)
bool isArchMaxwell(const ExecutorDeviceType dt) const
const std::string getQueryStatus()
Definition: Execute.h:103
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:2137
ResultSetPtr executeExplain(const QueryCompilationDescriptor &)
Definition: Execute.cpp:1619