mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes
m::wasm::Buffer< IsGlobal > Struct Template Reference

Buffers tuples by materializing them into memory. More...

#include <WasmUtil.hpp>

Collaboration diagram for m::wasm::Buffer< IsGlobal >:
[legend]

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 ()
 
Bufferoperator= (Buffer &&)=default
 
const Schemaschema () const
 Returns the schema of the buffer.
 
const storage::DataLayoutlayout () 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 > >
 

‍parameter type for proxy creation and pipeline resuming methods


 

Private Attributes

std::reference_wrapper< const Schemaschema_
 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_
 

‍function to resume pipeline for entire buffer; expects base address and size of buffer as parameters


 

Detailed Description

template<bool IsGlobal>
struct m::wasm::Buffer< IsGlobal >

Buffers tuples by materializing them into memory.

Definition at line 1069 of file WasmUtil.hpp.

Member Typedef Documentation

◆ param_t

template<bool IsGlobal>
using m::wasm::Buffer< IsGlobal >::param_t = std::optional<std::reference_wrapper<const Schema> >
private

‍parameter type for proxy creation and pipeline resuming methods

Definition at line 1073 of file WasmUtil.hpp.

Constructor & Destructor Documentation

◆ Buffer() [1/3]

template<bool IsGlobal>
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().

◆ Buffer() [2/3]

template<bool IsGlobal>
m::wasm::Buffer< IsGlobal >::Buffer ( const Buffer< IsGlobal > &  )
delete

◆ Buffer() [3/3]

template<bool IsGlobal>
m::wasm::Buffer< IsGlobal >::Buffer ( Buffer< IsGlobal > &&  )
default

◆ ~Buffer()

template<bool IsGlobal>
Buffer::~Buffer

Definition at line 2520 of file WasmUtil.cpp.

References m::wasm::Module::Allocator, and M_insist.

Member Function Documentation

◆ base_address()

template<bool IsGlobal>
Ptr< void > m::wasm::Buffer< IsGlobal >::base_address ( ) const
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().

◆ consume()

template<bool IsGlobal>
void Buffer::consume

Emits code to store the current tuple into the buffer.

The behaviour depends on whether the buffer is finite:

  • finite: If the buffer is full, resumes the pipeline for each tuple in the buffer and clears the buffer afterwards.
  • infinite: Potentially resizes the buffer but never resumes the pipeline (must be done explicitly by calling 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().

◆ create_load_proxy()

template<bool IsGlobal>
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().

◆ create_store_proxy()

template<bool IsGlobal>
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.

◆ create_swap_proxy()

template<bool IsGlobal>
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().

◆ execute_pipeline()

template<bool IsGlobal>
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.

◆ execute_pipeline_inline()

template<bool IsGlobal>
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.

◆ layout()

template<bool IsGlobal>
const storage::DataLayout & m::wasm::Buffer< IsGlobal >::layout ( ) const
inline

Returns the layout of the buffer.

Definition at line 1108 of file WasmUtil.hpp.

References m::wasm::Buffer< IsGlobal >::layout_.

◆ operator=()

template<bool IsGlobal>
Buffer & m::wasm::Buffer< IsGlobal >::operator= ( Buffer< IsGlobal > &&  )
default

◆ resume_pipeline()

template<bool IsGlobal>
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().

◆ resume_pipeline_inline()

template<bool IsGlobal>
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.

◆ schema()

template<bool IsGlobal>
const Schema & m::wasm::Buffer< IsGlobal >::schema ( ) const
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().

◆ setup()

template<bool IsGlobal>
void Buffer::setup

Performs the setup of all local variables of this buffer (by reading them from the global backups iff.

Template Parameters
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().

◆ setup_base_address()

template<bool IsGlobal>
void m::wasm::Buffer< IsGlobal >::setup_base_address ( )
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().

◆ size()

template<bool IsGlobal>
U32x1 m::wasm::Buffer< IsGlobal >::size ( ) const
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().

◆ teardown()

template<bool IsGlobal>
void Buffer::teardown

Performs the teardown of all local variables of this buffer (by storing them into the global backups iff.

Template Parameters
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().

◆ teardown_base_address()

template<bool IsGlobal>
void m::wasm::Buffer< IsGlobal >::teardown_base_address ( )
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().

Field Documentation

◆ base_address_

template<bool IsGlobal>
std::optional<Var<Ptr<void> > > m::wasm::Buffer< IsGlobal >::base_address_
private

◆ capacity_

template<bool IsGlobal>
std::optional<Var<U32x1> > m::wasm::Buffer< IsGlobal >::capacity_
private

dynamic capacity of infinite buffer, default initialized to 0

Definition at line 1080 of file WasmUtil.hpp.

◆ first_iteration_

template<bool IsGlobal>
std::optional<Var<Boolx1> > m::wasm::Buffer< IsGlobal >::first_iteration_
private

flag to indicate first loop iteration for infinite buffer

Definition at line 1081 of file WasmUtil.hpp.

◆ layout_

template<bool IsGlobal>
storage::DataLayout m::wasm::Buffer< IsGlobal >::layout_
private

◆ load_simdfied_

template<bool IsGlobal>
bool m::wasm::Buffer< IsGlobal >::load_simdfied_ = false
private

flag whether to load from the buffer in SIMDfied manner

Definition at line 1077 of file WasmUtil.hpp.

◆ pipeline_

template<bool IsGlobal>
pipeline_t m::wasm::Buffer< IsGlobal >::pipeline_
private

remaining actual pipeline

Definition at line 1084 of file WasmUtil.hpp.

◆ resume_pipeline_

template<bool IsGlobal>
std::optional<FunctionProxy<void(void*, uint32_t)> > m::wasm::Buffer< IsGlobal >::resume_pipeline_
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.

◆ schema_

template<bool IsGlobal>
std::reference_wrapper<const Schema> m::wasm::Buffer< IsGlobal >::schema_
private

schema of buffer

Definition at line 1075 of file WasmUtil.hpp.

Referenced by m::wasm::Buffer< IsGlobal >::schema().

◆ setup_

template<bool IsGlobal>
setup_t m::wasm::Buffer< IsGlobal >::setup_
private

remaining pipeline initializations

Definition at line 1083 of file WasmUtil.hpp.

◆ size_

template<bool IsGlobal>
std::optional<Var<U32x1> > m::wasm::Buffer< IsGlobal >::size_
private

current size of buffer, default initialized to 0

Definition at line 1079 of file WasmUtil.hpp.

Referenced by m::wasm::Buffer< IsGlobal >::size().

◆ storage_

template<bool IsGlobal>
buffer_storage<IsGlobal> m::wasm::Buffer< IsGlobal >::storage_
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().

◆ teardown_

template<bool IsGlobal>
teardown_t m::wasm::Buffer< IsGlobal >::teardown_
private

remaining pipeline post-processing

Definition at line 1085 of file WasmUtil.hpp.


The documentation for this struct was generated from the following files: