OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Execute.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, 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 "GroupByAndAggregate.h"
28 #include "JoinHashTable.h"
30 #include "NvidiaKernel.h"
31 #include "PlanState.h"
32 #include "RelAlgExecutionUnit.h"
33 #include "RelAlgTranslator.h"
35 #include "TableGenerations.h"
36 #include "TargetMetaInfo.h"
37 #include "WindowContext.h"
38 
39 #include "../Chunk/Chunk.h"
40 #include "../Fragmenter/InsertOrderFragmenter.h"
41 #include "../Planner/Planner.h"
42 #include "../Shared/Logger.h"
43 #include "../Shared/MapDParameters.h"
44 #include "../Shared/measure.h"
45 #include "../Shared/thread_count.h"
46 #include "../StringDictionary/LruCache.hpp"
47 #include "../StringDictionary/StringDictionary.h"
48 #include "../StringDictionary/StringDictionaryProxy.h"
49 
50 #include <llvm/IR/Function.h>
51 #include <llvm/IR/Value.h>
52 #include <llvm/Linker/Linker.h>
53 #include <llvm/Transforms/Utils/ValueMapper.h>
54 #include <rapidjson/document.h>
55 
56 #include <unistd.h>
57 #include <algorithm>
58 #include <condition_variable>
59 #include <cstddef>
60 #include <cstdlib>
61 #include <deque>
62 #include <functional>
63 #include <limits>
64 #include <map>
65 #include <mutex>
66 #include <stack>
67 #include <unordered_map>
68 #include <unordered_set>
69 
70 extern bool g_enable_watchdog;
71 extern bool g_enable_dynamic_watchdog;
72 extern unsigned g_dynamic_watchdog_time_limit;
73 extern unsigned g_trivial_loop_join_threshold;
74 extern bool g_from_table_reordering;
75 extern bool g_enable_filter_push_down;
76 extern bool g_allow_cpu_retry;
77 extern bool g_null_div_by_zero;
78 extern bool g_bigint_count;
80 extern float g_filter_push_down_low_frac;
81 extern float g_filter_push_down_high_frac;
83 extern bool g_enable_columnar_output;
84 extern bool g_enable_overlaps_hashjoin;
86 extern bool g_strip_join_covered_quals;
87 extern size_t g_constrained_by_in_threshold;
88 extern size_t g_big_group_threshold;
89 extern bool g_enable_window_functions;
90 extern bool g_enable_table_functions;
91 extern size_t g_max_memory_allocation_size;
94 
96 using QueryCompilationDescriptorOwned = std::unique_ptr<QueryCompilationDescriptor>;
98 using QueryMemoryDescriptorOwned = std::unique_ptr<QueryMemoryDescriptor>;
99 
100 extern void read_udf_gpu_module(const std::string& udf_ir_filename);
101 extern void read_udf_cpu_module(const std::string& udf_ir_filename);
102 extern bool is_udf_module_present(bool cpu_only = false);
103 extern void read_rt_udf_gpu_module(const std::string& udf_ir);
104 extern void read_rt_udf_cpu_module(const std::string& udf_ir);
105 extern bool is_rt_udf_module_present(bool cpu_only = false);
106 
107 class ColumnFetcher;
108 class ExecutionResult;
109 
110 class WatchdogException : public std::runtime_error {
111  public:
112  WatchdogException(const std::string& cause) : std::runtime_error(cause) {}
113 };
114 
115 class Executor;
116 
117 inline llvm::Value* get_arg_by_name(llvm::Function* func, const std::string& name) {
118  for (auto& arg : func->args()) {
119  if (arg.getName() == name) {
120  return &arg;
121  }
122  }
123  CHECK(false);
124  return nullptr;
125 }
126 
127 inline uint32_t log2_bytes(const uint32_t bytes) {
128  switch (bytes) {
129  case 1:
130  return 0;
131  case 2:
132  return 1;
133  case 4:
134  return 2;
135  case 8:
136  return 3;
137  default:
138  abort();
139  }
140 }
141 
143  const int col_id,
144  const int table_id,
145  const Catalog_Namespace::Catalog& cat) {
146  CHECK_GT(table_id, 0);
147  const auto col_desc = cat.getMetadataForColumn(table_id, col_id);
148  CHECK(col_desc);
149  return col_desc;
150 }
151 
152 inline const Analyzer::Expr* extract_cast_arg(const Analyzer::Expr* expr) {
153  const auto cast_expr = dynamic_cast<const Analyzer::UOper*>(expr);
154  if (!cast_expr || cast_expr->get_optype() != kCAST) {
155  return expr;
156  }
157  return cast_expr->get_operand();
158 }
159 
160 inline std::string numeric_type_name(const SQLTypeInfo& ti) {
161  CHECK(ti.is_integer() || ti.is_decimal() || ti.is_boolean() || ti.is_time() ||
162  ti.is_fp() || (ti.is_string() && ti.get_compression() == kENCODING_DICT) ||
163  ti.is_timeinterval());
164  if (ti.is_integer() || ti.is_decimal() || ti.is_boolean() || ti.is_time() ||
165  ti.is_string() || ti.is_timeinterval()) {
166  return "int" + std::to_string(ti.get_logical_size() * 8) + "_t";
167  }
168  return ti.get_type() == kDOUBLE ? "double" : "float";
169 }
170 
172  const int col_id,
173  const int table_id,
174  const Catalog_Namespace::Catalog& cat) {
175  CHECK(table_id);
176  return table_id > 0 ? get_column_descriptor(col_id, table_id, cat) : nullptr;
177 }
178 
179 inline const ResultSetPtr& get_temporary_table(const TemporaryTables* temporary_tables,
180  const int table_id) {
181  CHECK_LT(table_id, 0);
182  const auto it = temporary_tables->find(table_id);
183  CHECK(it != temporary_tables->end());
184  return it->second;
185 }
186 
187 inline const SQLTypeInfo get_column_type(const int col_id,
188  const int table_id,
189  const ColumnDescriptor* cd,
190  const TemporaryTables* temporary_tables) {
191  CHECK(cd || temporary_tables);
192  if (cd) {
193  CHECK_EQ(col_id, cd->columnId);
194  CHECK_EQ(table_id, cd->tableId);
195  return cd->columnType;
196  }
197  const auto& temp = get_temporary_table(temporary_tables, table_id);
198  return temp->getColType(col_id);
199 }
200 
201 template <typename PtrTy>
203  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
204  const PtrTy& result,
205  const int number) {
206  std::vector<SQLTypeInfo> col_types;
207  for (size_t i = 0; i < result->colCount(); ++i) {
208  col_types.push_back(get_logical_type_info(result->getColType(i)));
209  }
210  return new ColumnarResults(row_set_mem_owner, *result, number, col_types);
211 }
212 
213 // TODO(alex): Adjust interfaces downstream and make this not needed.
214 inline std::vector<Analyzer::Expr*> get_exprs_not_owned(
215  const std::vector<std::shared_ptr<Analyzer::Expr>>& exprs) {
216  std::vector<Analyzer::Expr*> exprs_not_owned;
217  for (const auto expr : exprs) {
218  exprs_not_owned.push_back(expr.get());
219  }
220  return exprs_not_owned;
221 }
222 
224  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
225  const ResultSetPtr& result,
226  const int frag_id) {
228  CHECK_EQ(0, frag_id);
229  return rows_to_columnar_results(row_set_mem_owner, result, result->colCount());
230 }
231 
232 class CompilationRetryNoLazyFetch : public std::runtime_error {
233  public:
235  : std::runtime_error("Retry query compilation with no GPU lazy fetch.") {}
236 };
237 
238 class CompilationRetryNewScanLimit : public std::runtime_error {
239  public:
240  CompilationRetryNewScanLimit(const size_t new_scan_limit)
241  : std::runtime_error("Retry query compilation with new scan limit.")
242  , new_scan_limit_(new_scan_limit) {}
243 
245 };
246 
247 class TooManyLiterals : public std::runtime_error {
248  public:
249  TooManyLiterals() : std::runtime_error("Too many literals in the query") {}
250 };
251 
252 class CompilationRetryNoCompaction : public std::runtime_error {
253  public:
255  : std::runtime_error("Retry query compilation with no compaction.") {}
256 };
257 
258 class QueryMustRunOnCpu : public std::runtime_error {
259  public:
260  QueryMustRunOnCpu() : std::runtime_error("Query must run in cpu mode.") {}
261 };
262 
263 class SringConstInResultSet : public std::runtime_error {
264  public:
266  : std::runtime_error(
267  "NONE ENCODED String types are not supported as input result set.") {}
268 };
269 
270 class ExtensionFunction;
271 
272 namespace std {
273 template <>
274 struct hash<std::vector<int>> {
275  size_t operator()(const std::vector<int>& vec) const {
276  return vec.size() ^ boost::hash_range(vec.begin(), vec.end());
277  }
278 };
279 
280 template <>
281 struct hash<std::pair<int, int>> {
282  size_t operator()(const std::pair<int, int>& p) const {
283  return boost::hash<std::pair<int, int>>()(p);
284  }
285 };
286 
287 } // namespace std
288 
290 
292  public:
294 
295  UpdateLogForFragment(FragmentInfoType const& fragment_info,
296  size_t const,
297  const std::shared_ptr<ResultSet>& rs);
298 
299  std::vector<TargetValue> getEntryAt(const size_t index) const override;
300  std::vector<TargetValue> getTranslatedEntryAt(const size_t index) const override;
301 
302  size_t const getRowCount() const override;
304  return rs_->getRowSetMemOwner()->getLiteralStringDictProxy();
305  }
306  size_t const getEntryCount() const override;
307  size_t const getFragmentIndex() const;
308  FragmentInfoType const& getFragmentInfo() const;
311  }
312  decltype(FragmentInfoType::fragmentId) const getFragmentId() const {
313  return fragment_info_.fragmentId;
314  }
315 
316  SQLTypeInfo getColumnType(const size_t col_idx) const;
317 
318  using Callback = std::function<void(const UpdateLogForFragment&)>;
319 
320  private:
323  std::shared_ptr<ResultSet> rs_;
324 };
325 
326 using LLVMValueVector = std::vector<llvm::Value*>;
327 
329 
330 class Executor {
331  static_assert(sizeof(float) == 4 && sizeof(double) == 8,
332  "Host hardware not supported, unexpected size of float / double.");
333  static_assert(sizeof(time_t) == 8,
334  "Host hardware not supported, 64-bit time support is required.");
335 
336  public:
337  Executor(const int db_id,
338  const size_t block_size_x,
339  const size_t grid_size_x,
340  const std::string& debug_dir,
341  const std::string& debug_file,
342  ::QueryRenderer::QueryRenderManager* render_manager);
343 
344  static std::shared_ptr<Executor> getExecutor(
345  const int db_id,
346  const std::string& debug_dir = "",
347  const std::string& debug_file = "",
348  const MapDParameters mapd_parameters = MapDParameters(),
349  ::QueryRenderer::QueryRenderManager* render_manager = nullptr);
350 
351  static void nukeCacheOfExecutors() {
352  std::lock_guard<std::mutex> flush_lock(
353  execute_mutex_); // don't want native code to vanish while executing
354  mapd_unique_lock<mapd_shared_mutex> lock(executors_cache_mutex_);
355  (decltype(executors_){}).swap(executors_);
356  }
357 
358  static void clearMemory(const Data_Namespace::MemoryLevel memory_level);
359 
360  typedef std::tuple<std::string, const Analyzer::Expr*, int64_t, const size_t> AggInfo;
361 
362  std::shared_ptr<ResultSet> execute(const Planner::RootPlan* root_plan,
363  const Catalog_Namespace::SessionInfo& session,
364  const bool hoist_literals,
365  const ExecutorDeviceType device_type,
366  const ExecutorOptLevel,
367  const bool allow_multifrag,
368  const bool allow_loop_joins,
369  RenderInfo* render_query_data = nullptr);
370 
371  std::shared_ptr<ResultSet> renderPointsNonInSitu(
372  const std::string& queryStr,
373  const ExecutionResult& results,
374  const Catalog_Namespace::SessionInfo& session,
375  const int render_widget_id,
376  const ::QueryRenderer::JSONLocation* data_loc,
377  RenderInfo* render_query_data);
378 
379  std::shared_ptr<ResultSet> renderPointsInSitu(RenderInfo* render_query_data);
380 
381  std::shared_ptr<ResultSet> renderPolygonsNonInSitu(
382  const std::string& queryStr,
383  const ExecutionResult& results,
384  const Catalog_Namespace::SessionInfo& session,
385  const int render_widget_id,
386  const ::QueryRenderer::JSONLocation* data_loc,
387  RenderInfo* render_query_data,
388  const std::string& poly_table_name);
389 
390  std::shared_ptr<ResultSet> renderLinesNonInSitu(
391  const std::string& queryStr,
392  const ExecutionResult& results,
393  const Catalog_Namespace::SessionInfo& session,
394  const int render_widget_id,
395  const ::QueryRenderer::JSONLocation* data_loc,
396  RenderInfo* render_query_data);
397 
398 #if HAVE_CUDA
399  enum class InSituGeoRenderType { kPOLYGONS, kLINES };
400 
401  std::shared_ptr<ResultSet> renderGeoInSitu(
402  const InSituGeoRenderType in_situ_geo_render_type,
403  const std::string& queryStr,
404  const ExecutionResult& results,
405  const Catalog_Namespace::SessionInfo& session,
406  const int render_widget_id,
407  const ::QueryRenderer::JSONLocation* data_loc,
408  RenderInfo* render_query_data,
409  const std::string& line_table_name);
410 #endif
411 
412  std::vector<int32_t> getStringIds(
413  const std::string& col_name,
414  const std::vector<std::string>& col_vals,
415  const ::QueryRenderer::QueryDataLayout* query_data_layout,
416  const ResultSet* results,
417  const std::shared_ptr<RowSetMemoryOwner>& row_set_mem_owner,
418  const bool warn = false) const;
419 
420  std::vector<std::string> getStringsFromIds(
421  const std::string& col_name,
422  const std::vector<int32_t>& ids,
423  const ::QueryRenderer::QueryDataLayout* query_data_layout,
424  const ResultSet* results,
425  const std::shared_ptr<RowSetMemoryOwner>& row_set_mem_owner) const;
426 
428  const int dictId,
429  const std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
430  const bool with_generation) const;
431 
432  bool isCPUOnly() const;
433 
434  bool isArchMaxwell(const ExecutorDeviceType dt) const;
435 
437  return cgen_state_->contains_left_deep_outer_join_;
438  }
439 
441 
443  int) const;
444 
445  const Catalog_Namespace::Catalog* getCatalog() const;
446  void setCatalog(const Catalog_Namespace::Catalog* catalog);
447 
448  const std::shared_ptr<RowSetMemoryOwner> getRowSetMemoryOwner() const;
449 
450  const TemporaryTables* getTemporaryTables() const;
451 
452  Fragmenter_Namespace::TableInfo getTableInfo(const int table_id) const;
453 
454  const TableGeneration& getTableGeneration(const int table_id) const;
455 
457 
458  size_t getNumBytesForFetchedRow() const;
459 
460  std::vector<ColumnLazyFetchInfo> getColLazyFetchInfo(
461  const std::vector<Analyzer::Expr*>& target_exprs) const;
462 
463  void registerActiveModule(void* module, const int device_id) const;
464  void unregisterActiveModule(void* module, const int device_id) const;
465  void interrupt();
466  void resetInterrupt();
467 
468  static const size_t high_scan_limit{32000000};
469 
470  int8_t warpSize() const;
471  unsigned gridSize() const;
472  unsigned blockSize() const;
473 
474  private:
475  void clearMetaInfoCache();
476 
477  int deviceCount(const ExecutorDeviceType) const;
478  int deviceCountForMemoryLevel(const Data_Namespace::MemoryLevel memory_level) const;
479 
480  // Generate code for a window function target.
481  llvm::Value* codegenWindowFunction(const size_t target_index,
482  const CompilationOptions& co);
483 
484  // Generate code for an aggregate window function target.
485  llvm::Value* codegenWindowFunctionAggregate(const CompilationOptions& co);
486 
487  // The aggregate state requires a state reset when starting a new partition. Generate
488  // the new partition check and return the continuation basic block.
489  llvm::BasicBlock* codegenWindowResetStateControlFlow();
490 
491  // Generate code for initializing the state of a window aggregate.
492  void codegenWindowFunctionStateInit(llvm::Value* aggregate_state);
493 
494  // Generates the required calls for an aggregate window function and returns the final
495  // result.
496  llvm::Value* codegenWindowFunctionAggregateCalls(llvm::Value* aggregate_state,
497  const CompilationOptions& co);
498 
499  // The AVG window function requires some post-processing: the sum is divided by count
500  // and the result is stored back for the current row.
501  void codegenWindowAvgEpilogue(llvm::Value* crt_val,
502  llvm::Value* window_func_null_val,
503  llvm::Value* multiplicity_lv);
504 
505  // Generates code which loads the current aggregate value for the window context.
506  llvm::Value* codegenAggregateWindowState();
507 
508  llvm::Value* aggregateWindowStatePtr();
509 
511  std::vector<std::pair<void*, void*>> native_functions;
512  std::unordered_map<int, CgenState::LiteralValues> literal_values;
514  std::string llvm_ir;
515  };
516 
518  if (dt == ExecutorDeviceType::GPU) {
519  const auto cuda_mgr = catalog_->getDataMgr().getCudaMgr();
520  LOG_IF(FATAL, cuda_mgr == nullptr)
521  << "No CudaMgr instantiated, unable to check device architecture";
522  return cuda_mgr->isArchPascalOrLater();
523  }
524  return false;
525  }
526 
527  struct FetchResult {
528  std::vector<std::vector<const int8_t*>> col_buffers;
529  std::vector<std::vector<int64_t>> num_rows;
530  std::vector<std::vector<uint64_t>> frag_offsets;
531  };
532 
533  bool needFetchAllFragments(const InputColDescriptor& col_desc,
534  const RelAlgExecutionUnit& ra_exe_unit,
535  const FragmentsList& selected_fragments) const;
536 
538  private:
541  const std::vector<InputTableInfo>& query_infos_;
543  mutable std::vector<uint64_t> all_frag_row_offsets_;
544  mutable std::mutex all_frag_row_offsets_mutex_;
545  const std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner_;
547  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>> all_fragment_results_;
548  std::atomic_flag dynamic_watchdog_set_ = ATOMIC_FLAG_INIT;
549  static std::mutex reduce_mutex_;
550 
551  void runImpl(const ExecutorDeviceType chosen_device_type,
552  int chosen_device_id,
553  const ExecutionOptions& eo,
554  const ColumnFetcher& column_fetcher,
555  const QueryCompilationDescriptor& query_comp_desc,
557  const FragmentsList& frag_list,
558  const ExecutorDispatchMode kernel_dispatch_mode,
559  const int64_t rowid_lookup_key);
560 
561  public:
562  ExecutionDispatch(Executor* executor,
563  const RelAlgExecutionUnit& ra_exe_unit,
564  const std::vector<InputTableInfo>& query_infos,
565  const Catalog_Namespace::Catalog& cat,
566  const std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
567  RenderInfo* render_info);
568 
569  ExecutionDispatch(const ExecutionDispatch&) = delete;
570 
572 
574 
576 
577  std::tuple<QueryCompilationDescriptorOwned, QueryMemoryDescriptorOwned> compile(
578  const size_t max_groups_buffer_entry_guess,
579  const int8_t crt_min_byte_width,
580  const CompilationOptions& co,
581  const ExecutionOptions& eo,
582  const ColumnFetcher& column_fetcher,
583  const bool has_cardinality_estimation);
584 
585  void run(const ExecutorDeviceType chosen_device_type,
586  int chosen_device_id,
587  const ExecutionOptions& eo,
588  const ColumnFetcher& column_fetcher,
589  const QueryCompilationDescriptor& query_comp_desc,
591  const FragmentsList& frag_ids,
592  const ExecutorDispatchMode kernel_dispatch_mode,
593  const int64_t rowid_lookup_key);
594 
595  const RelAlgExecutionUnit& getExecutionUnit() const;
596 
597  const std::vector<uint64_t>& getFragOffsets() const;
598 
599  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>>& getFragmentResults();
600 
602  };
603 
604  ResultSetPtr executeWorkUnit(size_t& max_groups_buffer_entry_guess,
605  const bool is_agg,
606  const std::vector<InputTableInfo>&,
607  const RelAlgExecutionUnit&,
608  const CompilationOptions&,
609  const ExecutionOptions& options,
611  std::shared_ptr<RowSetMemoryOwner>,
612  RenderInfo* render_info,
613  const bool has_cardinality_estimation,
614  ColumnCacheMap& column_cache);
615 
616  void executeUpdate(const RelAlgExecutionUnit& ra_exe_unit,
617  const std::vector<InputTableInfo>& table_infos,
618  const CompilationOptions& co,
619  const ExecutionOptions& eo,
620  const Catalog_Namespace::Catalog& cat,
621  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
623  const bool is_agg = false);
624 
625  using PerFragmentCallBack =
626  std::function<void(ResultSetPtr, const Fragmenter_Namespace::FragmentInfo&)>;
627 
633  void executeWorkUnitPerFragment(const RelAlgExecutionUnit& ra_exe_unit,
634  const InputTableInfo& table_info,
635  const CompilationOptions& co,
636  const ExecutionOptions& eo,
637  const Catalog_Namespace::Catalog& cat,
638  PerFragmentCallBack& cb);
639 
641 
648  const std::vector<InputTableInfo>& table_infos,
649  const CompilationOptions& co,
650  const ExecutionOptions& eo,
651  const Catalog_Namespace::Catalog& cat);
652 
653  // TODO(alex): remove
655  const RelAlgExecutionUnit& ra_exe_unit,
656  const ExecutorDeviceType requested_device_type);
657 
659  ExecutionDispatch& execution_dispatch,
660  const std::vector<Analyzer::Expr*>& target_exprs,
662  const ExecutorDeviceType device_type,
663  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner);
664 
666  ExecutionDispatch& execution_dispatch) const;
667 
668  std::unordered_map<int, const Analyzer::BinOper*> getInnerTabIdToJoinCond() const;
669 
670  void dispatchFragments(
671  const std::function<void(const ExecutorDeviceType chosen_device_type,
672  int chosen_device_id,
673  const QueryCompilationDescriptor& query_comp_desc,
675  const FragmentsList& frag_list,
676  const ExecutorDispatchMode kernel_dispatch_mode,
677  const int64_t rowid_lookup_key)> dispatch,
678  const ExecutionDispatch& execution_dispatch,
679  const std::vector<InputTableInfo>& table_infos,
680  const ExecutionOptions& eo,
681  const bool is_agg,
682  const bool allow_single_frag_table_opt,
683  const size_t context_count,
684  const QueryCompilationDescriptor& query_comp_desc,
685  const QueryMemoryDescriptor& query_mem_desc,
686  QueryFragmentDescriptor& fragment_descriptor,
687  std::unordered_set<int>& available_gpus,
688  int& available_cpus);
689 
690  std::vector<size_t> getTableFragmentIndices(
691  const RelAlgExecutionUnit& ra_exe_unit,
692  const ExecutorDeviceType device_type,
693  const size_t table_idx,
694  const size_t outer_frag_idx,
695  std::map<int, const TableFragments*>& selected_tables_fragments,
696  const std::unordered_map<int, const Analyzer::BinOper*>&
697  inner_table_id_to_join_condition);
698 
699  bool skipFragmentPair(const Fragmenter_Namespace::FragmentInfo& outer_fragment_info,
700  const Fragmenter_Namespace::FragmentInfo& inner_fragment_info,
701  const int inner_table_id,
702  const std::unordered_map<int, const Analyzer::BinOper*>&
703  inner_table_id_to_join_condition,
704  const RelAlgExecutionUnit& ra_exe_unit,
705  const ExecutorDeviceType device_type);
706 
708  const RelAlgExecutionUnit& ra_exe_unit,
709  const int device_id,
711  const std::map<int, const TableFragments*>&,
712  const FragmentsList& selected_fragments,
714  std::list<ChunkIter>&,
715  std::list<std::shared_ptr<Chunk_NS::Chunk>>&);
716 
717  std::pair<std::vector<std::vector<int64_t>>, std::vector<std::vector<uint64_t>>>
719  const RelAlgExecutionUnit& ra_exe_unit,
720  const CartesianProduct<std::vector<std::vector<size_t>>>& frag_ids_crossjoin,
721  const std::vector<InputDescriptor>& input_descs,
722  const std::map<int, const TableFragments*>& all_tables_fragments);
723 
725  std::vector<std::vector<size_t>>& selected_fragments_crossjoin,
726  std::vector<size_t>& local_col_to_frag_pos,
727  const std::list<std::shared_ptr<const InputColDescriptor>>& col_global_ids,
728  const FragmentsList& selected_fragments,
729  const RelAlgExecutionUnit& ra_exe_unit);
730 
731  std::vector<size_t> getFragmentCount(const FragmentsList& selected_fragments,
732  const size_t scan_idx,
733  const RelAlgExecutionUnit& ra_exe_unit);
734 
735  int32_t executePlanWithGroupBy(const RelAlgExecutionUnit& ra_exe_unit,
736  const CompilationResult&,
737  const bool hoist_literals,
738  ResultSetPtr& results,
739  const ExecutorDeviceType device_type,
740  std::vector<std::vector<const int8_t*>>& col_buffers,
741  const std::vector<size_t> outer_tab_frag_ids,
743  const std::vector<std::vector<int64_t>>& num_rows,
744  const std::vector<std::vector<uint64_t>>& frag_offsets,
746  const int device_id,
747  const int64_t limit,
748  const uint32_t start_rowid,
749  const uint32_t num_tables,
750  RenderInfo* render_info);
752  const RelAlgExecutionUnit& ra_exe_unit,
753  const CompilationResult&,
754  const bool hoist_literals,
755  ResultSetPtr& results,
756  const std::vector<Analyzer::Expr*>& target_exprs,
757  const ExecutorDeviceType device_type,
758  std::vector<std::vector<const int8_t*>>& col_buffers,
759  QueryExecutionContext* query_exe_context,
760  const std::vector<std::vector<int64_t>>& num_rows,
761  const std::vector<std::vector<uint64_t>>& frag_offsets,
762  Data_Namespace::DataMgr* data_mgr,
763  const int device_id,
764  const uint32_t start_rowid,
765  const uint32_t num_tables,
766  RenderInfo* render_info);
767 
768  public: // Temporary, ask saman about this
769  static std::pair<int64_t, int32_t> reduceResults(const SQLAgg agg,
770  const SQLTypeInfo& ti,
771  const int64_t agg_init_val,
772  const int8_t out_byte_width,
773  const int64_t* out_vec,
774  const size_t out_vec_sz,
775  const bool is_group_by,
776  const bool float_argument_input);
777 
778  static void addCodeToCache(const CodeCacheKey&,
779  std::vector<std::tuple<void*, ExecutionEngineWrapper>>,
780  llvm::Module*,
781  CodeCache&);
782 
783  private:
784  ResultSetPtr resultsUnion(ExecutionDispatch& execution_dispatch);
785  std::vector<int64_t> getJoinHashTablePtrs(const ExecutorDeviceType device_type,
786  const int device_id);
788  const RelAlgExecutionUnit&,
789  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>>& all_fragment_results,
790  std::shared_ptr<RowSetMemoryOwner>,
791  const QueryMemoryDescriptor&) const;
793  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>>& all_fragment_results,
794  std::shared_ptr<RowSetMemoryOwner>,
795  const QueryMemoryDescriptor&) const;
797  const RelAlgExecutionUnit&,
798  std::vector<std::pair<ResultSetPtr, std::vector<size_t>>>& all_fragment_results,
799  std::shared_ptr<RowSetMemoryOwner>,
800  const QueryMemoryDescriptor&) const;
801  void executeSimpleInsert(const Planner::RootPlan* root_plan);
802 
803  ResultSetPtr executeWorkUnitImpl(size_t& max_groups_buffer_entry_guess,
804  const bool is_agg,
805  const bool allow_single_frag_table_opt,
806  const std::vector<InputTableInfo>&,
807  const RelAlgExecutionUnit&,
808  const CompilationOptions&,
809  const ExecutionOptions& options,
811  std::shared_ptr<RowSetMemoryOwner>,
812  RenderInfo* render_info,
813  const bool has_cardinality_estimation,
814  ColumnCacheMap& column_cache);
815 
816  std::vector<llvm::Value*> inlineHoistedLiterals();
817 
818  std::tuple<Executor::CompilationResult, std::unique_ptr<QueryMemoryDescriptor>>
819  compileWorkUnit(const std::vector<InputTableInfo>& query_infos,
820  const RelAlgExecutionUnit& ra_exe_unit,
821  const CompilationOptions& co,
822  const ExecutionOptions& eo,
823  const CudaMgr_Namespace::CudaMgr* cuda_mgr,
824  const bool allow_lazy_fetch,
825  std::shared_ptr<RowSetMemoryOwner>,
826  const size_t max_groups_buffer_entry_count,
827  const int8_t crt_min_byte_width,
828  const bool has_cardinality_estimation,
829  ColumnCacheMap& column_cache,
830  RenderInfo* render_info = nullptr);
831  // Generate code to skip the deleted rows in the outermost table.
832  llvm::BasicBlock* codegenSkipDeletedOuterTableRow(
833  const RelAlgExecutionUnit& ra_exe_unit,
834  const CompilationOptions& co);
835  std::vector<JoinLoop> buildJoinLoops(RelAlgExecutionUnit& ra_exe_unit,
836  const CompilationOptions& co,
837  const ExecutionOptions& eo,
838  const std::vector<InputTableInfo>& query_infos,
839  ColumnCacheMap& column_cache);
840  // Create a callback which generates code which returns true iff the row on the given
841  // level is deleted.
842  std::function<llvm::Value*(const std::vector<llvm::Value*>&, llvm::Value*)>
843  buildIsDeletedCb(const RelAlgExecutionUnit& ra_exe_unit,
844  const size_t level_idx,
845  const CompilationOptions& co);
846  // Builds a join hash table for the provided conditions on the current level.
847  // Returns null iff on failure and provides the reasons in `fail_reasons`.
848  std::shared_ptr<JoinHashTableInterface> buildCurrentLevelHashTable(
849  const JoinCondition& current_level_join_conditions,
850  RelAlgExecutionUnit& ra_exe_unit,
851  const CompilationOptions& co,
852  const std::vector<InputTableInfo>& query_infos,
853  ColumnCacheMap& column_cache,
854  std::vector<std::string>& fail_reasons);
855  llvm::Value* addJoinLoopIterator(const std::vector<llvm::Value*>& prev_iters,
856  const size_t level_idx);
857  void codegenJoinLoops(const std::vector<JoinLoop>& join_loops,
858  const RelAlgExecutionUnit& ra_exe_unit,
859  GroupByAndAggregate& group_by_and_aggregate,
860  llvm::Function* query_func,
861  llvm::BasicBlock* entry_bb,
863  const CompilationOptions& co,
864  const ExecutionOptions& eo);
865  bool compileBody(const RelAlgExecutionUnit& ra_exe_unit,
866  GroupByAndAggregate& group_by_and_aggregate,
868  const CompilationOptions& co);
869 
870  void createErrorCheckControlFlow(llvm::Function* query_func,
871  bool run_with_dynamic_watchdog,
872  ExecutorDeviceType device_type);
873 
874  void preloadFragOffsets(const std::vector<InputDescriptor>& input_descs,
875  const std::vector<InputTableInfo>& query_infos);
876 
878  std::shared_ptr<JoinHashTableInterface> hash_table;
879  std::string fail_reason;
880  };
881 
883  const std::shared_ptr<Analyzer::BinOper>& qual_bin_oper,
884  const std::vector<InputTableInfo>& query_infos,
885  const MemoryLevel memory_level,
886  const JoinHashTableInterface::HashType preferred_hash_type,
887  ColumnCacheMap& column_cache);
888  void nukeOldState(const bool allow_lazy_fetch,
889  const std::vector<InputTableInfo>& query_infos,
890  const RelAlgExecutionUnit* ra_exe_unit);
891 
892  std::vector<std::pair<void*, void*>> optimizeAndCodegenCPU(
893  llvm::Function*,
894  llvm::Function*,
895  const std::unordered_set<llvm::Function*>&,
896  const CompilationOptions&);
897  std::vector<std::pair<void*, void*>> optimizeAndCodegenGPU(
898  llvm::Function*,
899  llvm::Function*,
900  std::unordered_set<llvm::Function*>&,
901  const bool no_inline,
902  const CudaMgr_Namespace::CudaMgr* cuda_mgr,
903  const CompilationOptions&);
904  std::string generatePTX(const std::string&) const;
905  void initializeNVPTXBackend() const;
906 
907  int64_t deviceCycles(int milliseconds) const;
908 
910  llvm::Value* translated_value;
911  llvm::Value* original_value;
912  };
913 
915  const size_t col_width,
916  const CompilationOptions&,
917  const bool translate_null_val,
918  const int64_t translated_null_val,
920  std::stack<llvm::BasicBlock*>&,
921  const bool thread_mem_shared);
922 
923  llvm::Value* castToFP(llvm::Value* val);
924  llvm::Value* castToIntPtrTyIn(llvm::Value* val, const size_t bit_width);
925 
927 
928  std::pair<bool, int64_t> skipFragment(
929  const InputDescriptor& table_desc,
930  const Fragmenter_Namespace::FragmentInfo& frag_info,
931  const std::list<std::shared_ptr<Analyzer::Expr>>& simple_quals,
932  const std::vector<uint64_t>& frag_offsets,
933  const size_t frag_idx);
934 
935  std::pair<bool, int64_t> skipFragmentInnerJoins(
936  const InputDescriptor& table_desc,
937  const RelAlgExecutionUnit& ra_exe_unit,
938  const Fragmenter_Namespace::FragmentInfo& fragment,
939  const std::vector<uint64_t>& frag_offsets,
940  const size_t frag_idx);
941 
943  const std::unordered_set<PhysicalInput>& phys_inputs);
945  const std::unordered_set<PhysicalInput>& phys_inputs);
946  TableGenerations computeTableGenerations(std::unordered_set<int> phys_table_ids);
947 
948  public:
949  void setupCaching(const std::unordered_set<PhysicalInput>& phys_inputs,
950  const std::unordered_set<int>& phys_table_ids);
951 
952  private:
953  std::vector<std::pair<void*, void*>> getCodeFromCache(const CodeCacheKey&,
954  const CodeCache&);
955 
956  void addCodeToCache(const CodeCacheKey&,
957  const std::vector<std::tuple<void*, GpuCompilationContext*>>&,
958  llvm::Module*,
959  CodeCache&);
960 
961  std::vector<int8_t> serializeLiterals(
962  const std::unordered_map<int, CgenState::LiteralValues>& literals,
963  const int device_id);
964 
965  static size_t align(const size_t off_in, const size_t alignment) {
966  size_t off = off_in;
967  if (off % alignment != 0) {
968  off += (alignment - off % alignment);
969  }
970  return off;
971  }
972 
973  std::unique_ptr<CgenState> cgen_state_;
974 
976  public:
978  : cgen_state_(cgen_state), saved_fetch_cache(cgen_state_->fetch_cache_) {}
980 
981  private:
983  std::unordered_map<int, std::vector<llvm::Value*>> saved_fetch_cache;
984  };
985 
986  llvm::Value* spillDoubleElement(llvm::Value* elem_val, llvm::Type* elem_ty);
987 
988  std::unique_ptr<PlanState> plan_state_;
989  std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner_;
990 
991  static const int max_gpu_count{16};
993 
994  mutable std::mutex gpu_active_modules_mutex_;
998 
999  mutable std::shared_ptr<StringDictionaryProxy> lit_str_dict_proxy_;
1000  mutable std::mutex str_dict_mutex_;
1001 
1002  mutable std::unique_ptr<llvm::TargetMachine> nvptx_target_machine_;
1003 
1006 
1007  ::QueryRenderer::QueryRenderManager* render_manager_;
1008 
1009  static const size_t baseline_threshold{
1010  1000000}; // if a perfect hash needs more entries, use baseline
1011  static const size_t code_cache_size{10000};
1012 
1013  const unsigned block_size_x_;
1014  const unsigned grid_size_x_;
1015  const std::string debug_dir_;
1016  const std::string debug_file_;
1017 
1018  const int db_id_;
1021 
1026 
1027  static std::map<std::pair<int, ::QueryRenderer::QueryRenderManager*>,
1028  std::shared_ptr<Executor>>
1030  static std::mutex execute_mutex_;
1032 
1033  static const int32_t ERR_DIV_BY_ZERO{1};
1034  static const int32_t ERR_OUT_OF_GPU_MEM{2};
1035  static const int32_t ERR_OUT_OF_SLOTS{3};
1036  static const int32_t ERR_UNSUPPORTED_SELF_JOIN{4};
1037  static const int32_t ERR_OUT_OF_RENDER_MEM{5};
1038  static const int32_t ERR_OUT_OF_CPU_MEM{6};
1039  static const int32_t ERR_OVERFLOW_OR_UNDERFLOW{7};
1040  static const int32_t ERR_SPECULATIVE_TOP_OOM{8};
1041  static const int32_t ERR_OUT_OF_TIME{9};
1042  static const int32_t ERR_INTERRUPTED{10};
1043  static const int32_t ERR_COLUMNAR_CONVERSION_NOT_SUPPORTED{11};
1044  static const int32_t ERR_TOO_MANY_LITERALS{12};
1045  static const int32_t ERR_STRING_CONST_IN_RESULTSET{13};
1048  friend class CodeGenerator;
1049  friend class ColumnFetcher;
1051  friend class GroupByAndAggregate;
1057  friend class ResultSet;
1058  friend class InValuesBitmap;
1059  friend class JoinHashTable;
1060  friend class LeafAggregator;
1061  friend class QueryRewriter;
1063  friend class RelAlgExecutor;
1064  friend class TableOptimizer;
1068  friend struct TargetExprCodegen;
1069 
1070  template <typename META_TYPE_CLASS>
1072 };
1073 
1074 inline std::string get_null_check_suffix(const SQLTypeInfo& lhs_ti,
1075  const SQLTypeInfo& rhs_ti) {
1076  if (lhs_ti.get_notnull() && rhs_ti.get_notnull()) {
1077  return "";
1078  }
1079  std::string null_check_suffix{"_nullable"};
1080  if (lhs_ti.get_notnull()) {
1081  CHECK(!rhs_ti.get_notnull());
1082  null_check_suffix += "_rhs";
1083  } else if (rhs_ti.get_notnull()) {
1084  CHECK(!lhs_ti.get_notnull());
1085  null_check_suffix += "_lhs";
1086  }
1087  return null_check_suffix;
1088 }
1089 
1090 inline bool is_unnest(const Analyzer::Expr* expr) {
1091  return dynamic_cast<const Analyzer::UOper*>(expr) &&
1092  static_cast<const Analyzer::UOper*>(expr)->get_optype() == kUNNEST;
1093 }
1094 
1095 bool is_trivial_loop_join(const std::vector<InputTableInfo>& query_infos,
1096  const RelAlgExecutionUnit& ra_exe_unit);
1097 
1098 std::unordered_set<int> get_available_gpus(const Catalog_Namespace::Catalog& cat);
1099 
1100 size_t get_context_count(const ExecutorDeviceType device_type,
1101  const size_t cpu_count,
1102  const size_t gpu_count);
1103 
1104 extern "C" void register_buffer_with_executor_rsm(int64_t exec, int8_t* buffer);
1105 
1107 
1108 #endif // QUERYENGINE_EXECUTE_H
std::vector< std::vector< int64_t > > num_rows
Definition: Execute.h:529
void read_rt_udf_gpu_module(const std::string &udf_ir)
Executor(const int db_id, const size_t block_size_x, const size_t grid_size_x, const std::string &debug_dir, const std::string &debug_file,::QueryRenderer::QueryRenderManager *render_manager)
Definition: Execute.cpp:106
SQLTypeInfo getColumnType(const size_t col_idx) const
std::vector< std::pair< ResultSetPtr, std::vector< size_t > > > & getFragmentResults()
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:117
const std::string debug_dir_
Definition: Execute.h:1015
llvm::Value * translated_value
Definition: Execute.h:910
bool is_fp() const
Definition: sqltypes.h:481
bool is_agg(const Analyzer::Expr *expr)
bool is_boolean() const
Definition: sqltypes.h:484
AggregatedColRange computeColRangesCache(const std::unordered_set< PhysicalInput > &phys_inputs)
Definition: Execute.cpp:3244
std::shared_ptr< ResultSet > renderPointsNonInSitu(const std::string &queryStr, const ExecutionResult &results, const Catalog_Namespace::SessionInfo &session, const int render_widget_id, const ::QueryRenderer::JSONLocation *data_loc, RenderInfo *render_query_data)
SQLAgg
Definition: sqldefs.h:71
#define CHECK_EQ(x, y)
Definition: Logger.h:198
float g_filter_push_down_low_frac
Definition: Execute.cpp:83
ResultSetPtr collectAllDeviceResults(ExecutionDispatch &execution_dispatch, const std::vector< Analyzer::Expr * > &target_exprs, const QueryMemoryDescriptor &query_mem_desc, const ExecutorDeviceType device_type, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner)
Definition: Execute.cpp:1507
std::vector< uint64_t > all_frag_row_offsets_
Definition: Execute.h:543
std::unique_ptr< llvm::TargetMachine > nvptx_target_machine_
Definition: Execute.h:1002
std::unique_ptr< llvm::Module > module(runtime_module_shallow_copy(cgen_state))
size_t g_constrained_by_in_threshold
Definition: Execute.cpp:91
llvm::Value * castToFP(llvm::Value *val)
Definition: Execute.cpp:2984
friend class ResultSet
Definition: Execute.h:1057
static void addCodeToCache(const CodeCacheKey &, std::vector< std::tuple< void *, ExecutionEngineWrapper >>, llvm::Module *, CodeCache &)
double g_bump_allocator_step_reduction
Definition: Execute.cpp:100
const int8_t const int64_t * num_rows
static const int32_t ERR_INTERRUPTED
Definition: Execute.h:1042
const Analyzer::Expr * remove_cast_to_int(const Analyzer::Expr *expr)
Definition: ColumnIR.cpp:527
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:81
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_
Definition: Execute.h:999
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:334
std::vector< std::vector< uint64_t > > frag_offsets
Definition: Execute.h:530
static std::shared_ptr< Executor > getExecutor(const int db_id, const std::string &debug_dir="", const std::string &debug_file="", const MapDParameters mapd_parameters=MapDParameters(),::QueryRenderer::QueryRenderManager *render_manager=nullptr)
Definition: Execute.cpp:127
bool is_trivial_loop_join(const std::vector< InputTableInfo > &query_infos, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:1067
FetchCacheAnchor(CgenState *cgen_state)
Definition: Execute.h:977
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:459
bool g_strip_join_covered_quals
Definition: Execute.cpp:90
const std::shared_ptr< RowSetMemoryOwner > getRowSetMemoryOwner() const
Definition: Execute.cpp:241
StringDictionaryProxy * getLiteralDictionary() const override
Definition: Execute.h:303
std::shared_ptr< ResultSet > execute(const Planner::RootPlan *root_plan, const Catalog_Namespace::SessionInfo &session, const bool hoist_literals, const ExecutorDeviceType device_type, const ExecutorOptLevel, const bool allow_multifrag, const bool allow_loop_joins, RenderInfo *render_query_data=nullptr)
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:1816
bool g_enable_direct_columnarization
Definition: Execute.cpp:101
void dispatchFragments(const std::function< void(const ExecutorDeviceType chosen_device_type, int chosen_device_id, const QueryCompilationDescriptor &query_comp_desc, const QueryMemoryDescriptor &query_mem_desc, const FragmentsList &frag_list, const ExecutorDispatchMode kernel_dispatch_mode, const int64_t rowid_lookup_key)> dispatch, const ExecutionDispatch &execution_dispatch, 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, QueryFragmentDescriptor &fragment_descriptor, std::unordered_set< int > &available_gpus, int &available_cpus)
Definition: Execute.cpp:1692
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:1346
void read_rt_udf_cpu_module(const std::string &udf_ir)
Fragmenter_Namespace::RowDataProvider RowDataProvider
Definition: Execute.h:289
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:177
std::tuple< QueryCompilationDescriptorOwned, QueryMemoryDescriptorOwned > compile(const size_t max_groups_buffer_entry_guess, const int8_t crt_min_byte_width, const CompilationOptions &co, const ExecutionOptions &eo, const ColumnFetcher &column_fetcher, const bool has_cardinality_estimation)
std::unordered_set< int > get_available_gpus(const Catalog_Namespace::Catalog &cat)
Definition: Execute.cpp:947
static const int max_gpu_count
Definition: Execute.h:991
std::unordered_map< int, CgenState::LiteralValues > literal_values
Definition: Execute.h:512
size_t const getFragmentIndex() const
static const size_t code_cache_size
Definition: Execute.h:1011
bool isArchPascalOrLater(const ExecutorDeviceType dt) const
Definition: Execute.h:517
static mapd_shared_mutex executors_cache_mutex_
Definition: Execute.h:1031
bool is_udf_module_present(bool cpu_only=false)
std::vector< ColumnLazyFetchInfo > getColLazyFetchInfo(const std::vector< Analyzer::Expr * > &target_exprs) const
Definition: Execute.cpp:287
static const size_t baseline_threshold
Definition: Execute.h:1009
void registerActiveModule(void *module, const int device_id) const
std::vector< std::string > getStringsFromIds(const std::string &col_name, const std::vector< int32_t > &ids, const ::QueryRenderer::QueryDataLayout *query_data_layout, const ResultSet *results, const std::shared_ptr< RowSetMemoryOwner > &row_set_mem_owner) const
TableGenerations computeTableGenerations(std::unordered_set< int > phys_table_ids)
Definition: Execute.cpp:3291
static std::mutex reduce_mutex_
Definition: Execute.h:549
const SQLTypeInfo get_column_type(const int col_id, const int table_id, const ColumnDescriptor *cd, const TemporaryTables *temporary_tables)
Definition: Execute.h:187
RelAlgExecutionUnit addDeletedColumn(const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:3034
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:869
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:614
void read_udf_gpu_module(const std::string &udf_ir_filename)
Definition: sqldefs.h:49
std::vector< std::string > CodeCacheKey
Definition: CodeCache.h:61
size_t operator()(const std::vector< int > &vec) const
Definition: Execute.h:275
const Analyzer::Expr * extract_cast_arg(const Analyzer::Expr *expr)
Definition: Execute.h:152
const ColumnarResults * rows_to_columnar_results(std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const PtrTy &result, const int number)
Definition: Execute.h:202
size_t g_filter_push_down_passing_row_ubound
Definition: Execute.cpp:85
const RelAlgExecutionUnit & getExecutionUnit() const
AggregatedColRange agg_col_range_cache_
Definition: Execute.h:1023
std::shared_ptr< ResultSet > ResultSetPtr
std::unique_ptr< CgenState > cgen_state_
Definition: Execute.h:973
static const int32_t ERR_TOO_MANY_LITERALS
Definition: Execute.h:1044
llvm::Value * original_value
Definition: Execute.h:911
std::vector< std::vector< const int8_t * > > col_buffers
Definition: Execute.h:528
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:72
unsigned g_trivial_loop_join_threshold
Definition: Execute.cpp:76
std::vector< Analyzer::Expr * > get_exprs_not_owned(const std::vector< std::shared_ptr< Analyzer::Expr >> &exprs)
Definition: Execute.h:214
uint32_t gpu_active_modules_device_mask_
Definition: Execute.h:995
ExecutionDispatch(Executor *executor, const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &query_infos, const Catalog_Namespace::Catalog &cat, const std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, RenderInfo *render_info)
int deviceCount(const ExecutorDeviceType) const
Definition: Execute.cpp:597
llvm::Value * castToIntPtrTyIn(llvm::Value *val, const size_t bit_width)
Definition: Execute.cpp:3004
#define CHECK_GT(x, y)
Definition: Logger.h:202
bool isCPUOnly() const
Definition: Execute.cpp:211
std::vector< FragmentsPerTable > FragmentsList
bool needFetchAllFragments(const InputColDescriptor &col_desc, const RelAlgExecutionUnit &ra_exe_unit, const FragmentsList &selected_fragments) const
Definition: Execute.cpp:1995
std::string to_string(char const *&&v)
std::function< void(const UpdateLogForFragment &)> Callback
Definition: Execute.h:318
#define LOG_IF(severity, condition)
Definition: Logger.h:276
bool g_enable_overlaps_hashjoin
Definition: Execute.cpp:87
size_t g_max_memory_allocation_size
Definition: Execute.cpp:95
bool g_enable_watchdog
static void clearMemory(const Data_Namespace::MemoryLevel memory_level)
Definition: Execute.cpp:160
bool g_inner_join_fragment_skipping
Definition: Execute.cpp:78
std::tuple< Executor::CompilationResult, std::unique_ptr< QueryMemoryDescriptor > > compileWorkUnit(const std::vector< InputTableInfo > &query_infos, 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)
Fragmenter_Namespace::TableInfo getTableInfo(const int table_id) const
Definition: Execute.cpp:249
ExecutorOptLevel
void executeSimpleInsert(const Planner::RootPlan *root_plan)
Definition: Execute.cpp:2582
std::vector< std::pair< void *, void * > > optimizeAndCodegenCPU(llvm::Function *, llvm::Function *, const std::unordered_set< llvm::Function * > &, const CompilationOptions &)
ExecutorDispatchMode
static const size_t high_scan_limit
Definition: Execute.h:468
CodeCache gpu_code_cache_
Definition: Execute.h:1005
std::mutex all_frag_row_offsets_mutex_
Definition: Execute.h:544
static const int32_t ERR_STRING_CONST_IN_RESULTSET
Definition: Execute.h:1045
void codegenWindowAvgEpilogue(llvm::Value *crt_val, llvm::Value *window_func_null_val, llvm::Value *multiplicity_lv)
std::vector< int64_t > getJoinHashTablePtrs(const ExecutorDeviceType device_type, const int device_id)
Definition: Execute.cpp:2515
void preloadFragOffsets(const std::vector< InputDescriptor > &input_descs, const std::vector< InputTableInfo > &query_infos)
Definition: Execute.cpp:2874
bool g_null_div_by_zero
Definition: Execute.cpp:75
::QueryRenderer::QueryRenderManager * render_manager_
Definition: Execute.h:1007
std::unordered_map< int, const ResultSetPtr & > TemporaryTables
Definition: InputMetadata.h:31
false auto cgen_state
static const int32_t ERR_STREAMING_TOP_N_NOT_SUPPORTED_IN_RENDER_QUERY
Definition: Execute.h:1046
static const int32_t ERR_COLUMNAR_CONVERSION_NOT_SUPPORTED
Definition: Execute.h:1043
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:179
int8_t warpSize() const
Definition: Execute.cpp:2951
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:920
bool g_enable_columnar_output
Definition: Execute.cpp:86
const ColumnDescriptor * getPhysicalColumnDescriptor(const Analyzer::ColumnVar *, int) const
Definition: Execute.cpp:222
static const int32_t ERR_DIV_BY_ZERO
Definition: Execute.h:1033
void run(const ExecutorDeviceType chosen_device_type, int chosen_device_id, const ExecutionOptions &eo, const ColumnFetcher &column_fetcher, const QueryCompilationDescriptor &query_comp_desc, const QueryMemoryDescriptor &query_mem_desc, const FragmentsList &frag_ids, const ExecutorDispatchMode kernel_dispatch_mode, const int64_t rowid_lookup_key)
bool g_from_table_reordering
Definition: Execute.cpp:77
CHECK(cgen_state)
llvm::Value * get_arg_by_name(llvm::Function *func, const std::string &name)
Definition: Execute.h:117
std::vector< llvm::Value * > LLVMValueVector
Definition: Execute.h:326
bool is_time() const
Definition: sqltypes.h:483
size_t get_context_count(const ExecutorDeviceType device_type, const size_t cpu_count, const size_t gpu_count)
Definition: Execute.cpp:959
int get_logical_size() const
Definition: sqltypes.h:337
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:171
std::vector< TargetValue > getEntryAt(const size_t index) const override
bool compileBody(const RelAlgExecutionUnit &ra_exe_unit, GroupByAndAggregate &group_by_and_aggregate, const QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co)
std::unordered_map< int, std::vector< llvm::Value * > > fetch_cache_
Definition: CgenState.h:270
decltype(FragmentInfoType::fragmentId) const getFragmentId() const
Definition: Execute.h:312
int64_t deviceCycles(int milliseconds) const
Definition: Execute.cpp:2976
std::string generatePTX(const std::string &) const
const Catalog_Namespace::Catalog & cat_
Definition: Execute.h:542
std::mutex str_dict_mutex_
Definition: Execute.h:1000
const Catalog_Namespace::Catalog * catalog_
Definition: Execute.h:1019
#define INJECT_TIMER(DESC)
Definition: measure.h:91
friend class PendingExecutionClosure
Definition: Execute.h:1062
static const int32_t ERR_OUT_OF_RENDER_MEM
Definition: Execute.h:1037
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:837
std::shared_timed_mutex mapd_shared_mutex
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
const std::string debug_file_
Definition: Execute.h:1016
decltype(FragmentInfoType::physicalTableId) const getPhysicalTableId() const
Definition: Execute.h:309
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
Definition: Execute.h:989
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:79
bool containsLeftDeepOuterJoin() const
Definition: Execute.h:436
void setCatalog(const Catalog_Namespace::Catalog *catalog)
Definition: Execute.cpp:237
const std::vector< uint64_t > & getFragOffsets() const
const std::vector< InputTableInfo > & query_infos_
Definition: Execute.h:541
size_t g_big_group_threshold
Definition: Execute.cpp:92
static const int32_t ERR_OVERFLOW_OR_UNDERFLOW
Definition: Execute.h:1039
float g_filter_push_down_high_frac
Definition: Execute.cpp:84
FragmentInfoType const & getFragmentInfo() const
std::unique_ptr< PlanState > plan_state_
Definition: Execute.h:988
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
static const int32_t ERR_OUT_OF_TIME
Definition: Execute.h:1041
void initializeNVPTXBackend() const
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:333
bool g_bigint_count
std::shared_ptr< ResultSet > renderLinesNonInSitu(const std::string &queryStr, const ExecutionResult &results, const Catalog_Namespace::SessionInfo &session, const int render_widget_id, const ::QueryRenderer::JSONLocation *data_loc, RenderInfo *render_query_data)
const TableGeneration & getTableGeneration(const int table_id) const
Definition: Execute.cpp:253
const std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
Definition: Execute.h:545
size_t fragment_index_
Definition: Execute.h:322
std::shared_ptr< ResultSet > renderPointsInSitu(RenderInfo *render_query_data)
const ColumnDescriptor * getColumnDescriptor(const Analyzer::ColumnVar *) const
Definition: Execute.cpp:216
static const int32_t ERR_UNSUPPORTED_SELF_JOIN
Definition: Execute.h:1036
const unsigned block_size_x_
Definition: Execute.h:1013
void nukeOldState(const bool allow_lazy_fetch, const std::vector< InputTableInfo > &query_infos, const RelAlgExecutionUnit *ra_exe_unit)
Definition: Execute.cpp:2860
const unsigned grid_size_x_
Definition: Execute.h:1014
specifies the content in-memory of a row in the column metadata table
size_t g_overlaps_max_table_size_bytes
Definition: Execute.cpp:89
std::vector< TargetValue > getTranslatedEntryAt(const size_t index) const override
static const int32_t ERR_OUT_OF_GPU_MEM
Definition: Execute.h:1034
std::string get_null_check_suffix(const SQLTypeInfo &lhs_ti, const SQLTypeInfo &rhs_ti)
Definition: Execute.h:1074
ResultSetPtr resultsUnion(ExecutionDispatch &execution_dispatch)
Definition: Execute.cpp:811
void interrupt()
const Catalog_Namespace::Catalog * getCatalog() const
Definition: Execute.cpp:233
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:2259
bool g_enable_window_functions
Definition: Execute.cpp:93
std::shared_ptr< JoinHashTableInterface > hash_table
Definition: Execute.h:878
void createErrorCheckControlFlow(llvm::Function *query_func, bool run_with_dynamic_watchdog, ExecutorDeviceType device_type)
#define CHECK_LT(x, y)
Definition: Logger.h:200
std::shared_ptr< ResultSet > rs_
Definition: Execute.h:323
void runImpl(const ExecutorDeviceType chosen_device_type, int chosen_device_id, const ExecutionOptions &eo, const ColumnFetcher &column_fetcher, const QueryCompilationDescriptor &query_comp_desc, const QueryMemoryDescriptor &query_mem_desc, const FragmentsList &frag_list, const ExecutorDispatchMode kernel_dispatch_mode, const int64_t rowid_lookup_key)
std::vector< int32_t > getStringIds(const std::string &col_name, const std::vector< std::string > &col_vals, const ::QueryRenderer::QueryDataLayout *query_data_layout, const ResultSet *results, const std::shared_ptr< RowSetMemoryOwner > &row_set_mem_owner, const bool warn=false) const
std::vector< size_t > getFragmentCount(const FragmentsList &selected_fragments, const size_t scan_idx, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:2102
size_t operator()(const std::pair< int, int > &p) const
Definition: Execute.h:282
llvm::BasicBlock * codegenSkipDeletedOuterTableRow(const RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co)
std::unique_ptr< QueryCompilationDescriptor > QueryCompilationDescriptorOwned
Definition: Execute.h:96
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 >> &)
Definition: Execute.cpp:2014
const ColumnarResults * columnarize_result(std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const ResultSetPtr &result, const int frag_id)
Definition: Execute.h:223
std::vector< int8_t > serializeLiterals(const std::unordered_map< int, CgenState::LiteralValues > &literals, const int device_id)
Definition: Execute.cpp:335
StringDictionaryGenerations string_dictionary_generations_
Definition: Execute.h:1024
InputTableInfoCache input_table_info_cache_
Definition: Execute.h:1022
std::vector< std::pair< void *, void * > > native_functions
Definition: Execute.h:511
bool is_integer() const
Definition: sqltypes.h:479
void codegenWindowFunctionStateInit(llvm::Value *aggregate_state)
void * gpu_active_modules_[max_gpu_count]
Definition: Execute.h:996
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 &, std::shared_ptr< RowSetMemoryOwner >, RenderInfo *render_info, const bool has_cardinality_estimation, ColumnCacheMap &column_cache)
Definition: Execute.cpp:1109
CodeCache cpu_code_cache_
Definition: Execute.h:1004
ResultSetPtr collectAllDeviceShardedTopResults(ExecutionDispatch &execution_dispatch) const
Definition: Execute.cpp:1618
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:3077
unsigned gridSize() const
Definition: Execute.cpp:2960
bool is_timeinterval() const
Definition: sqltypes.h:488
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:1948
const int8_t const int64_t const uint64_t const int32_t const int64_t int64_t uint32_t frag_idx
StringDictionaryGenerations computeStringDictionaryGenerations(const std::unordered_set< PhysicalInput > &phys_inputs)
Definition: Execute.cpp:3270
FragmentInfoType const & fragment_info_
Definition: Execute.h:321
bool g_enable_table_functions
Definition: Execute.cpp:94
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=false)
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:3211
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:2116
llvm::Value * codegenAggregateWindowState()
TableGenerations table_generations_
Definition: Execute.h:1025
std::tuple< std::string, const Analyzer::Expr *, int64_t, const size_t > AggInfo
Definition: Execute.h:360
void unregisterActiveModule(void *module, const int device_id) const
std::function< void(ResultSetPtr, const Fragmenter_Namespace::FragmentInfo &)> PerFragmentCallBack
Definition: Execute.h:626
void resetInterrupt()
bool g_enable_filter_push_down
Definition: Execute.cpp:82
static const int32_t ERR_SPECULATIVE_TOP_OOM
Definition: Execute.h:1040
llvm::Value * addJoinLoopIterator(const std::vector< llvm::Value * > &prev_iters, const size_t level_idx)
Definition: IRCodegen.cpp:442
ResultSetPtr reduceMultiDeviceResultSets(std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &all_fragment_results, std::shared_ptr< RowSetMemoryOwner >, const QueryMemoryDescriptor &) const
Definition: Execute.cpp:861
llvm::Value * codegenWindowFunctionAggregate(const CompilationOptions &co)
bool is_string() const
Definition: sqltypes.h:477
size_t getNumBytesForFetchedRow() const
Definition: Execute.cpp:261
const int8_t * literals
std::vector< std::pair< void *, void * > > optimizeAndCodegenGPU(llvm::Function *, llvm::Function *, std::unordered_set< llvm::Function * > &, const bool no_inline, const CudaMgr_Namespace::CudaMgr *cuda_mgr, const CompilationOptions &)
static const int32_t ERR_OUT_OF_SLOTS
Definition: Execute.h:1035
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 int64_t limit, const uint32_t start_rowid, const uint32_t num_tables, RenderInfo *render_info)
Definition: Execute.cpp:2402
bool g_allow_cpu_retry
Definition: Execute.cpp:74
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults > > > ColumnCacheMap
std::vector< std::pair< ResultSetPtr, std::vector< size_t > > > all_fragment_results_
Definition: Execute.h:547
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:1150
std::atomic_flag dynamic_watchdog_set_
Definition: Execute.h:548
std::unordered_map< int, const Analyzer::BinOper * > getInnerTabIdToJoinCond() const
Definition: Execute.cpp:1666
ExecutorDeviceType getDeviceTypeForTargets(const RelAlgExecutionUnit &ra_exe_unit, const ExecutorDeviceType requested_device_type)
Definition: Execute.cpp:1378
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:504
uint32_t log2_bytes(const uint32_t bytes)
Definition: Execute.h:127
ExpressionRange getColRange(const PhysicalInput &) const
Definition: Execute.cpp:257
std::string numeric_type_name(const SQLTypeInfo &ti)
Definition: Execute.h:160
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:1090
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:218
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:1301
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:340
unsigned blockSize() const
Definition: Execute.cpp:2968
std::shared_ptr< ResultSet > renderPolygonsNonInSitu(const std::string &queryStr, const ExecutionResult &results, const Catalog_Namespace::SessionInfo &session, const int render_widget_id, const ::QueryRenderer::JSONLocation *data_loc, RenderInfo *render_query_data, const std::string &poly_table_name)
Execution unit for relational algebra. It&#39;s a low-level description of any relational algebra operati...
std::unordered_map< int, std::vector< llvm::Value * > > saved_fetch_cache
Definition: Execute.h:983
CgenState * cgen_state_
Definition: Execute.h:982
static size_t align(const size_t off_in, const size_t alignment)
Definition: Execute.h:965
RenderInfo * render_info_
Definition: Execute.h:546
static std::map< std::pair< int,::QueryRenderer::QueryRenderManager * >, std::shared_ptr< Executor > > executors_
Definition: Execute.h:1029
std::unique_ptr< QueryMemoryDescriptor > QueryMemoryDescriptorOwned
Definition: Execute.h:98
bool is_decimal() const
Definition: sqltypes.h:480
size_t const getRowCount() const override
unsigned g_dynamic_watchdog_time_limit
Definition: Execute.cpp:73
static const int32_t ERR_OUT_OF_CPU_MEM
Definition: Execute.h:1038
static std::mutex execute_mutex_
Definition: Execute.h:1030
int deviceCountForMemoryLevel(const Data_Namespace::MemoryLevel memory_level) const
Definition: Execute.cpp:607
Descriptor for the fragments required for a query.
llvm::Value * codegenWindowFunctionAggregateCalls(llvm::Value *aggregate_state, const CompilationOptions &co)
Fragmenter_Namespace::FragmentInfo FragmentInfoType
Definition: Execute.h:293
ExecutionDispatch & operator=(const ExecutionDispatch &)=delete
bool is_rt_udf_module_present(bool cpu_only=false)
std::mutex gpu_exec_mutex_[max_gpu_count]
Definition: Execute.h:992
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:2894
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:185
llvm::Value * codegenWindowFunction(const size_t target_index, const CompilationOptions &co)
SQLOps get_optype() const
Definition: Analyzer.h:364
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:396
bool interrupted_
Definition: Execute.h:997
const TemporaryTables * getTemporaryTables() const
Definition: Execute.cpp:245
const int db_id_
Definition: Execute.h:1018
const RelAlgExecutionUnit & ra_exe_unit_
Definition: Execute.h:540
std::mutex gpu_active_modules_mutex_
Definition: Execute.h:994
void setupCaching(const std::unordered_set< PhysicalInput > &phys_inputs, const std::unordered_set< int > &phys_table_ids)
Definition: Execute.cpp:3302
static void nukeCacheOfExecutors()
Definition: Execute.h:351
void clearMetaInfoCache()
Definition: Execute.cpp:328
const ColumnDescriptor * get_column_descriptor(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:142
std::vector< std::pair< void *, void * > > getCodeFromCache(const CodeCacheKey &, const CodeCache &)
size_t const getEntryCount() const override
llvm::BasicBlock * codegenWindowResetStateControlFlow()
const TemporaryTables * temporary_tables_
Definition: Execute.h:1020
CompilationRetryNewScanLimit(const size_t new_scan_limit)
Definition: Execute.h:240
WatchdogException(const std::string &cause)
Definition: Execute.h:112
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:1858
ResultSetPtr executeExplain(const QueryCompilationDescriptor &)
Definition: Execute.cpp:1372