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

Commit 0b38686

Browse files
akroviakovkurapov-peter
authored andcommitted
move proportion knobs to execution options
1 parent 50f9178 commit 0b38686

File tree

7 files changed

+17
-58
lines changed

7 files changed

+17
-58
lines changed

examples/heterogeneous_demo.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@
7676
" prop_time = {col_names[0] : [], col_names[1]: []}\n",
7777
" # Walking over proportions\n",
7878
" for gpu_proportion in range(0, 101, prop_step):\n",
79-
" config.gpu_prop = gpu_proportion\n",
8079
" # Multiple iterations\n",
8180
" for _ in range(1, n_iters + 1):\n",
8281
" rel_alg_executor = pyhdk.sql.RelAlgExecutor(executor, storage, data_mgr, ra)\n",
8382
" query_start = time.perf_counter()\n",
84-
" result = rel_alg_executor.execute()\n",
83+
" result = rel_alg_executor.execute(forced_gpu_proportion=gpu_proportion)\n",
8584
" query_finish = time.perf_counter()\n",
8685
" prop_time[col_names[0]].append(gpu_proportion)\n",
8786
" prop_time[col_names[1]].append(query_finish - query_start)\n",
@@ -157,7 +156,7 @@
157156
"outputs": [],
158157
"source": [
159158
"# Read data\n",
160-
"dataset_path = \"some/path/myFile.csv\"\n",
159+
"dataset_path = \"../omniscidb/Tests/ArrowStorageDataFiles/taxi_sample_header.csv\"\n",
161160
"table_name = \"taxi\"\n",
162161
"# If the CSV does not have a header, please provide the column names.\n",
163162
"pyarrow_tbl = pa.csv.read_csv(dataset_path)"

omniscidb/QueryEngine/CompilationOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ struct ExecutionOptions {
108108
bool allow_runtime_query_interrupt;
109109
double running_query_interrupt_freq;
110110
unsigned pending_query_interrupt_freq;
111+
unsigned forced_gpu_proportion;
112+
unsigned forced_cpu_proportion;
111113
ExecutorType executor_type = ExecutorType::Native;
112114
std::vector<size_t> outer_fragment_indices{};
113115
bool multifrag_result = false;
@@ -134,6 +136,8 @@ struct ExecutionOptions {
134136

135137
eo.multifrag_result = config.exec.enable_multifrag_rs;
136138
eo.preserve_order = false;
139+
eo.forced_gpu_proportion = config.exec.heterogeneous.forced_gpu_proportion;
140+
eo.forced_cpu_proportion = config.exec.heterogeneous.forced_cpu_proportion;
137141

138142
return eo;
139143
}

omniscidb/QueryEngine/Execute.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,8 @@ std::pair<std::unique_ptr<policy::ExecutionPolicy>, ExecutorDeviceType>
19361936
Executor::getExecutionPolicyForTargets(const RelAlgExecutionUnit& ra_exe_unit,
19371937
const ExecutorDeviceType requested_device_type,
19381938
const std::vector<InputTableInfo>& query_infos,
1939-
size_t& max_groups_buffer_entry_guess) {
1939+
size_t& max_groups_buffer_entry_guess,
1940+
const ExecutionOptions& eo) {
19401941
if (needFallbackOnCPU(ra_exe_unit, requested_device_type)) {
19411942
LOG(DEBUG1) << "Devices Restricted, falling back on CPU";
19421943
return {std::make_unique<policy::FragmentIDAssignmentExecutionPolicy>(
@@ -1995,8 +1996,8 @@ Executor::getExecutionPolicyForTargets(const RelAlgExecutionUnit& ra_exe_unit,
19951996
if (cfg.enable_heterogeneous_execution) {
19961997
if (cfg.forced_heterogeneous_distribution) {
19971998
std::map<ExecutorDeviceType, unsigned> distribution{
1998-
{ExecutorDeviceType::CPU, cfg.forced_cpu_proportion},
1999-
{ExecutorDeviceType::GPU, cfg.forced_gpu_proportion}};
1999+
{ExecutorDeviceType::CPU, eo.forced_cpu_proportion},
2000+
{ExecutorDeviceType::GPU, eo.forced_gpu_proportion}};
20002001
exe_policy = std::make_unique<policy::ProportionBasedExecutionPolicy>(
20012002
std::move(distribution));
20022003
} else {
@@ -2110,7 +2111,7 @@ hdk::ResultSetTable Executor::executeWorkUnitImpl(
21102111
ColumnCacheMap& column_cache) {
21112112
INJECT_TIMER(Exec_executeWorkUnit);
21122113
auto [exe_policy, fallback_device] = getExecutionPolicyForTargets(
2113-
ra_exe_unit, co.device_type, query_infos, max_groups_buffer_entry_guess);
2114+
ra_exe_unit, co.device_type, query_infos, max_groups_buffer_entry_guess, eo);
21142115

21152116
int8_t crt_min_byte_width{MAX_BYTE_WIDTH_SUPPORTED};
21162117
do {

omniscidb/QueryEngine/Execute.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ class Executor : public StringDictionaryProxyProvider {
472472
getExecutionPolicyForTargets(const RelAlgExecutionUnit& ra_exe_unit,
473473
const ExecutorDeviceType requested_device_type,
474474
const std::vector<InputTableInfo>& query_infos,
475-
size_t& max_groups_buffer_entry_guess);
475+
size_t& max_groups_buffer_entry_guess,
476+
const ExecutionOptions& eo);
476477

477478
hdk::ResultSetTable collectAllDeviceResults(
478479
SharedKernelContext& shared_context,

python/pyhdk/_common.pyx

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -184,56 +184,6 @@ cdef class TypeInfo:
184184
def __repr__(self):
185185
return self.c_type_info.toString()
186186

187-
cdef class Config:
188-
@property
189-
def gpu_prop(self):
190-
return self.c_config.get().exec.heterogeneous.forced_gpu_proportion
191-
192-
@gpu_prop.setter
193-
def gpu_prop(self, gpu_prop):
194-
self.c_config.get().exec.heterogeneous.forced_gpu_proportion=gpu_prop
195-
self.c_config.get().exec.heterogeneous.forced_cpu_proportion=100-gpu_prop
196-
197-
@property
198-
def allow_cpu_retry(self):
199-
return self.c_config.get().exec.heterogeneous.allow_cpu_retry
200-
201-
@allow_cpu_retry.setter
202-
def allow_cpu_retry(self, allowed):
203-
self.c_config.get().exec.heterogeneous.allow_cpu_retry=allowed
204-
205-
@property
206-
def allow_query_step_cpu_retry(self):
207-
return self.c_config.get().exec.heterogeneous.allow_query_step_cpu_retry
208-
209-
@allow_query_step_cpu_retry.setter
210-
def allow_query_step_cpu_retry(self, allowed):
211-
self.c_config.get().exec.heterogeneous.allow_query_step_cpu_retry=allowed
212-
213-
@property
214-
def enable_heterogeneous_execution(self):
215-
return self.c_config.get().exec.heterogeneous.enable_heterogeneous_execution
216-
217-
@enable_heterogeneous_execution.setter
218-
def enable_heterogeneous_execution(self, enabled):
219-
self.c_config.get().exec.heterogeneous.enable_heterogeneous_execution=enabled
220-
221-
@property
222-
def forced_heterogeneous_distribution(self):
223-
return self.c_config.get().exec.heterogeneous.forced_heterogeneous_distribution
224-
225-
@forced_heterogeneous_distribution.setter
226-
def forced_heterogeneous_distribution(self, enabled):
227-
self.c_config.get().exec.heterogeneous.forced_heterogeneous_distribution=enabled
228-
229-
@property
230-
def enable_multifrag_heterogeneous_execution(self):
231-
return self.c_config.get().exec.heterogeneous.enable_multifrag_heterogeneous_execution
232-
233-
@enable_multifrag_heterogeneous_execution.setter
234-
def enable_multifrag_heterogeneous_execution(self, enabled):
235-
self.c_config.get().exec.heterogeneous.enable_multifrag_heterogeneous_execution=enabled
236-
237187
def buildConfig(*, enable_debug_timer=None, enable_union=False, log_dir="hdk_log", **kwargs):
238188
global g_enable_debug_timer
239189
if enable_debug_timer is not None:

python/pyhdk/_execute.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ cdef extern from "omniscidb/QueryEngine/CompilationOptions.h":
8383
double gpu_input_mem_limit_percent
8484
bool allow_runtime_query_interrupt
8585
double running_query_interrupt_freq
86+
unsigned forced_gpu_proportion
87+
unsigned forced_cpu_proportion
8688
unsigned pending_query_interrupt_freq
8789
CExecutorType executor_type
8890
vector[size_t] outer_fragment_indices

python/pyhdk/_sql.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ cdef class RelAlgExecutor:
204204
c_eo.get().with_watchdog = kwargs.get("enable_watchdog", config.exec.watchdog.enable)
205205
c_eo.get().with_dynamic_watchdog = kwargs.get("enable_dynamic_watchdog", config.exec.watchdog.enable_dynamic)
206206
c_eo.get().just_explain = kwargs.get("just_explain", False)
207+
c_eo.get().forced_gpu_proportion = kwargs.get("forced_gpu_proportion", config.exec.heterogeneous.forced_gpu_proportion)
208+
c_eo.get().forced_cpu_proportion = 100 - c_eo.get().forced_gpu_proportion
207209
cdef CExecutionResult c_res = self.c_rel_alg_executor.get().executeRelAlgQuery(c_co, dereference(c_eo.get()), False)
208210
cdef ExecutionResult res = ExecutionResult()
209211
res.c_result = move(c_res)

0 commit comments

Comments
 (0)