Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Forbid CompilationOptions default constructor #640

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions omniscidb/QueryEngine/ColumnIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,10 @@ std::vector<llvm::Value*> CodeGenerator::codegenOuterJoinNullPlaceholder(
}
const auto null_constant =
hdk::ir::makeExpr<hdk::ir::Constant>(null_type, true, Datum{0});
const auto null_target_lvs =
codegen(null_constant.get(),
false,
CompilationOptions{
ExecutorDeviceType::CPU, false, ExecutorOptLevel::Default, false});
// this looks incorrect, should we just use co instead?
CompilationOptions in_co =
CompilationOptions::makeCpuOnly(co).withHoistedLiterals(false);
const auto null_target_lvs = codegen(null_constant.get(), false, in_co);
cgen_state_->ir_builder_.CreateBr(phi_bb);
CHECK_EQ(orig_lvs.size(), null_target_lvs.size());
cgen_state_->ir_builder_.SetInsertPoint(phi_bb);
Expand Down
23 changes: 23 additions & 0 deletions omniscidb/QueryEngine/CompilationOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ struct CompilationOptions {
compiler::cpu_cgen_traits_desc};
}

CompilationOptions withHoistedLiterals(bool hoist = true) {
CompilationOptions co = *this;
co.hoist_literals = hoist;
return co;
}

static CompilationOptions reductionDefaults() {
return CompilationOptions{
ExecutorDeviceType::CPU,
/*hoist_literals=*/false,
/*opt_level=*/ExecutorOptLevel::ReductionJIT,
/*with_dynamic_watchdog=*/false,
/*allow_lazy_fetch=*/true,
/*filter_on_delted_column=*/true,
/*explain_type=*/ExecutorExplainType::Default,
/*register_intel_jit_listener=*/false,
/*use_groupby_buffer_desc=*/false,
/*codegen_traits_desc=*/getCgenTraitsDesc(ExecutorDeviceType::CPU)};
}

static compiler::CodegenTraitsDescriptor getCgenTraitsDesc(
const ExecutorDeviceType device_type,
const bool is_l0 = false) {
Expand Down Expand Up @@ -89,6 +109,9 @@ struct CompilationOptions {
/*use_groupby_buffer_desc=*/false,
/*codegen_traits_desc=*/getCgenTraitsDesc(device_type, is_l0)};
}

private:
CompilationOptions() = default;
};

enum class ExecutorType { Native, Extern };
Expand Down
4 changes: 1 addition & 3 deletions omniscidb/QueryEngine/ResultSetReductionInterpreterStubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ StubGenerator::Stub StubGenerator::generateStub(const std::string& name,
const Type ret_type,
const bool is_external,
const Executor* executor) {
CompilationOptions co{
ExecutorDeviceType::CPU, false, ExecutorOptLevel::ReductionJIT, false};
co.codegen_traits_desc = co.getCgenTraitsDesc(ExecutorDeviceType::CPU);
CompilationOptions co = CompilationOptions::reductionDefaults();
// Multiple executors may trigger the generation of the same
// stub. We'll use get_or_wait/put methods of code cache accessor to
// let the first executor to generate the stub while other executors
Expand Down
8 changes: 2 additions & 6 deletions omniscidb/QueryEngine/ResultSetReductionJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,7 @@ ResultSetReductionJIT::ResultSetReductionJIT(const QueryMemoryDescriptor& query_

ReductionCode ResultSetReductionJIT::codegen() const {
const auto hash_type = query_mem_desc_.getQueryDescriptionType();
CompilationOptions co{
ExecutorDeviceType::CPU, false, ExecutorOptLevel::ReductionJIT, false};

co.codegen_traits_desc = co.getCgenTraitsDesc(ExecutorDeviceType::CPU);
CompilationOptions co = CompilationOptions::reductionDefaults();

if (query_mem_desc_.didOutputColumnar() || !is_aggregate_query(hash_type)) {
return {};
Expand Down Expand Up @@ -1354,8 +1351,7 @@ void ResultSetReductionJIT::finalizeReductionCode(
const llvm::Function* ir_reduce_one_entry,
const llvm::Function* ir_reduce_one_entry_idx,
const CodeCacheKey& key) const {
CompilationOptions co{
ExecutorDeviceType::CPU, false, ExecutorOptLevel::ReductionJIT, false};
CompilationOptions co = CompilationOptions::reductionDefaults();
#ifdef NDEBUG
LOG(IR) << "Reduction Loop:\n"
<< serialize_llvm_object(reduction_code.llvm_reduce_loop);
Expand Down
4 changes: 1 addition & 3 deletions omniscidb/Tests/ArrowBasedExecuteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9657,9 +9657,7 @@ TEST_F(Select, Joins_LeftJoinFiltered) {
auto check_explain_result = [](const std::string& query,
const ExecutorDeviceType dt,
const bool enable_filter_hoisting) {
CompilationOptions co;
co.device_type = dt;
co.hoist_literals = true;
CompilationOptions co = getCompilationOptions(dt);
ExecutionOptions eo = ExecutionOptions::fromConfig(config());
eo.allow_loop_joins = false;
eo.just_explain = true;
Expand Down
12 changes: 6 additions & 6 deletions python/pyhdk/_sql.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,21 @@ cdef class RelAlgExecutor:

def execute(self, **kwargs):
cdef const CConfig *config = self.c_rel_alg_executor.get().getExecutor().getConfigPtr().get()
cdef CCompilationOptions c_co
cdef unique_ptr[CCompilationOptions] c_co
if kwargs.get("device_type", "auto") == "GPU" and not config.exec.cpu_only:
c_co = CCompilationOptions.defaults(CExecutorDeviceType.GPU, False)
c_co = make_unique[CCompilationOptions](CCompilationOptions.defaults(CExecutorDeviceType.GPU, False))
else:
c_co = CCompilationOptions.defaults(CExecutorDeviceType.CPU, False)
c_co.allow_lazy_fetch = kwargs.get("enable_lazy_fetch", config.rs.enable_lazy_fetch)
c_co.with_dynamic_watchdog = kwargs.get("enable_dynamic_watchdog", config.exec.watchdog.enable_dynamic)
c_co = make_unique[CCompilationOptions](CCompilationOptions.defaults(CExecutorDeviceType.CPU, False))
c_co.get().allow_lazy_fetch = kwargs.get("enable_lazy_fetch", config.rs.enable_lazy_fetch)
c_co.get().with_dynamic_watchdog = kwargs.get("enable_dynamic_watchdog", config.exec.watchdog.enable_dynamic)
cdef unique_ptr[CExecutionOptions] c_eo = make_unique[CExecutionOptions](CExecutionOptions.fromConfig(dereference(config)))
c_eo.get().output_columnar_hint = kwargs.get("enable_columnar_output", config.rs.enable_columnar_output)
c_eo.get().with_watchdog = kwargs.get("enable_watchdog", config.exec.watchdog.enable)
c_eo.get().with_dynamic_watchdog = kwargs.get("enable_dynamic_watchdog", config.exec.watchdog.enable_dynamic)
c_eo.get().just_explain = kwargs.get("just_explain", False)
c_eo.get().forced_gpu_proportion = kwargs.get("forced_gpu_proportion", config.exec.heterogeneous.forced_gpu_proportion)
c_eo.get().forced_cpu_proportion = 100 - c_eo.get().forced_gpu_proportion
cdef CExecutionResult c_res = self.c_rel_alg_executor.get().executeRelAlgQuery(c_co, dereference(c_eo.get()), False)
cdef CExecutionResult c_res = self.c_rel_alg_executor.get().executeRelAlgQuery(dereference(c_co.get()), dereference(c_eo.get()), False)
cdef ExecutionResult res = ExecutionResult()
res.c_result = move(c_res)
res.c_data_mgr = self.c_data_mgr
Expand Down