diff --git a/templates/Sweep.tmpl.cpp b/templates/Sweep.tmpl.cpp index 4eb4a35faa13e1c2324ac7280dba1f48e914f6e6..75e7d41ec5cc1d54aa8e9adf8b0abf9d0376b841 100644 --- a/templates/Sweep.tmpl.cpp +++ b/templates/Sweep.tmpl.cpp @@ -50,11 +50,10 @@ namespace {{namespace}} { {{kernel|generate_definition(target)}} - -void {{class_name}}::operator()( IBlock * block ) +void {{class_name}}::operator()( IBlock * block{%if target is equalto 'gpu'%} , cudaStream_t stream{% endif %} ) { {{kernel|generate_block_data_to_field_extraction|indent(4)}} - {{kernel|generate_call(stream='stream_')|indent(4)}} + {{kernel|generate_call(stream='stream')|indent(4)}} {{kernel|generate_swaps|indent(4)}} } @@ -62,7 +61,7 @@ void {{class_name}}::operator()( IBlock * block ) void {{class_name}}::runOnCellInterval( const shared_ptr<StructuredBlockStorage> & blocks, const CellInterval & globalCellInterval, cell_idx_t ghostLayers, - IBlock * block ) + IBlock * block{%if target is equalto 'gpu'%} , cudaStream_t stream{% endif %} ) { CellInterval ci = globalCellInterval; CellInterval blockBB = blocks->getBlockCellBB( *block); @@ -73,7 +72,7 @@ void {{class_name}}::runOnCellInterval( const shared_ptr<StructuredBlockStorage> return; {{kernel|generate_block_data_to_field_extraction|indent(4)}} - {{kernel|generate_call(stream='stream_', cell_interval='ci')|indent(4)}} + {{kernel|generate_call(stream='stream', cell_interval='ci')|indent(4)}} {{kernel|generate_swaps|indent(4)}} } diff --git a/templates/Sweep.tmpl.h b/templates/Sweep.tmpl.h index e6d24cff7d8942e361e3ba11df575e12d46fb1d1..9de4b96c2284560b920a6c592d8b2e5749a2bbf7 100644 --- a/templates/Sweep.tmpl.h +++ b/templates/Sweep.tmpl.h @@ -51,15 +51,16 @@ namespace {{namespace}} { class {{class_name}} { public: - {{class_name}}( {{kernel|generate_constructor_parameters}}{%if target is equalto 'gpu'%} , cudaStream_t stream = 0{% endif %}) - : {{ kernel|generate_constructor_initializer_list }}{%if target is equalto 'gpu'%}, stream_(stream) {%endif %} + {{class_name}}( {{kernel|generate_constructor_parameters}}) + : {{ kernel|generate_constructor_initializer_list }} {}; {{ kernel| generate_destructor(class_name) |indent(4) }} - void operator()(IBlock * b); + void operator() ( IBlock * block{%if target is equalto 'gpu'%} , cudaStream_t stream = 0{% endif %} ); void runOnCellInterval(const shared_ptr<StructuredBlockStorage> & blocks, - const CellInterval & globalCellInterval, cell_idx_t ghostLayers, IBlock * block); + const CellInterval & globalCellInterval, cell_idx_t ghostLayers, IBlock * block + {%if target is equalto 'gpu'%} , cudaStream_t stream = 0{% endif %}); @@ -67,22 +68,19 @@ public: return [kernel](IBlock * b) { (*kernel)(b); }; } - 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 ) + static std::function<void (IBlock*{%if target is equalto 'gpu'%} , cudaStream_t {% endif %})> + getSweepOnCellInterval(const shared_ptr<{{class_name}}> & kernel, + const shared_ptr<StructuredBlockStorage> & blocks, + const CellInterval & globalCellInterval, + cell_idx_t ghostLayers=1 ) { - return [kernel, blocks, globalCellInterval, ghostLayers] (IBlock * b) { - kernel->runOnCellInterval(blocks, globalCellInterval, ghostLayers, b); + return [kernel, blocks, globalCellInterval, ghostLayers] (IBlock * b{%if target is equalto 'gpu'%} , cudaStream_t stream = 0{% endif %}) { + kernel->runOnCellInterval(blocks, globalCellInterval, ghostLayers, b{%if target is equalto 'gpu'%},stream {% endif %}); }; } {{ kernel|generate_members|indent(4) }} -private: - {%if target is equalto 'gpu'%} - cudaStream_t stream_; - {% endif %} };