23 #include "../Parser/ParserNode.h"
24 #include "../Shared/checked_alloc.h"
35 const int64_t null_val,
37 const int device_count,
39 : rhs_has_null_(
false)
53 min_val_ = std::numeric_limits<int64_t>::max();
54 max_val_ = std::numeric_limits<int64_t>::min();
55 for (
const auto value : values) {
56 if (value == null_val) {
78 uint64_t
const bitmap_sz_bytes = bitmap_sz_bits_minus_one / 8 + 1;
79 auto cpu_bitset =
static_cast<int8_t*
>(
checked_calloc(bitmap_sz_bytes, 1));
80 for (
const auto value : values) {
81 if (value == null_val) {
85 reinterpret_cast<int64_t*>(&cpu_bitset), value, min_val_, 0);
89 for (
int device_id = 0; device_id <
device_count_; ++device_id) {
90 auto device_allocator = std::make_unique<CudaAllocator>(
95 device_allocator->copyToDevice(gpu_bitset, cpu_bitset, bitmap_sz_bytes);
125 std::vector<std::shared_ptr<const Analyzer::Constant>> constants_owned;
126 std::vector<const Analyzer::Constant*> constants;
127 for (
const auto bitset :
bitsets_) {
128 const int64_t bitset_handle =
reinterpret_cast<int64_t
>(bitset);
131 CHECK(bitset_handle_literal);
133 constants_owned.push_back(bitset_handle_literal);
134 constants.push_back(bitset_handle_literal.get());
136 const auto needle_i64 = executor->cgen_state_->castToTypeIn(needle, 64);
137 const auto null_bool_val =
140 llvm::PointerType::get(
get_int_type(8, executor->cgen_state_->context_), 0);
141 if (bitsets_.empty()) {
142 auto empty_bitmap = executor->cgen_state_->llInt(int64_t(0));
143 auto empty_bitmap_ptr =
144 executor->cgen_state_->ir_builder_.CreateIntToPtr(empty_bitmap, pi8_ty);
145 return executor->cgen_state_->emitCall(
"bit_is_set",
148 executor->cgen_state_->llInt(int64_t(0)),
149 executor->cgen_state_->llInt(int64_t(0)),
151 executor->cgen_state_->llInt(null_bool_val)});
154 const auto bitset_handle_lvs =
156 CHECK_EQ(
size_t(1), bitset_handle_lvs.size());
157 auto bitset_ptr = executor->cgen_state_->ir_builder_.CreateIntToPtr(
158 bitset_handle_lvs.front(), pi8_ty);
159 return executor->cgen_state_->emitCall(
"bit_is_set",
162 executor->cgen_state_->llInt(
min_val_),
163 executor->cgen_state_->llInt(
max_val_),
165 executor->cgen_state_->llInt(null_bool_val)});
static std::shared_ptr< Analyzer::Expr > analyzeValue(const int64_t intval)
RUNTIME_EXPORT ALWAYS_INLINE void agg_count_distinct_bitmap(int64_t *agg, const int64_t val, const int64_t min_val, const int64_t bucket_size)
std::vector< llvm::Value * > codegenHoistedConstants(const std::vector< const Analyzer::Constant * > &constants, const EncodingType enc_type, const shared::StringDictKey &dict_id)
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
std::vector< int8_t * > bitsets_
std::vector< Data_Namespace::AbstractBuffer * > gpu_buffers_
void * checked_calloc(const size_t nmemb, const size_t size)
int64_t g_bitmap_memory_limit
InValuesBitmap(const std::vector< int64_t > &values, const int64_t null_val, const Data_Namespace::MemoryLevel memory_level, const int device_count, Data_Namespace::DataMgr *data_mgr)
llvm::Value * codegen(llvm::Value *needle, Executor *executor) const
Data_Namespace::DataMgr * data_mgr_
CUstream getQueryEngineCudaStreamForDevice(int device_num)
bool g_enable_watchdog false
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
device_count_(device_count)
void free(AbstractBuffer *buffer)
AbstractBuffer * alloc(const MemoryLevel memoryLevel, const int deviceId, const size_t numBytes)
const Data_Namespace::MemoryLevel memory_level_
memory_level_(memory_level)