|
docc 0.8.3 (0d44999b)
C++ API 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. | |
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.
| 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.
| language_extension | Language extension for code generation |
| function | Function context |
| data_flow_graph | Containing dataflow graph |
| node | Library node to dispatch |
|
virtualdefault |
|
inlinevirtual |
Begin code generation for the node.
| stream | Output stream for generated code |
Reimplemented in sdfg::codegen::LibraryNodeDispatcherBase< NodeType >, and sdfg::codegen::LibraryNodeDispatcherBase< sdfg::math::blas::GEMMNode >.
|
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
|
virtual |
Dispatch the library node to code.
| stream | Main code stream |
| globals_stream | Global declarations stream |
| library_snippet_factory | Factory for library code snippets |
Reimplemented in docc::target::et::blas::GEMMNodeDispatcher_ETSOC_WithTransfers, sdfg::cuda::tiles::PipelineCommitNodeDispatcher, sdfg::cuda::tiles::PipelineWaitNodeDispatcher, sdfg::data_flow::MetadataDispatcher, sdfg::gpu::BarrierLocalNodeDispatcher, sdfg::rocm::tiles::PipelineCommitNodeDispatcher, and sdfg::rocm::tiles::PipelineWaitNodeDispatcher.
|
inlinevirtual |
Generate the operation-specific code.
Subclasses override this method to generate the actual library call or inline implementation. This might include:
| stream | Main code stream |
| globals_stream | Global declarations stream |
| library_snippet_factory | Factory for library code snippets |
Reimplemented in sdfg::cuda::blas::DotNodeDispatcher_CUBLASWithoutTransfers, sdfg::cuda::blas::DotNodeDispatcher_CUBLASWithTransfers, sdfg::cuda::blas::GEMMNodeDispatcher_CUBLASWithoutTransfers, sdfg::cuda::blas::GEMMNodeDispatcher_CUBLASWithTransfers, sdfg::data_flow::InvokeNodeDispatcher, sdfg::data_flow::LoadConstNodeDispatcher, sdfg::math::cmath::CMathNodeDispatcher, sdfg::offloading::ExternalDataOffloadingNodeDispatcher, sdfg::rocm::blas::DotNodeDispatcher_ROCMBLASWithoutTransfers, sdfg::rocm::blas::DotNodeDispatcher_ROCMBLASWithTransfers, sdfg::rocm::blas::GEMMNodeDispatcher_ROCMBLASWithoutTransfers, sdfg::rocm::blas::GEMMNodeDispatcher_ROCMBLASWithTransfers, sdfg::rocm::stdlib::MemsetNodeDispatcher_ROCMWithTransfers, sdfg::stdlib::AllocaNodeDispatcher, sdfg::stdlib::AssertNodeDispatcher, sdfg::stdlib::CallocNodeDispatcher, sdfg::stdlib::TrapNodeDispatcher, and sdfg::stdlib::UnreachableNodeDispatcher.
|
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.
|
inlinevirtual |
End code generation for the node.
| stream | Output stream for generated code |
| has_declaration | Whether a declaration was generated |
Reimplemented in sdfg::codegen::LibraryNodeDispatcherBase< NodeType >, and sdfg::codegen::LibraryNodeDispatcherBase< sdfg::math::blas::GEMMNode >.
|
virtual |
Get instrumentation information for this node.
Reimplemented in sdfg::cuda::blas::BatchedGEMMNodeDispatcher_CUBLASWithoutTransfers, sdfg::cuda::blas::BatchedGEMMNodeDispatcher_CUBLASWithTransfers, sdfg::cuda::blas::DotNodeDispatcher_CUBLASWithoutTransfers, sdfg::cuda::blas::DotNodeDispatcher_CUBLASWithTransfers, sdfg::cuda::blas::GEMMNodeDispatcher_CUBLASWithoutTransfers, sdfg::cuda::blas::GEMMNodeDispatcher_CUBLASWithTransfers, sdfg::cuda::CUDADataOffloadingNodeDispatcher, sdfg::cuda::tensor::SoftmaxNodeDispatcher_CUDAWithoutTransfers, sdfg::cuda::tensor::SoftmaxNodeDispatcher_CUDAWithTransfers, sdfg::math::blas::DotNodeDispatcher_BLAS, sdfg::math::blas::GEMMNodeDispatcher_BLAS, sdfg::rocm::blas::BatchedGEMMNodeDispatcher_ROCMBLASWithoutTransfers, sdfg::rocm::blas::BatchedGEMMNodeDispatcher_ROCMBLASWithTransfers, sdfg::rocm::blas::DotNodeDispatcher_ROCMBLASWithoutTransfers, sdfg::rocm::blas::DotNodeDispatcher_ROCMBLASWithTransfers, sdfg::rocm::blas::GEMMNodeDispatcher_ROCMBLASWithoutTransfers, sdfg::rocm::blas::GEMMNodeDispatcher_ROCMBLASWithTransfers, and sdfg::rocm::ROCMDataOffloadingNodeDispatcher.
|
protected |
Declare a variable of the type of the output and with the name "var_name".
Compatible to preexisting [dispatch_code] impls.
|
protected |
The dispatcher as created an output that is identified by [result_identifier].
Use that as the source for the output edges of [output]
|
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.
|
protected |
Containing dataflow graph.
|
protected |
Language extension for code generation.
|
protected |
Library node being dispatched.