docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
sdfg::codegen::LibraryNodeDispatcher Class Reference

Base class for library node code generation dispatchers. More...

#include <sdfg/codegen/dispatchers/block_dispatcher.h>

Inherited by sdfg::codegen::LibraryNodeDispatcherBase< sdfg::math::blas::GEMMNode >, sdfg::codegen::LibraryNodeDispatcherBase< NodeType >, sdfg::cuda::CUDADataOffloadingNodeDispatcher, sdfg::cuda::blas::BatchedGEMMNodeDispatcher_CUBLASWithTransfers, sdfg::cuda::blas::BatchedGEMMNodeDispatcher_CUBLASWithoutTransfers, sdfg::cuda::blas::DotNodeDispatcher_CUBLASWithTransfers, sdfg::cuda::blas::DotNodeDispatcher_CUBLASWithoutTransfers, sdfg::cuda::blas::GEMMNodeDispatcher_CUBLASWithTransfers, sdfg::cuda::blas::GEMMNodeDispatcher_CUBLASWithoutTransfers, sdfg::cuda::stdlib::MemcpyNodeDispatcher_CUDAWithTransfers, sdfg::cuda::stdlib::MemcpyNodeDispatcher_CUDAWithoutTransfers, sdfg::cuda::stdlib::MemsetNodeDispatcher_CUDAWithTransfers, sdfg::cuda::stdlib::MemsetNodeDispatcher_CUDAWithoutTransfers, sdfg::cuda::tensor::SoftmaxNodeDispatcher_CUDAWithTransfers, sdfg::cuda::tensor::SoftmaxNodeDispatcher_CUDAWithoutTransfers, sdfg::cuda::tiles::PipelineCommitNodeDispatcher, sdfg::cuda::tiles::PipelineWaitNodeDispatcher, sdfg::cuda::tiles::TileCopyNodeDispatcher, sdfg::data_flow::AtomicScalarOpNodeDispatcher, sdfg::data_flow::CallNodeDispatcher, sdfg::data_flow::InvokeNodeDispatcher, sdfg::data_flow::LoadConstNodeDispatcher, sdfg::data_flow::MetadataDispatcher, sdfg::gpu::BarrierLocalNodeDispatcher, sdfg::gpu::GpuMmaNodeDispatcher, sdfg::gpu::GpuTileArrivalDispatcher, sdfg::math::blas::DotNodeDispatcher_BLAS, sdfg::math::blas::GEMMNodeDispatcher_BLAS, sdfg::math::cmath::CMathNodeDispatcher, sdfg::offloading::ExternalDataOffloadingNodeDispatcher, sdfg::rocm::ROCMDataOffloadingNodeDispatcher, sdfg::rocm::blas::BatchedGEMMNodeDispatcher_ROCMBLASWithTransfers, sdfg::rocm::blas::BatchedGEMMNodeDispatcher_ROCMBLASWithoutTransfers, sdfg::rocm::blas::DotNodeDispatcher_ROCMBLASWithTransfers, sdfg::rocm::blas::DotNodeDispatcher_ROCMBLASWithoutTransfers, sdfg::rocm::blas::GEMMNodeDispatcher_ROCMBLASWithTransfers, sdfg::rocm::blas::GEMMNodeDispatcher_ROCMBLASWithoutTransfers, sdfg::rocm::stdlib::MemcpyNodeDispatcher_ROCMWithTransfers, sdfg::rocm::stdlib::MemcpyNodeDispatcher_ROCMWithoutTransfers, sdfg::rocm::stdlib::MemsetNodeDispatcher_ROCMWithTransfers, sdfg::rocm::stdlib::MemsetNodeDispatcher_ROCMWithoutTransfers, sdfg::rocm::tiles::PipelineCommitNodeDispatcher, sdfg::rocm::tiles::PipelineWaitNodeDispatcher, sdfg::rocm::tiles::TileCopyNodeDispatcher, sdfg::stdlib::AllocaNodeDispatcher, sdfg::stdlib::AssertNodeDispatcher, sdfg::stdlib::CallocNodeDispatcher, sdfg::stdlib::FreeNodeDispatcher, sdfg::stdlib::MallocNodeDispatcher, sdfg::stdlib::MemcpyNodeDispatcher, sdfg::stdlib::MemmoveNodeDispatcher, sdfg::stdlib::MemsetNodeDispatcher, sdfg::stdlib::TrapNodeDispatcher, sdfg::stdlib::UnreachableNodeDispatcher, and sdfg::tiles::TileCopyNodeDispatcher.

Public Member Functions

 LibraryNodeDispatcher (LanguageExtension &language_extension, const Function &function, const data_flow::DataFlowGraph &data_flow_graph, const data_flow::LibraryNode &node)
 Construct a library node dispatcher.
virtual ~LibraryNodeDispatcher ()=default
virtual bool begin_node (PrettyPrinter &stream)
 Begin code generation for the node.
virtual void end_node (PrettyPrinter &stream, bool has_declaration)
 End code generation for the node.
virtual void dispatch (PrettyPrinter &stream, PrettyPrinter &globals_stream, CodeSnippetFactory &library_snippet_factory)
 Dispatch the library node to code.
virtual void dispatch_code (PrettyPrinter &stream, PrettyPrinter &globals_stream, CodeSnippetFactory &library_snippet_factory)
 Generate the operation-specific code.
virtual void dispatch_code_with_edges (CodegenOutput &out, std::vector< DispatchInput > &inputs, std::vector< DispatchOutput > &outputs)
virtual InstrumentationInfo instrumentation_info () const
 Get instrumentation information for this node.

Protected Member Functions

void require_locally_modifiable_var (CodegenOutput &out, DispatchInput &input) const
 Ensure that [input] points to a local copy that can be changed without modifying the actual source of the input Should only be needed to ensure that legacy [dispatch_code] code can act as before, where it always was a copy.
void pre_allocate_output (CodegenOutput &out, DispatchOutput &output, const std::string &var_name) const
 Declare a variable of the type of the output and with the name "var_name".
void register_output (DispatchOutput &output, const std::string &result_identifier) const
 The dispatcher as created an output that is identified by [result_identifier].
void copy_output (CodegenOutput &out, const DispatchOutput &output, const data_flow::Memlet &oedge) const
 This is a temporary & hopefully short-lived workaround.

Protected Attributes

LanguageExtension & language_extension_
 Language extension for code generation.
const Function & function_
 Function context.
const data_flow::DataFlowGraph & data_flow_graph_
 Containing dataflow graph.
const data_flow::LibraryNode & node_
 Library node being dispatched.

Detailed Description

Base class for library node code generation dispatchers.

LibraryNodeDispatcher provides the interface for generating code from library nodes. Subclasses implement specific code generation for different library operations (BLAS calls, memory operations, etc.).

A modern impl overrides [dispatch_code_with_edges].

CodegenOutput is used as a wrapper around multiple args needed. This makes extending the args provided a simpler code-change. We expect this to also include state to handle data-flow edges in the future.

The base class collects all inputs and outputs and provides them. For inputs, this is 1:1 with edges, since outputs in dataflow can have multiple edges, no edge is attached to them. The dispatcher only needs to provide the output per connector, the base class will handle providing the output to all edges as needed.

Legacy code can still override the [dispatch_code] as before and is provided with almost the same environment of variables.

Note the class handles ptrs correctly, meaning there is no need to consider inputs and outputs overlapping in any way. If a pointer is provided as input, that can be used to change all the data it points to. A pointer output is only needed if a pointer is selected, created or modified. Not if the data behind is changed.

Constructor & Destructor Documentation

◆ LibraryNodeDispatcher()

sdfg::codegen::LibraryNodeDispatcher::LibraryNodeDispatcher ( LanguageExtension & language_extension,
const Function & function,
const data_flow::DataFlowGraph & data_flow_graph,
const data_flow::LibraryNode & node )

Construct a library node dispatcher.

Parameters
language_extensionLanguage extension for code generation
functionFunction context
data_flow_graphContaining dataflow graph
nodeLibrary node to dispatch

◆ ~LibraryNodeDispatcher()

virtual sdfg::codegen::LibraryNodeDispatcher::~LibraryNodeDispatcher ( )
virtualdefault

Member Function Documentation

◆ begin_node()

virtual bool sdfg::codegen::LibraryNodeDispatcher::begin_node ( PrettyPrinter & stream)
inlinevirtual

Begin code generation for the node.

Parameters
streamOutput stream for generated code
Returns
True if a declaration was generated

Reimplemented in sdfg::codegen::LibraryNodeDispatcherBase< NodeType >, and sdfg::codegen::LibraryNodeDispatcherBase< sdfg::math::blas::GEMMNode >.

◆ copy_output()

void sdfg::codegen::LibraryNodeDispatcher::copy_output ( CodegenOutput & out,
const DispatchOutput & output,
const data_flow::Memlet & oedge ) const
protected

This is a temporary & hopefully short-lived workaround.

For a sensible and flexible data flow graph you want to know the available data (by some unique ID, like the vertex IDs) And then just use those whenever they are declared as an input. Edges can possibly apply some on the fly transformations, like selects or casts. Access Nodes / whatever new modeling of memory writes & reads we then have, needs to dispatch whatever side effects they need themselves, just like lib-nodes do. This saves unneeded copying around which can cause issues and inadvertently remove or add side effects. Also makes the code redundant.

But this also requires a per-dataflow-graph state of data-handles-by-id. But this would also be what you would want to emit LLVM-IR directly

◆ dispatch()

virtual void sdfg::codegen::LibraryNodeDispatcher::dispatch ( PrettyPrinter & stream,
PrettyPrinter & globals_stream,
CodeSnippetFactory & library_snippet_factory )
virtual

◆ dispatch_code()

virtual void sdfg::codegen::LibraryNodeDispatcher::dispatch_code ( PrettyPrinter & stream,
PrettyPrinter & globals_stream,
CodeSnippetFactory & library_snippet_factory )
inlinevirtual

◆ dispatch_code_with_edges()

virtual void sdfg::codegen::LibraryNodeDispatcher::dispatch_code_with_edges ( CodegenOutput & out,
std::vector< DispatchInput > & inputs,
std::vector< DispatchOutput > & outputs )
virtual

Reimplemented in sdfg::cuda::blas::BatchedGEMMNodeDispatcher_CUBLASWithoutTransfers, sdfg::cuda::blas::BatchedGEMMNodeDispatcher_CUBLASWithTransfers, sdfg::cuda::CUDADataOffloadingNodeDispatcher, sdfg::cuda::stdlib::MemcpyNodeDispatcher_CUDAWithoutTransfers, sdfg::cuda::stdlib::MemcpyNodeDispatcher_CUDAWithTransfers, sdfg::cuda::stdlib::MemsetNodeDispatcher_CUDAWithoutTransfers, sdfg::cuda::stdlib::MemsetNodeDispatcher_CUDAWithTransfers, sdfg::cuda::tensor::SoftmaxNodeDispatcher_CUDAWithoutTransfers, sdfg::cuda::tensor::SoftmaxNodeDispatcher_CUDAWithTransfers, sdfg::cuda::tiles::TileCopyNodeDispatcher, sdfg::data_flow::AtomicScalarOpCPUNodeDispatcher, sdfg::data_flow::AtomicScalarOpGPUNodeDispatcher, sdfg::data_flow::CallNodeDispatcher, sdfg::gpu::GpuMmaEltwiseAddDispatcher, sdfg::gpu::GpuMmaFillDispatcher, sdfg::gpu::GpuMmaFragmentLoadDispatcher, sdfg::gpu::GpuMmaFragmentStoreDispatcher, sdfg::gpu::GpuMmaMatmulDispatcher, sdfg::gpu::GpuTileArrivalDispatcher, sdfg::math::blas::DotNodeDispatcher_BLAS, sdfg::math::blas::GEMMNodeDispatcher_BLAS, sdfg::rocm::blas::BatchedGEMMNodeDispatcher_ROCMBLASWithoutTransfers, sdfg::rocm::blas::BatchedGEMMNodeDispatcher_ROCMBLASWithTransfers, sdfg::rocm::ROCMDataOffloadingNodeDispatcher, sdfg::rocm::stdlib::MemcpyNodeDispatcher_ROCMWithoutTransfers, sdfg::rocm::stdlib::MemcpyNodeDispatcher_ROCMWithTransfers, sdfg::rocm::stdlib::MemsetNodeDispatcher_ROCMWithoutTransfers, sdfg::rocm::tiles::TileCopyNodeDispatcher, sdfg::stdlib::FreeNodeDispatcher, sdfg::stdlib::MallocNodeDispatcher, sdfg::stdlib::MemcpyNodeDispatcher, sdfg::stdlib::MemmoveNodeDispatcher, sdfg::stdlib::MemsetNodeDispatcher, and sdfg::tiles::TileCopyNodeDispatcher.

◆ end_node()

virtual void sdfg::codegen::LibraryNodeDispatcher::end_node ( PrettyPrinter & stream,
bool has_declaration )
inlinevirtual

End code generation for the node.

Parameters
streamOutput stream for generated code
has_declarationWhether a declaration was generated

Reimplemented in sdfg::codegen::LibraryNodeDispatcherBase< NodeType >, and sdfg::codegen::LibraryNodeDispatcherBase< sdfg::math::blas::GEMMNode >.

◆ instrumentation_info()

◆ pre_allocate_output()

void sdfg::codegen::LibraryNodeDispatcher::pre_allocate_output ( CodegenOutput & out,
DispatchOutput & output,
const std::string & var_name ) const
protected

Declare a variable of the type of the output and with the name "var_name".

Compatible to preexisting [dispatch_code] impls.

◆ register_output()

void sdfg::codegen::LibraryNodeDispatcher::register_output ( DispatchOutput & output,
const std::string & result_identifier ) const
protected

The dispatcher as created an output that is identified by [result_identifier].

Use that as the source for the output edges of [output]

◆ require_locally_modifiable_var()

void sdfg::codegen::LibraryNodeDispatcher::require_locally_modifiable_var ( CodegenOutput & out,
DispatchInput & input ) const
protected

Ensure that [input] points to a local copy that can be changed without modifying the actual source of the input Should only be needed to ensure that legacy [dispatch_code] code can act as before, where it always was a copy.

Member Data Documentation

◆ data_flow_graph_

const data_flow::DataFlowGraph& sdfg::codegen::LibraryNodeDispatcher::data_flow_graph_
protected

Containing dataflow graph.

◆ function_

const Function& sdfg::codegen::LibraryNodeDispatcher::function_
protected

Function context.

◆ language_extension_

LanguageExtension& sdfg::codegen::LibraryNodeDispatcher::language_extension_
protected

Language extension for code generation.

◆ node_

const data_flow::LibraryNode& sdfg::codegen::LibraryNodeDispatcher::node_
protected

Library node being dispatched.


The documentation for this class was generated from the following file: