23 #include "../Parser/ParserNode.h"
24 #include "../Shared/checked_alloc.h"
36 const int64_t null_val,
38 const int device_count,
41 : rhs_has_null_(
false)
56 min_val_ = std::numeric_limits<int64_t>::max();
57 max_val_ = std::numeric_limits<int64_t>::min();
58 for (
const auto value : values) {
59 if (value == null_val) {
81 uint64_t
const bitmap_sz_bytes = bitmap_sz_bits_minus_one / 8 + 1;
82 auto cpu_bitset =
static_cast<int8_t*
>(
checked_calloc(bitmap_sz_bytes, 1));
83 for (
const auto value : values) {
84 if (value == null_val) {
88 reinterpret_cast<int64_t*>(&cpu_bitset), value, min_val_, 0);
92 for (
int device_id = 0; device_id <
device_count_; ++device_id) {
93 auto device_allocator = std::make_unique<CudaAllocator>(
98 device_allocator->copyToDevice(gpu_bitset, cpu_bitset, bitmap_sz_bytes);
128 std::vector<std::shared_ptr<const Analyzer::Constant>>
const& constant_owned)
const {
131 llvm::PointerType::get(
get_int_type(8, executor->cgen_state_->context_), 0);
143 executor->cgen_state_->ir_builder_.CreateIntToPtr(zero_lvs.front(), pi8_ty);
153 auto to_raw_ptr = [](
const auto& ptr) {
return ptr.get(); };
154 auto begin = boost::make_transform_iterator(constant_owned.begin(), to_raw_ptr);
155 auto end = boost::make_transform_iterator(constant_owned.end(), to_raw_ptr);
156 std::vector<const Analyzer::Constant*> bitmap_constants(begin, end);
157 const auto bitset_handle_lvs =
159 CHECK_EQ(
size_t(1), bitset_handle_lvs.size());
160 params.
bitmap_ptr_lv = executor->cgen_state_->ir_builder_.CreateIntToPtr(
161 bitset_handle_lvs.front(), pi8_ty);
167 auto cgen_state = executor->getCgenStatePtr();
169 std::vector<std::shared_ptr<const Analyzer::Constant>> constants_owned;
170 for (
const auto bitset :
bitsets_) {
171 const int64_t bitset_handle =
reinterpret_cast<int64_t
>(bitset);
174 CHECK(bitset_handle_literal);
176 constants_owned.push_back(bitset_handle_literal);
178 const auto needle_i64 = cgen_state->castToTypeIn(needle, 64);
179 const auto null_bool_val =
182 return cgen_state->emitCall(
"bit_is_set",
183 {func_params.bitmap_ptr_lv,
185 func_params.min_val_lv,
186 func_params.max_val_lv,
187 func_params.null_val_lv,
188 cgen_state->llInt(null_bool_val)});
BitIsSetParams prepareBitIsSetParams(Executor *executor, std::vector< std::shared_ptr< const Analyzer::Constant >> const &constant_owned) const
std::vector< llvm::Value * > hoistLiteral(CodeGenerator *code_generator, CompilationOptions const &co, Datum d, SQLTypeInfo type, size_t num_devices_to_hoist_literal)
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)
llvm::Value * null_val_lv
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
llvm::Value * bitmap_ptr_lv
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)
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, CompilationOptions const &co)
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)