diff --git a/omniscidb/QueryEngine/CompilationOptions.cpp b/omniscidb/QueryEngine/CompilationOptions.cpp index 7f7a67ebf..2510e5499 100644 --- a/omniscidb/QueryEngine/CompilationOptions.cpp +++ b/omniscidb/QueryEngine/CompilationOptions.cpp @@ -37,4 +37,17 @@ std::ostream& operator<<(std::ostream& os, const ExecutionOptions& eo) { << "preserve_order=" << eo.preserve_order << "\n"; return os; } + +std::ostream& operator<<(std::ostream& os, const ExecutorOptLevel& ol) { + switch (ol) { + case ExecutorOptLevel::Default: + return os << "ExecutorOptLevel::Default"; + + case ExecutorOptLevel::ReductionJIT: + return os << "ExecutorOptLevel::ReductionJIT"; + + default: + return os << "Unknown ExecutorOptLevel"; + } +} #endif diff --git a/omniscidb/QueryEngine/CompilationOptions.h b/omniscidb/QueryEngine/CompilationOptions.h index 7555039bd..fb59933ad 100644 --- a/omniscidb/QueryEngine/CompilationOptions.h +++ b/omniscidb/QueryEngine/CompilationOptions.h @@ -168,6 +168,7 @@ struct ExecutionOptions { #ifndef __CUDACC__ std::ostream& operator<<(std::ostream& os, const ExecutionOptions& eo); +std::ostream& operator<<(std::ostream& os, const ExecutorOptLevel& ol); #endif #endif // QUERYENGINE_COMPILATIONOPTIONS_H diff --git a/omniscidb/QueryEngine/Execute.cpp b/omniscidb/QueryEngine/Execute.cpp index 09ba95672..a0d438cd4 100644 --- a/omniscidb/QueryEngine/Execute.cpp +++ b/omniscidb/QueryEngine/Execute.cpp @@ -1219,7 +1219,9 @@ ReductionCode get_reduction_code( this_result_set->getTargetInitVals(), config, executor); - return reduction_jit.codegen(); + auto reduction_co = CompilationOptions::makeCpuOnly(co); + reduction_co.opt_level = ExecutorOptLevel::ReductionJIT; + return reduction_jit.codegen(reduction_co); }; } // namespace diff --git a/omniscidb/QueryEngine/ResultSetReduction.cpp b/omniscidb/QueryEngine/ResultSetReduction.cpp index 6a6444e21..d11f05443 100644 --- a/omniscidb/QueryEngine/ResultSetReduction.cpp +++ b/omniscidb/QueryEngine/ResultSetReduction.cpp @@ -994,7 +994,10 @@ ResultSet* ResultSetManager::reduce(std::vector& result_sets, result_rs->getTargetInitVals(), config, executor); - auto reduction_code = reduction_jit.codegen(); + CompilationOptions co = { + ExecutorDeviceType::CPU, false, ExecutorOptLevel::ReductionJIT, false}; + co.codegen_traits_desc = co.getCgenTraitsDesc(ExecutorDeviceType::CPU); + auto reduction_code = reduction_jit.codegen(co); size_t ctr = 1; for (auto result_it = result_sets.begin() + 1; result_it != result_sets.end(); ++result_it) { diff --git a/omniscidb/QueryEngine/ResultSetReductionJIT.cpp b/omniscidb/QueryEngine/ResultSetReductionJIT.cpp index 8b6fd9bfd..4c9eca4ef 100644 --- a/omniscidb/QueryEngine/ResultSetReductionJIT.cpp +++ b/omniscidb/QueryEngine/ResultSetReductionJIT.cpp @@ -554,12 +554,12 @@ ResultSetReductionJIT::ResultSetReductionJIT(const QueryMemoryDescriptor& query_ // for that_entry_index in [start_entry_index, end_entry_index): // reduce_func_idx(this_buff, that_buff, that_entry_index) -ReductionCode ResultSetReductionJIT::codegen() const { +ReductionCode ResultSetReductionJIT::codegen(const CompilationOptions& co) const { + CHECK_EQ(co.device_type, ExecutorDeviceType::CPU); + CHECK_EQ(co.hoist_literals, false); + CHECK_EQ(co.opt_level, ExecutorOptLevel::ReductionJIT); + CHECK_EQ(co.allow_lazy_fetch, false); const auto hash_type = query_mem_desc_.getQueryDescriptionType(); - CompilationOptions co{ - ExecutorDeviceType::CPU, false, ExecutorOptLevel::ReductionJIT, false}; - - co.codegen_traits_desc = co.getCgenTraitsDesc(ExecutorDeviceType::CPU); if (query_mem_desc_.didOutputColumnar() || !is_aggregate_query(hash_type)) { return {}; diff --git a/omniscidb/QueryEngine/ResultSetReductionJIT.h b/omniscidb/QueryEngine/ResultSetReductionJIT.h index ffd2f1748..d5f4678b2 100644 --- a/omniscidb/QueryEngine/ResultSetReductionJIT.h +++ b/omniscidb/QueryEngine/ResultSetReductionJIT.h @@ -59,7 +59,7 @@ class ResultSetReductionJIT { virtual ~ResultSetReductionJIT() = default; // Generate the code for the result set reduction loop. - virtual ReductionCode codegen() const; + virtual ReductionCode codegen(const CompilationOptions& co) const; protected: // Generate a function which checks whether a row is empty. diff --git a/omniscidb/Tests/ResultSetTest.cpp b/omniscidb/Tests/ResultSetTest.cpp index b1b37b051..881206169 100644 --- a/omniscidb/Tests/ResultSetTest.cpp +++ b/omniscidb/Tests/ResultSetTest.cpp @@ -2018,7 +2018,10 @@ TEST(MoreReduce, MissingValues) { rs1->getTargetInitVals(), config(), executor.get()); - const auto reduction_code = reduction_jit.codegen(); + CompilationOptions co = { + ExecutorDeviceType::CPU, false, ExecutorOptLevel::ReductionJIT, false}; + co.codegen_traits_desc = co.getCgenTraitsDesc(ExecutorDeviceType::CPU); + const auto reduction_code = reduction_jit.codegen(co); ResultSetReduction::reduce( *storage1, *storage2, {}, reduction_code, config(), executor.get()); { @@ -2091,7 +2094,10 @@ TEST(MoreReduce, MissingValuesKeyless) { rs1->getTargetInitVals(), config(), executor.get()); - const auto reduction_code = reduction_jit.codegen(); + CompilationOptions co = { + ExecutorDeviceType::CPU, false, ExecutorOptLevel::ReductionJIT, false}; + co.codegen_traits_desc = co.getCgenTraitsDesc(ExecutorDeviceType::CPU); + const auto reduction_code = reduction_jit.codegen(co); ResultSetReduction::reduce( *storage1, *storage2, {}, reduction_code, config(), executor.get()); { @@ -2183,7 +2189,10 @@ TEST(MoreReduce, OffsetRewrite) { rs1->getTargetInitVals(), config(), executor.get()); - const auto reduction_code = reduction_jit.codegen(); + CompilationOptions co = { + ExecutorDeviceType::CPU, false, ExecutorOptLevel::ReductionJIT, false}; + co.codegen_traits_desc = co.getCgenTraitsDesc(ExecutorDeviceType::CPU); + const auto reduction_code = reduction_jit.codegen(co); ResultSetReduction::reduce(*storage1, *storage2, serialized_varlen_buffer,