![]() |
mutable
A Database System for Research and Fast Prototyping
|
Buffers tuples by materializing them into memory. More...
#include <WasmUtil.hpp>
Public Member Functions | |
Buffer (const Schema &schema, const storage::DataLayoutFactory &factory, bool load_simdfied=false, std::size_t num_tuples=0, setup_t setup=setup_t::Make_Without_Parent(), pipeline_t pipeline=pipeline_t(), teardown_t teardown=teardown_t::Make_Without_Parent()) | |
Creates a buffer for num_tuples tuples (0 means infinite) of schema schema using the data layout created by factory to temporarily materialize tuples before resuming with the remaining pipeline initializations setup , the actual pipeline pipeline , and the post-processing teardown . | |
Buffer (const Buffer &)=delete | |
Buffer (Buffer &&)=default | |
~Buffer () | |
Buffer & | operator= (Buffer &&)=default |
const Schema & | schema () const |
Returns the schema of the buffer. | |
const storage::DataLayout & | layout () const |
Returns the layout of the buffer. | |
Ptr< void > | base_address () const |
Returns the base address of the buffer. | |
U32x1 | size () const |
Returns the current size of the buffer. | |
buffer_load_proxy_t< IsGlobal > | create_load_proxy (param_t tuple_value_schema=param_t(), param_t tuple_addr_schema=param_t()) const |
Creates and returns a proxy object to load value tuples of schema tuple_value_schema (default: entire tuples) and address tuples of schema tuple_addr_schema (default: empty tuples) from the buffer. | |
buffer_store_proxy_t< IsGlobal > | create_store_proxy (param_t tuple_schema=param_t()) const |
Creates and returns a proxy object to store tuples of schema tuple_schema (default: entire tuples) to the buffer. | |
buffer_swap_proxy_t< IsGlobal > | create_swap_proxy (param_t tuple_schema=param_t()) const |
Creates and returns a proxy object to swap tuples of schema tuple_schema (default: entire tuples) in the buffer. | |
void | setup () |
Performs the setup of all local variables of this buffer (by reading them from the global backups iff. | |
void | teardown () |
Performs the teardown of all local variables of this buffer (by storing them into the global backups iff. | |
void | setup_base_address () |
Performs the setup of the local base address of this buffer by reading it from the global backup. | |
void | teardown_base_address () |
Performs the teardown of the local base address of this buffer by destroying it but without storing it into the global backup. | |
void | resume_pipeline (param_t tuple_value_schema=param_t(), param_t tuple_addr_schema=param_t()) const |
Emits code into a separate function to resume the pipeline for each value tuple of schema tuple_value_schema (default: entire tuples) and address tuple of schema tuple_addr_schema (default: empty tuples) in the buffer. | |
void | resume_pipeline_inline (param_t tuple_value_schema=param_t(), param_t tuple_addr_schema=param_t()) const |
Emits code inline to resume the pipeline for each value tuple of schema tuple_value_schema (default: entire tuples) and address tuple of schema tuple_addr_schema (default: empty tuples) in the buffer. | |
void | execute_pipeline (setup_t setup, pipeline_t pipeline, teardown_t teardown, param_t tuple_value_schema=param_t(), param_t tuple_addr_schema=param_t()) const |
Emits code into a separate function to execute the give pipeline pipeline for each value tuple of schema tuple_value_schema (default: entire tuples) and address tuple of schema tuple_addr_schema (default: empty tuples) in the buffer. | |
void | execute_pipeline_inline (setup_t setup, pipeline_t pipeline, teardown_t teardown, param_t tuple_value_schema=param_t(), param_t tuple_addr_schema=param_t()) const |
Emits code inline to execute the given pipeline pipeline for each value tuple of schema tuple_value_schema (default: entire tuples) and address tuple of schema tuple_addr_schema (default: empty tuples) in the buffer. | |
void | consume () |
Emits code to store the current tuple into the buffer. | |
Private Types | |
using | param_t = std::optional< std::reference_wrapper< const Schema > > |
| |
Private Attributes | |
std::reference_wrapper< const Schema > | schema_ |
schema of buffer | |
storage::DataLayout | layout_ |
data layout of buffer | |
bool | load_simdfied_ = false |
flag whether to load from the buffer in SIMDfied manner | |
std::optional< Var< Ptr< void > > > | base_address_ |
base address of buffer | |
std::optional< Var< U32x1 > > | size_ |
current size of buffer, default initialized to 0 | |
std::optional< Var< U32x1 > > | capacity_ |
dynamic capacity of infinite buffer, default initialized to 0 | |
std::optional< Var< Boolx1 > > | first_iteration_ |
flag to indicate first loop iteration for infinite buffer | |
buffer_storage< IsGlobal > | storage_ |
if IsGlobal , contains backups for base address, capacity, and size | |
setup_t | setup_ |
remaining pipeline initializations | |
pipeline_t | pipeline_ |
remaining actual pipeline | |
teardown_t | teardown_ |
remaining pipeline post-processing | |
std::optional< FunctionProxy< void(void *, uint32_t)> > | resume_pipeline_ |
| |
Buffers tuples by materializing them into memory.
Definition at line 1069 of file WasmUtil.hpp.
|
private |
parameter type for proxy creation and pipeline resuming methods
Definition at line 1073 of file WasmUtil.hpp.
Buffer::Buffer | ( | const Schema & | schema, |
const storage::DataLayoutFactory & | factory, | ||
bool | load_simdfied = false , |
||
std::size_t | num_tuples = 0 , |
||
setup_t | setup = setup_t::Make_Without_Parent() , |
||
pipeline_t | pipeline = pipeline_t() , |
||
teardown_t | teardown = teardown_t::Make_Without_Parent() |
||
) |
Creates a buffer for num_tuples
tuples (0 means infinite) of schema schema
using the data layout created by factory
to temporarily materialize tuples before resuming with the remaining pipeline initializations setup
, the actual pipeline pipeline
, and the post-processing teardown
.
For global finite buffers, emits code to pre-allocate entire buffer into the current block.
Definition at line 2494 of file WasmUtil.cpp.
References m::wasm::Module::Allocator, m::storage::DataLayout::child(), m::storage::DataLayout::is_finite(), m::wasm::Buffer< IsGlobal >::layout_, M_insist, m::Schema::num_entries(), m::storage::DataLayout::num_tuples(), m::storage::DataLayout::Node::num_tuples(), m::wasm::Buffer< IsGlobal >::schema(), m::wasm::Buffer< IsGlobal >::storage_, and m::storage::DataLayout::stride_in_bits().
|
delete |
|
default |
Buffer::~Buffer |
Definition at line 2520 of file WasmUtil.cpp.
References m::wasm::Module::Allocator, and M_insist.
|
inline |
Returns the base address of the buffer.
Definition at line 1110 of file WasmUtil.hpp.
References m::wasm::Buffer< IsGlobal >::base_address_, M_insist, and m::wasm::Buffer< IsGlobal >::storage_.
Referenced by write_result_set().
void Buffer::consume |
Emits code to store the current tuple into the buffer.
The behaviour depends on whether the buffer is finite:
resume_pipeline()
). Predication is supported, i.e. the current tuple is always written in the buffer but can only loaded from it later iff the predication predicate is fulfilled. Definition at line 2910 of file WasmUtil.cpp.
References m::wasm::Module::Allocator, m::wasm::Block::attach_to_current(), m::wasm::compile_store_sequential_single_pass(), ELSE, m::wasm::CodeGenContext::Get(), IF, M_insist, m::wasm::num_simd_lanes, m::wasm::CodeGenContext::num_simd_lanes(), m::wasm::U, and Wasm_insist.
Referenced by m::wasm::Quicksort< CmpPredicated >::execute(), m::Match< wasm::Scan< SIMDfied > >::execute(), m::execute_buffered(), and write_result_set().
buffer_load_proxy_t< IsGlobal > Buffer::create_load_proxy | ( | param_t | tuple_value_schema = param_t() , |
param_t | tuple_addr_schema = param_t() |
||
) | const |
Creates and returns a proxy object to load value tuples of schema tuple_value_schema
(default: entire tuples) and address tuples of schema tuple_addr_schema
(default: empty tuples) from the buffer.
Definition at line 2535 of file WasmUtil.cpp.
References M_insist.
Referenced by m::wasm::quicksort().
buffer_store_proxy_t< IsGlobal > Buffer::create_store_proxy | ( | param_t | tuple_schema = param_t() | ) | const |
Creates and returns a proxy object to store tuples of schema tuple_schema
(default: entire tuples) to the buffer.
Definition at line 2557 of file WasmUtil.cpp.
References M_insist, and m::storage::tuple_schema.
buffer_swap_proxy_t< IsGlobal > Buffer::create_swap_proxy | ( | param_t | tuple_schema = param_t() | ) | const |
Creates and returns a proxy object to swap tuples of schema tuple_schema
(default: entire tuples) in the buffer.
Definition at line 2570 of file WasmUtil.cpp.
References M_insist, and m::storage::tuple_schema.
Referenced by m::wasm::quicksort().
void Buffer::execute_pipeline | ( | setup_t | setup, |
pipeline_t | pipeline, | ||
teardown_t | teardown, | ||
param_t | tuple_value_schema = param_t() , |
||
param_t | tuple_addr_schema = param_t() |
||
) | const |
Emits code into a separate function to execute the give pipeline pipeline
for each value tuple of schema tuple_value_schema
(default: entire tuples) and address tuple of schema tuple_addr_schema
(default: empty tuples) in the buffer.
Used to explicitly execute a given pipeline.
Definition at line 2761 of file WasmUtil.cpp.
References m::wasm::and, m::wasm::compile_load_sequential(), FUNCTION, m::wasm::CodeGenContext::Get(), m::storage::get_num_simd_lanes(), M_insist, m::wasm::num_simd_lanes, m::wasm::CodeGenContext::num_simd_lanes_preferred(), PARAMETER, m::wasm::CodeGenContext::scoped_environment(), m::wasm::CodeGenContext::set_num_simd_lanes(), and WHILE.
void Buffer::execute_pipeline_inline | ( | setup_t | setup, |
pipeline_t | pipeline, | ||
teardown_t | teardown, | ||
param_t | tuple_value_schema = param_t() , |
||
param_t | tuple_addr_schema = param_t() |
||
) | const |
Emits code inline to execute the given pipeline pipeline
for each value tuple of schema tuple_value_schema
(default: entire tuples) and address tuple of schema tuple_addr_schema
(default: empty tuples) in the buffer.
Due to inlining the current Environment
must not be cleared and this method should be used for n-ary operators. Used to explicitly execute a given pipeline. Predication is supported, i.e. if the predication predicate is not fulfilled, no tuples will be loaded and thus the pipeline will not be executed.
Definition at line 2833 of file WasmUtil.cpp.
References m::wasm::and, m::wasm::compile_load_sequential(), m::wasm::CodeGenContext::Get(), m::storage::get_num_simd_lanes(), M_CONSTEXPR_COND, M_insist, m::wasm::num_simd_lanes, m::wasm::CodeGenContext::num_simd_lanes_preferred(), m::wasm::Select(), m::wasm::CodeGenContext::set_num_simd_lanes(), m::wasm::U, and WHILE.
|
inline |
Returns the layout of the buffer.
Definition at line 1108 of file WasmUtil.hpp.
References m::wasm::Buffer< IsGlobal >::layout_.
|
default |
void Buffer::resume_pipeline | ( | param_t | tuple_value_schema = param_t() , |
param_t | tuple_addr_schema = param_t() |
||
) | const |
Emits code into a separate function to resume the pipeline for each value tuple of schema tuple_value_schema
(default: entire tuples) and address tuple of schema tuple_addr_schema
(default: empty tuples) in the buffer.
Used to explicitly resume pipeline for infinite or partially filled buffers.
Definition at line 2679 of file WasmUtil.cpp.
References m::wasm::and, m::wasm::compile_load_sequential(), FUNCTION, m::wasm::CodeGenContext::Get(), m::storage::get_num_simd_lanes(), M_insist, m::wasm::num_simd_lanes, m::wasm::CodeGenContext::num_simd_lanes_preferred(), PARAMETER, m::wasm::CodeGenContext::scoped_environment(), m::wasm::CodeGenContext::set_num_simd_lanes(), and WHILE.
Referenced by m::wasm::Quicksort< CmpPredicated >::execute(), m::Match< wasm::Scan< SIMDfied > >::execute(), and m::execute_buffered().
void Buffer::resume_pipeline_inline | ( | param_t | tuple_value_schema = param_t() , |
param_t | tuple_addr_schema = param_t() |
||
) | const |
Emits code inline to resume the pipeline for each value tuple of schema tuple_value_schema
(default: entire tuples) and address tuple of schema tuple_addr_schema
(default: empty tuples) in the buffer.
Due to inlining the current Environment
must not be cleared and this method should be used for n-ary operators. Used to explicitly resume pipeline for infinite or partially filled buffers. Predication is supported, i.e. if the predication predicate is not fulfilled, no tuples will be loaded and thus the pipeline will not be resumed.
Definition at line 2755 of file WasmUtil.cpp.
|
inline |
Returns the schema of the buffer.
Definition at line 1106 of file WasmUtil.hpp.
References m::wasm::Buffer< IsGlobal >::schema_.
Referenced by m::wasm::Buffer< IsGlobal >::Buffer(), and m::wasm::quicksort().
void Buffer::setup |
Performs the setup of all local variables of this buffer (by reading them from the global backups iff.
IsGlobal) | for a write access. Must be called before any call to consume() . |
Definition at line 2583 of file WasmUtil.cpp.
References m::wasm::Module::Allocator, ELSE, IF, M_insist, and m::wasm::U.
Referenced by m::wasm::Quicksort< CmpPredicated >::execute(), m::Match< wasm::Scan< SIMDfied > >::execute(), m::execute_buffered(), and write_result_set().
|
inline |
Performs the setup of the local base address of this buffer by reading it from the global backup.
Definition at line 1147 of file WasmUtil.hpp.
References m::wasm::Buffer< IsGlobal >::base_address_, m::storage::DataLayout::is_finite(), m::wasm::Buffer< IsGlobal >::layout_, M_insist, m::wasm::Buffer< IsGlobal >::storage_, m::wasm::U, and Wasm_insist.
Referenced by m::wasm::quicksort().
|
inline |
Returns the current size of the buffer.
Definition at line 1119 of file WasmUtil.hpp.
References M_insist, m::wasm::Buffer< IsGlobal >::size_, and m::wasm::Buffer< IsGlobal >::storage_.
Referenced by m::wasm::quicksort(), and write_result_set().
void Buffer::teardown |
Performs the teardown of all local variables of this buffer (by storing them into the global backups iff.
IsGlobal) | for a write access. Must be called after all calls to consume() . |
Definition at line 2642 of file WasmUtil.cpp.
References m::wasm::Module::Allocator, and M_insist.
Referenced by m::wasm::Quicksort< CmpPredicated >::execute(), m::Match< wasm::Scan< SIMDfied > >::execute(), m::execute_buffered(), and write_result_set().
|
inline |
Performs the teardown of the local base address of this buffer by destroying it but without storing it into the global backup.
Definition at line 1157 of file WasmUtil.hpp.
References m::wasm::Buffer< IsGlobal >::base_address_, and M_insist.
Referenced by m::wasm::quicksort().
|
private |
base address of buffer
Definition at line 1078 of file WasmUtil.hpp.
Referenced by m::wasm::Buffer< IsGlobal >::base_address(), m::wasm::Buffer< IsGlobal >::setup_base_address(), and m::wasm::Buffer< IsGlobal >::teardown_base_address().
|
private |
dynamic capacity of infinite buffer, default initialized to 0
Definition at line 1080 of file WasmUtil.hpp.
|
private |
flag to indicate first loop iteration for infinite buffer
Definition at line 1081 of file WasmUtil.hpp.
|
private |
data layout of buffer
Definition at line 1076 of file WasmUtil.hpp.
Referenced by m::wasm::Buffer< IsGlobal >::Buffer(), m::wasm::Buffer< IsGlobal >::layout(), and m::wasm::Buffer< IsGlobal >::setup_base_address().
|
private |
flag whether to load from the buffer in SIMDfied manner
Definition at line 1077 of file WasmUtil.hpp.
|
private |
remaining actual pipeline
Definition at line 1084 of file WasmUtil.hpp.
|
mutableprivate |
function to resume pipeline for entire buffer; expects base address and size of buffer as parameters
Definition at line 1087 of file WasmUtil.hpp.
|
private |
schema of buffer
Definition at line 1075 of file WasmUtil.hpp.
Referenced by m::wasm::Buffer< IsGlobal >::schema().
|
private |
remaining pipeline initializations
Definition at line 1083 of file WasmUtil.hpp.
|
private |
current size of buffer, default initialized to 0
Definition at line 1079 of file WasmUtil.hpp.
Referenced by m::wasm::Buffer< IsGlobal >::size().
|
private |
if IsGlobal
, contains backups for base address, capacity, and size
Definition at line 1082 of file WasmUtil.hpp.
Referenced by m::wasm::Buffer< IsGlobal >::base_address(), m::wasm::Buffer< IsGlobal >::Buffer(), m::wasm::Buffer< IsGlobal >::setup_base_address(), and m::wasm::Buffer< IsGlobal >::size().
|
private |
remaining pipeline post-processing
Definition at line 1085 of file WasmUtil.hpp.