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

Commit 99e33f6

Browse files
committed
Move quantile runtime to static code.
Signed-off-by: ienkovich <[email protected]>
1 parent d5051b5 commit 99e33f6

File tree

5 files changed

+37
-16
lines changed

5 files changed

+37
-16
lines changed

omniscidb/QueryEngine/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ set(query_engine_source_files
7373
OutputBufferInitialization.cpp
7474
QueryPhysicalInputsCollector.cpp
7575
PlanState.cpp
76+
QuantileRuntime.cpp
7677
QueryRewrite.cpp
7778
QueryTemplateGenerator.cpp
7879
QueryExecutionContext.cpp
@@ -136,6 +137,7 @@ set(group_by_hash_test_files
136137
GroupByHashTest.cpp
137138
MurmurHash.cpp
138139
DynamicWatchdog.cpp
140+
QuantileRuntime.cpp
139141
RuntimeFunctions.cpp
140142
)
141143

omniscidb/QueryEngine/GroupByRuntime.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#ifndef __CUDACC__
2121
#include "QueryEngine/TopKAggRuntime.h"
22-
#include "Shared/quantile.h"
2322
#endif
2423

2524
extern "C" RUNTIME_EXPORT ALWAYS_INLINE DEVICE uint32_t
@@ -413,16 +412,12 @@ DEF_AGG_TOPK_ALL(double, double)
413412
#undef DEF_AGG_TOPK_SKIP_VAL
414413
#undef DEF_AGG_TOPK
415414

416-
template <typename ValueType>
417-
void agg_quantile_impl(int64_t* agg, ValueType val) {
418-
auto* quantile = reinterpret_cast<hdk::quantile::Quantile*>(*agg);
419-
quantile->add<ValueType>(val);
420-
}
421-
422-
#define DEF_AGG_QUANTILE(val_type, suffix) \
423-
extern "C" RUNTIME_EXPORT ALWAYS_INLINE DEVICE void agg_quantile_##suffix( \
424-
int64_t* agg, val_type val) { \
425-
agg_quantile_impl<val_type>(agg, val); \
415+
#define DEF_AGG_QUANTILE(val_type, suffix) \
416+
extern "C" RUNTIME_EXPORT DEVICE void agg_quantile_impl_##suffix(int64_t* agg, \
417+
val_type val); \
418+
extern "C" RUNTIME_EXPORT ALWAYS_INLINE DEVICE void agg_quantile_##suffix( \
419+
int64_t* agg, val_type val) { \
420+
agg_quantile_impl_##suffix(agg, val); \
426421
}
427422

428423
#define DEF_AGG_QUANTILE_SKIP_VAL(val_type, suffix) \
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2023 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "Shared/quantile.h"
8+
9+
#define DEF_AGG_QUANTILE_IMPL(val_type, suffix) \
10+
extern "C" RUNTIME_EXPORT DEVICE void agg_quantile_impl_##suffix(int64_t* agg, \
11+
val_type val) { \
12+
auto* quantile = reinterpret_cast<hdk::quantile::Quantile*>(*agg); \
13+
quantile->add<val_type>(val); \
14+
}
15+
16+
DEF_AGG_QUANTILE_IMPL(int8_t, int8)
17+
DEF_AGG_QUANTILE_IMPL(int16_t, int16)
18+
DEF_AGG_QUANTILE_IMPL(int32_t, int32)
19+
DEF_AGG_QUANTILE_IMPL(int64_t, int64)
20+
DEF_AGG_QUANTILE_IMPL(float, float)
21+
DEF_AGG_QUANTILE_IMPL(double, double)

omniscidb/Shared/InlineNullValues.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <cstdint>
2929
#include <cstdlib>
3030
#include <limits>
31+
#include <type_traits>
3132

3233
#define NULL_BOOLEAN INT8_MIN
3334
#define NULL_TINYINT INT8_MIN

omniscidb/Shared/quantile.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include "IR/OpTypeEnums.h"
1313

14+
#include <algorithm>
15+
#include <cmath>
1416
#include <cstdint>
1517
#include <vector>
1618

@@ -260,18 +262,18 @@ class Quantile {
260262
size_t right_idx;
261263
switch (interpolation) {
262264
case ir::Interpolation::kLower:
263-
left_idx = right_idx = floor(pos);
265+
left_idx = right_idx = std::floor(pos);
264266
break;
265267
case ir::Interpolation::kHigher:
266-
left_idx = right_idx = ceil(pos);
268+
left_idx = right_idx = std::ceil(pos);
267269
break;
268270
case ir::Interpolation::kNearest:
269-
left_idx = right_idx = round(pos);
271+
left_idx = right_idx = std::round(pos);
270272
break;
271273
case ir::Interpolation::kMidpoint:
272274
case ir::Interpolation::kLinear:
273-
left_idx = floor(pos);
274-
right_idx = ceil(pos);
275+
left_idx = std::floor(pos);
276+
right_idx = std::ceil(pos);
275277
break;
276278
}
277279

0 commit comments

Comments
 (0)