diff --git a/templates/Sweep.tmpl.cpp b/templates/Sweep.tmpl.cpp index 63d686e4a041bb9e8201843dc7d7ad13dc077d5a..66fa70f912644acbfc1d237a539fb0d520f0ea92 100644 --- a/templates/Sweep.tmpl.cpp +++ b/templates/Sweep.tmpl.cpp @@ -51,7 +51,7 @@ namespace {{namespace}} { {{kernel|generate_definition}} -void {{class_name}}::sweep( IBlock * block ) +void {{class_name}}::operator()( IBlock * block ) { {{kernel|generate_block_data_to_field_extraction|indent(4)}} {{kernel|generate_call(stream='stream_')|indent(4)}} @@ -59,10 +59,10 @@ void {{class_name}}::sweep( IBlock * block ) } -void {{class_name}}::sweepOnCellInterval( const shared_ptr<StructuredBlockStorage> & blocks, - const CellInterval & globalCellInterval, - cell_idx_t ghostLayers, - IBlock * block ) +void {{class_name}}::runOnCellInterval( const shared_ptr<StructuredBlockStorage> & blocks, + const CellInterval & globalCellInterval, + cell_idx_t ghostLayers, + IBlock * block ) { CellInterval ci = globalCellInterval; CellInterval blockBB = blocks->getBlockCellBB( *block); diff --git a/templates/Sweep.tmpl.h b/templates/Sweep.tmpl.h index 325b9c57c6dff002c69a73c92c6c0cf1dacf180d..e6d24cff7d8942e361e3ba11df575e12d46fb1d1 100644 --- a/templates/Sweep.tmpl.h +++ b/templates/Sweep.tmpl.h @@ -57,28 +57,29 @@ public: {{ kernel| generate_destructor(class_name) |indent(4) }} - void operator()(IBlock * b) { sweep(b); } + void operator()(IBlock * b); + void runOnCellInterval(const shared_ptr<StructuredBlockStorage> & blocks, + const CellInterval & globalCellInterval, cell_idx_t ghostLayers, IBlock * block); - std::function<void (IBlock*)> getSweep() { - return [this](IBlock * b) { this->sweep(b); }; + + + static std::function<void (IBlock*)> getSweep(const shared_ptr<{{class_name}}> & kernel) { + return [kernel](IBlock * b) { (*kernel)(b); }; } - std::function<void (IBlock*)> getSweepOnCellInterval(const shared_ptr<StructuredBlockStorage> & blocks, - const CellInterval & globalCellInterval, - cell_idx_t ghostLayers=1 ) + static std::function<void (IBlock*)> getSweepOnCellInterval(const shared_ptr<{{class_name}}> & kernel, + const shared_ptr<StructuredBlockStorage> & blocks, + const CellInterval & globalCellInterval, + cell_idx_t ghostLayers=1 ) { - return [this, blocks, globalCellInterval, ghostLayers] (IBlock * b) { - this->sweepOnCellInterval(blocks, globalCellInterval, ghostLayers, b); + return [kernel, blocks, globalCellInterval, ghostLayers] (IBlock * b) { + kernel->runOnCellInterval(blocks, globalCellInterval, ghostLayers, b); }; } {{ kernel|generate_members|indent(4) }} private: - void sweep( IBlock * block ); - void sweepOnCellInterval(const shared_ptr<StructuredBlockStorage> & blocks, - const CellInterval & globalCellInterval, cell_idx_t ghostLayers, IBlock * block ); - {%if target is equalto 'gpu'%} cudaStream_t stream_; {% endif %}