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

Coalesces pure device buffer allocations (deviceMalloc/deviceFree without any host/device transfer) so that non-overlapping buffers of the same element type share a single, max-sized allocation. More...

#include <sdfg/passes/offloading/device_buffer_reuse_pass.h>

Inheritance diagram for sdfg::passes::DeviceBufferReusePass:
[legend]

Public Member Functions

 DeviceBufferReusePass (bool consider_dataflow_branching=false)
std::string name () override
bool run_pass (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
Public Member Functions inherited from sdfg::passes::Pass
 Pass ()=default
 Pass (const Options &options)
virtual ~Pass ()=default
virtual std::vector< OptionSpec > options ()
bool run (builder::SDFGBuilder &builder, bool create_report=false)
bool run (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager, bool create_report=false)
virtual bool run_pass (builder::SDFGBuilder &builder)
virtual void invalidates (analysis::AnalysisManager &analysis_manager, bool applied)

Additional Inherited Members

Protected Member Functions inherited from sdfg::passes::Pass
template<class T>
T option (const OptionKey< T > &key, T fallback=T{}) const

Detailed Description

Coalesces pure device buffer allocations (deviceMalloc/deviceFree without any host/device transfer) so that non-overlapping buffers of the same element type share a single, max-sized allocation.

The pass works in a mark-then-sweep fashion:

  1. MARK - collect pure ALLOC/FREE DataOffloadingNode pairs, compute their live ranges and build an interference graph (interfere if differing element type, overlapping live ranges, or not provably ordered on a single path).
  2. COLOR - greedily assign buffers to shared "colors", processing the largest allocations first; a buffer reuses an existing color only if it is compatible and does not interfere. The color's allocation is sized to the largest member.
  3. SWEEP - rename merged containers to their representative, keep one ALLOC (max size) and one FREE per color, and remove the now-redundant ALLOC/FREE nodes.

NOTE: This pass operates purely through the base offloading::DataOffloadingNode interface and is therefore target agnostic (deviceMalloc/deviceFree).

Branching can occur in two ways and both prevent reuse:

  • control-flow branching: uses live on divergent (not totally ordered) control-flow paths.
  • dataflow branching: device kernels execute asynchronously, so two uses that are reachable from one another but share no data dependency may run concurrently. When consider_dataflow_branching is enabled such independent uses are treated as interfering (conservative, correct under unsynchronized async execution). When disabled (the default) the pass assumes consecutive uses are serialized and may coalesce their buffers.

Constructor & Destructor Documentation

◆ DeviceBufferReusePass()

sdfg::passes::DeviceBufferReusePass::DeviceBufferReusePass ( bool consider_dataflow_branching = false)
explicit

Member Function Documentation

◆ name()

std::string sdfg::passes::DeviceBufferReusePass::name ( )
overridevirtual

Implements sdfg::passes::Pass.

◆ run_pass()

bool sdfg::passes::DeviceBufferReusePass::run_pass ( builder::StructuredSDFGBuilder & builder,
analysis::AnalysisManager & analysis_manager )
overridevirtual

Reimplemented from sdfg::passes::Pass.


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