Exemplo n.º 1
0
void TableScanTranslator::ScanConsumer::FilterRowsByVisibility(
    CodeGen &codegen, llvm::Value *tid_start, llvm::Value *tid_end,
    Vector &selection_vector) const {
  llvm::Value *executor_context_ptr =
      translator_.GetCompilationContext().GetExecutorContextPtr();
  llvm::Value *txn = codegen.Call(ExecutorContextProxy::GetTransaction,
                                  {executor_context_ptr});
  llvm::Value *raw_sel_vec = selection_vector.GetVectorPtr();

  // Invoke TransactionRuntime::PerformRead(...)
  llvm::Value *out_idx =
      codegen.Call(TransactionRuntimeProxy::PerformVectorizedRead,
                   {txn, tile_group_ptr_, tid_start, tid_end, raw_sel_vec});
  selection_vector.SetNumElements(out_idx);
}
Exemplo n.º 2
0
void Sorter::SortTopKParallel(CodeGen &codegen, llvm::Value *sorter_ptr,
                              llvm::Value *thread_states,
                              uint32_t sorter_offset, uint64_t top_k) const {
  auto *offset = codegen.Const32(sorter_offset);
  codegen.Call(SorterProxy::SortTopKParallel,
               {sorter_ptr, thread_states, offset, codegen.Const64(top_k)});
}
Exemplo n.º 3
0
void Sorter::Init(CodeGen &codegen, llvm::Value *sorter_ptr,
                  llvm::Value *executor_ctx,
                  llvm::Value *comparison_func) const {
  auto *tuple_size = codegen.Const32(storage_format_.GetStorageSize());
  codegen.Call(SorterProxy::Init,
               {sorter_ptr, executor_ctx, comparison_func, tuple_size});
}
Exemplo n.º 4
0
void Sorter::StoreTupleForTopK(CodeGen &codegen, llvm::Value *sorter_ptr,
                               const std::vector<codegen::Value> &tuple,
                               uint64_t top_k) const {
  // Allocate room
  auto *space = codegen.Call(SorterProxy::StoreTupleForTopK,
                             {sorter_ptr, codegen.Const64(top_k)});

  // Serialize tuple
  UpdateableStorage::NullBitmap null_bitmap(codegen, storage_format_, space);
  for (uint32_t col_id = 0; col_id < tuple.size(); col_id++) {
    storage_format_.SetValue(codegen, space, col_id, tuple[col_id],
                             null_bitmap);
  }
  null_bitmap.WriteBack(codegen);

  // Finish
  codegen.Call(SorterProxy::StoreTupleForTopKFinish,
               {sorter_ptr, codegen.Const64(top_k)});
}
Exemplo n.º 5
0
void BufferAccessor::Append(CodeGen &codegen, llvm::Value *buffer_ptr,
                            const std::vector<codegen::Value> &tuple) const {
  auto *size = codegen.Const32(storage_format_.GetStorageSize());
  auto *space = codegen.Call(BufferProxy::Append, {buffer_ptr, size});

  // Now, individually store the attributes of the tuple into the free space
  UpdateableStorage::NullBitmap null_bitmap(codegen, storage_format_, space);
  for (uint32_t col_id = 0; col_id < tuple.size(); col_id++) {
    storage_format_.SetValue(codegen, space, col_id, tuple[col_id],
                             null_bitmap);
  }
  null_bitmap.WriteBack(codegen);
}
Exemplo n.º 6
0
void Sorter::StoreTuple(CodeGen &codegen, llvm::Value *sorter_ptr,
                        const std::vector<codegen::Value> &tuple) const {
  // First, call Sorter::StoreInputTuple() to get a handle to a contiguous
  // chunk of free space large enough to materialize a single tuple.
  auto *space = codegen.Call(SorterProxy::StoreTuple, {sorter_ptr});

  // Now, individually store the attributes of the tuple into the free space
  UpdateableStorage::NullBitmap null_bitmap(codegen, storage_format_, space);
  for (uint32_t col_id = 0; col_id < tuple.size(); col_id++) {
    storage_format_.SetValue(codegen, space, col_id, tuple[col_id],
                             null_bitmap);
  }
  null_bitmap.WriteBack(codegen);
}
Exemplo n.º 7
0
//===----------------------------------------------------------------------===//
// Here, we discover the layout of every column that will be accessed. A
// column's layout includes three pieces of information:
//
// 1. The starting memory address (where the first value of the column is)
// 2. The stride length
// 3. Whether the column is in columnar layout
//===----------------------------------------------------------------------===//
std::vector<TileGroup::ColumnLayout> TileGroup::GetColumnLayouts(
    CodeGen &codegen, llvm::Value *tile_group_ptr,
    llvm::Value *column_layout_infos) const {
  // Call RuntimeFunctions::GetTileGroupLayout()
  uint32_t num_cols = schema_.GetColumnCount();
  codegen.Call(
      RuntimeFunctionsProxy::GetTileGroupLayout,
      {tile_group_ptr, column_layout_infos, codegen.Const32(num_cols)});

  // Collect <start, stride, is_columnar> triplets of all columns
  std::vector<TileGroup::ColumnLayout> layouts;
  auto *layout_type = ColumnLayoutInfoProxy::GetType(codegen);
  for (uint32_t col_id = 0; col_id < num_cols; col_id++) {
    auto *start = codegen->CreateLoad(codegen->CreateConstInBoundsGEP2_32(
        layout_type, column_layout_infos, col_id, 0));
    auto *stride = codegen->CreateLoad(codegen->CreateConstInBoundsGEP2_32(
        layout_type, column_layout_infos, col_id, 1));
    auto *columnar = codegen->CreateLoad(codegen->CreateConstInBoundsGEP2_32(
        layout_type, column_layout_infos, col_id, 2));
    layouts.push_back(ColumnLayout{col_id, start, stride, columnar});
  }
  return layouts;
}
Exemplo n.º 8
0
void BufferAccessor::Destroy(CodeGen &codegen, llvm::Value *buffer_ptr) const {
  codegen.Call(BufferProxy::Destroy, {buffer_ptr});
}
Exemplo n.º 9
0
void Sorter::Sort(CodeGen &codegen, llvm::Value *sorter_ptr) const {
  codegen.Call(SorterProxy::Sort, {sorter_ptr});
}
Exemplo n.º 10
0
// Just make a call to util::Sorter::Sort(...). This actually sorts the data
// that has been inserted into the sorter instance.
void Sorter::Sort(CodeGen &codegen, llvm::Value *sorter_ptr) const {
  //  auto *sort_func = SorterProxy::_Sort::GetFunction(codegen);
  codegen.Call(SorterProxy::Sort, {sorter_ptr});
}