Skip to content
Snippets Groups Projects
Commit 3c6dd047 authored by Martin Bauer's avatar Martin Bauer
Browse files

pystencils_walberla: stream passed at call instead of constructor

parent 94dc442b
No related branches found
No related tags found
No related merge requests found
...@@ -50,11 +50,10 @@ namespace {{namespace}} { ...@@ -50,11 +50,10 @@ namespace {{namespace}} {
{{kernel|generate_definition(target)}} {{kernel|generate_definition(target)}}
void {{class_name}}::operator()( IBlock * block{%if target is equalto 'gpu'%} , cudaStream_t stream{% endif %} )
void {{class_name}}::operator()( IBlock * block )
{ {
{{kernel|generate_block_data_to_field_extraction|indent(4)}} {{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)}} {{kernel|generate_swaps|indent(4)}}
} }
...@@ -62,7 +61,7 @@ void {{class_name}}::operator()( IBlock * block ) ...@@ -62,7 +61,7 @@ void {{class_name}}::operator()( IBlock * block )
void {{class_name}}::runOnCellInterval( const shared_ptr<StructuredBlockStorage> & blocks, void {{class_name}}::runOnCellInterval( const shared_ptr<StructuredBlockStorage> & blocks,
const CellInterval & globalCellInterval, const CellInterval & globalCellInterval,
cell_idx_t ghostLayers, cell_idx_t ghostLayers,
IBlock * block ) IBlock * block{%if target is equalto 'gpu'%} , cudaStream_t stream{% endif %} )
{ {
CellInterval ci = globalCellInterval; CellInterval ci = globalCellInterval;
CellInterval blockBB = blocks->getBlockCellBB( *block); CellInterval blockBB = blocks->getBlockCellBB( *block);
...@@ -73,7 +72,7 @@ void {{class_name}}::runOnCellInterval( const shared_ptr<StructuredBlockStorage> ...@@ -73,7 +72,7 @@ void {{class_name}}::runOnCellInterval( const shared_ptr<StructuredBlockStorage>
return; return;
{{kernel|generate_block_data_to_field_extraction|indent(4)}} {{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)}} {{kernel|generate_swaps|indent(4)}}
} }
......
...@@ -51,15 +51,16 @@ namespace {{namespace}} { ...@@ -51,15 +51,16 @@ namespace {{namespace}} {
class {{class_name}} class {{class_name}}
{ {
public: public:
{{class_name}}( {{kernel|generate_constructor_parameters}}{%if target is equalto 'gpu'%} , cudaStream_t stream = 0{% endif %}) {{class_name}}( {{kernel|generate_constructor_parameters}})
: {{ kernel|generate_constructor_initializer_list }}{%if target is equalto 'gpu'%}, stream_(stream) {%endif %} : {{ kernel|generate_constructor_initializer_list }}
{}; {};
{{ kernel| generate_destructor(class_name) |indent(4) }} {{ 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, 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: ...@@ -67,22 +68,19 @@ public:
return [kernel](IBlock * b) { (*kernel)(b); }; return [kernel](IBlock * b) { (*kernel)(b); };
} }
static std::function<void (IBlock*)> getSweepOnCellInterval(const shared_ptr<{{class_name}}> & kernel, static std::function<void (IBlock*{%if target is equalto 'gpu'%} , cudaStream_t {% endif %})>
const shared_ptr<StructuredBlockStorage> & blocks, getSweepOnCellInterval(const shared_ptr<{{class_name}}> & kernel,
const CellInterval & globalCellInterval, const shared_ptr<StructuredBlockStorage> & blocks,
cell_idx_t ghostLayers=1 ) const CellInterval & globalCellInterval,
cell_idx_t ghostLayers=1 )
{ {
return [kernel, blocks, globalCellInterval, ghostLayers] (IBlock * b) { return [kernel, blocks, globalCellInterval, ghostLayers] (IBlock * b{%if target is equalto 'gpu'%} , cudaStream_t stream = 0{% endif %}) {
kernel->runOnCellInterval(blocks, globalCellInterval, ghostLayers, b); kernel->runOnCellInterval(blocks, globalCellInterval, ghostLayers, b{%if target is equalto 'gpu'%},stream {% endif %});
}; };
} }
{{ kernel|generate_members|indent(4) }} {{ kernel|generate_members|indent(4) }}
private:
{%if target is equalto 'gpu'%}
cudaStream_t stream_;
{% endif %}
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment