AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
Aqua::CalcServer::Tool Class Reference

Tools base class. More...

#include <Tool.hpp>

Inheritance diagram for Aqua::CalcServer::Tool:
Collaboration diagram for Aqua::CalcServer::Tool:

Public Member Functions

 Tool (const std::string tool_name, bool once=false)
virtual ~Tool ()
virtual void setup ()
virtual void execute ()
 Execute the tool measuring the elapsed time.
virtual Toolnext_tool ()
Toolprev_tool () const
void prev_tool (Tool *tool)
size_t allocatedMemory () const
unsigned int used_times () const
void addElapsedTime (float elapsed_time)
 Add new data to the average and squared elapsed times.
float elapsedTime (bool averaged=true) const
float elapsedTimeVariance () const
float elapsedTimeDeviation () const
virtual int scope_modifier () const
std::vector< InputOutput::Variable * > getInputDependencies () const
 Get the input depedencies of the tool.
std::vector< InputOutput::Variable * > getOutputDependencies () const
 Get the output depedencies of the tool.
std::tuple< std::vector< InputOutput::Variable * >, std::vector< InputOutput::Variable * > > getDependencies () const
 Get the depedencies of the tool.
cl_event getEvent () const
 Get the tool event.
void parent (Tool *tool)
 Set the tool parent.
Toolparent ()
 Get the tool parent.
Public Member Functions inherited from Aqua::CalcServer::Named
 Named (const std::string name)
 ~Named ()
void name (const std::string tool_name)
const std::string name () const
 Get the name.
Public Member Functions inherited from Aqua::CalcServer::Profiler
 Profiler ()
 ~Profiler ()
std::vector< Profile * > substages () const
 Get the substages.

Protected Types

enum  dep_events { in = 0x01 , out = 0x02 , all = 0x03 }

Protected Member Functions

int id_in_pipeline () const
std::string varPrefix () const
 Produce a variable name prefix.
void next_tool (Tool *tool)
void allocatedMemory (size_t mem_size)
virtual cl_event _execute (const UNUSED_PARAM std::vector< cl_event > events)
void setDependencies (std::vector< std::string > inputs, std::vector< std::string > outputs)
 Set the depedencies of the tool.
void setDependencies (std::vector< InputOutput::Variable * > inputs, std::vector< InputOutput::Variable * > outputs)
 Set the depedencies of the tool.
void setDependencies (std::vector< std::string > vars)
 Set the depedencies of the tool.
void setInputDependencies (std::vector< std::string > vars)
 Set the reading depedencies of the tool.
void setInputDependencies (std::vector< InputOutput::Variable * > vars)
 Set the reading depedencies of the tool.
void setOutputDependencies (std::vector< std::string > vars)
 Set the writing depedencies of the tool.
void setOutputDependencies (std::vector< InputOutput::Variable * > vars)
 Set the writing depedencies of the tool.
void setDependencies (std::vector< InputOutput::Variable * > vars)
 Set the depedencies of the tool.
const std::vector< cl_event > getEvents (dep_events which=dep_events::all) const
 Get the list of events that this tool shall wait for.
Protected Member Functions inherited from Aqua::CalcServer::Profiler
void substages (std::vector< Profile * > instances)
 Set the tool substages.

Static Protected Member Functions

static std::vector< cl_kernel > compile (const std::string source, const std::vector< std::string > names, const std::string flags="")
 Compile an OpenCL source code and generate the corresponding kernel.
static cl_kernel compile_kernel (const std::string source, const std::string kernel_name, const std::string flags="")
 Compile an OpenCL source code and generate the corresponding kernel.

Detailed Description

Tools base class.

The way that AQUAgpusph compute each problem is set through a set of tools that are computed sequentially. Several tools can be considered, for instance:

  1. A single OpenCL kernel
  2. A more complex OpenCL tool like Reductions or LinkList
  3. Python scripts
  4. Variables set

Member Enumeration Documentation

◆ dep_events

Enumerator
in 
out 
all 

Constructor & Destructor Documentation

◆ Tool()

Aqua::CalcServer::Tool::Tool ( const std::string tool_name,
bool once = false )

Constructor.

Parameters
tool_nameName of the tool. Useful to identify errors.
onceRun this tool just once. Useful to make initializations.
Here is the call graph for this function:

◆ ~Tool()

Aqua::CalcServer::Tool::~Tool ( )
virtual

Destructor

Member Function Documentation

◆ _execute()

virtual cl_event Aqua::CalcServer::Tool::_execute ( const UNUSED_PARAM std::vector< cl_event > events)
inlineprotectedvirtual

Execute the tool

Parameters
eventsList of events that shall be waited before safe execution
Returns
OpenCL event to be waited before accessing the dependencies

◆ addElapsedTime()

void Aqua::CalcServer::Tool::addElapsedTime ( float elapsed_time)

Add new data to the average and squared elapsed times.

Parameters
elapsed_timeElapsed time

◆ allocatedMemory() [1/2]

size_t Aqua::CalcServer::Tool::allocatedMemory ( ) const
inline

Get the allocated memory for this tool.

Returns
allocated memory by this tool.

◆ allocatedMemory() [2/2]

void Aqua::CalcServer::Tool::allocatedMemory ( size_t mem_size)
inlineprotected

Set the allocated memory for this tool.

Parameters
mem_sizeallocated memory by this tool.

◆ compile()

std::vector< cl_kernel > Aqua::CalcServer::Tool::compile ( const std::string source,
const std::vector< std::string > names,
const std::string flags = "" )
staticprotected

Compile an OpenCL source code and generate the corresponding kernel.

With this method several operations are carried out at the same time. First the program is compiled and linked. Afterwards, the required kernels are extracted, and the program object is released

Parameters
sourceSource code to be compiled
namesFunction names to be extracted in the kernel
flagsAdditional compilation flags. Some flags are used by default:
  • -DDEBUG/-DNDEBUG depending on whether DEBUG mode is enabled or not
  • -cl-mad-enable -cl-fast-relaxed-math
  • -DHAVE_2D/-DHAVE_3D depending on whether 2D or 3D is considered
Returns
Kernel instances
Here is the call graph for this function:

◆ compile_kernel()

cl_kernel Aqua::CalcServer::Tool::compile_kernel ( const std::string source,
const std::string kernel_name,
const std::string flags = "" )
staticprotected

Compile an OpenCL source code and generate the corresponding kernel.

With this method several operations are carried out at the same time. First the program is compiled and linked. Afterwards, the required kernel is extracted, and the program object is released

Parameters
sourceSource code to be compiled
kernel_nameFunction name to be extracted in the kernel
flagsAdditional compilation flags. Some flags are used by default:
  • -DDEBUG/-DNDEBUG depending on whether DEBUG mode is enabled or not
  • -cl-mad-enable -cl-fast-relaxed-math
  • -DHAVE_2D/-DHAVE_3D depending on whether 2D or 3D is considered
Returns
Kernel instance
Here is the call graph for this function:

◆ elapsedTime()

float Aqua::CalcServer::Tool::elapsedTime ( bool averaged = true) const
inline

Get the time consumed by the tool.

Parameters
averagedtrue if the avergaed time step is required, false otherwise.
Returns
time consumed.

◆ elapsedTimeDeviation()

float Aqua::CalcServer::Tool::elapsedTimeDeviation ( ) const
inline

Get the time consumed standard deviation.

Returns
Time consumed standard deviation.
Here is the call graph for this function:

◆ elapsedTimeVariance()

float Aqua::CalcServer::Tool::elapsedTimeVariance ( ) const
inline

Get the time consumed variance.

Returns
Time consumed variance.

◆ execute()

void Aqua::CalcServer::Tool::execute ( )
virtual

Execute the tool measuring the elapsed time.

Actually this method is just ensuring that the tool can be executed, e.g. the tool has been already executed, but it is asked to be ran just once. If the tool can be executed, then _execute() method is called, measuring the time required to carry out the task.

Returns
false if all gone right, true otherwise.
Note
Usually you don't want to overload this method, but the _execute() protected one.
Here is the call graph for this function:

◆ getDependencies()

std::tuple< std::vector< InputOutput::Variable * >, std::vector< InputOutput::Variable * > > Aqua::CalcServer::Tool::getDependencies ( ) const
inline

Get the depedencies of the tool.

Returns
The input and output dependencies

◆ getEvent()

cl_event Aqua::CalcServer::Tool::getEvent ( ) const
inline

Get the tool event.

That event will mark when the tool has already finished

Returns
The event

◆ getEvents()

const std::vector< cl_event > Aqua::CalcServer::Tool::getEvents ( dep_events which = dep_events::all) const
protected

Get the list of events that this tool shall wait for.

Returns
List of events
Note
The events returned have been retained, so call clReleaseEvent() after using them
Here is the call graph for this function:

◆ getInputDependencies()

std::vector< InputOutput::Variable * > Aqua::CalcServer::Tool::getInputDependencies ( ) const
inline

Get the input depedencies of the tool.

Returns
The input and output dependencies

◆ getOutputDependencies()

std::vector< InputOutput::Variable * > Aqua::CalcServer::Tool::getOutputDependencies ( ) const
inline

Get the output depedencies of the tool.

Returns
The input and output dependencies

◆ id_in_pipeline()

int Aqua::CalcServer::Tool::id_in_pipeline ( ) const
protected

Get the tool index in the pipeline

Returns
Index of the tool in the pipeline. -1 if the tool cannot be find
Here is the call graph for this function:

◆ next_tool() [1/2]

virtual Tool * Aqua::CalcServer::Tool::next_tool ( )
inlinevirtual

Get the next tool to be executed in the pipeline.

Such tool is usually just the next one in the linearized tools chain. However, conditional tools may alter the flow

Returns
Next tool to be executed. NULL if this is the last tool of the pipeline

Reimplemented in Aqua::CalcServer::Conditional, and Aqua::CalcServer::If.

Here is the call graph for this function:

◆ next_tool() [2/2]

void Aqua::CalcServer::Tool::next_tool ( Tool * tool)
inlineprotected

Set the next tool to be executed in the pipeline.

Parameters
toolNext tool to be executed. NULL if this is the last tool of the pipeline
Here is the call graph for this function:

◆ parent() [1/2]

Tool * Aqua::CalcServer::Tool::parent ( )
inline

Get the tool parent.

Returns
Parent tool. NULL if the tool has no parent
Here is the call graph for this function:

◆ parent() [2/2]

void Aqua::CalcServer::Tool::parent ( Tool * tool)
inline

Set the tool parent.

Parameters
toolParent tool. It can be NULL to set a top level tool
Here is the call graph for this function:

◆ prev_tool() [1/2]

Tool * Aqua::CalcServer::Tool::prev_tool ( ) const
inline

Get the previous tool executed in the pipeline.

CalcServer::CalcServer will provide with this information.

Returns
Previous enqueued tool. NULL if there is no previous tool on the pipeline
Here is the call graph for this function:

◆ prev_tool() [2/2]

void Aqua::CalcServer::Tool::prev_tool ( Tool * tool)
inline

Set the previous tool executed in the pipeline.

CalcServer::CalcServer will provide with this information.

Parameters
toolPrevious enqueued tool.
Here is the call graph for this function:

◆ scope_modifier()

virtual int Aqua::CalcServer::Tool::scope_modifier ( ) const
inlinevirtual

Get the scope modifier

Scopes can be used to create groups of tools that can be eventually enabled/disabled in runtime. This is sueful to create conditions.

Returns
0 if this tool is not modifying the scope, 1 if this tool is creating a new subscope, and -1 if this tool is closing an already created subscope, returning to the previous one
Note
scopes shall be always balanced

Reimplemented in Aqua::CalcServer::Conditional, and Aqua::CalcServer::End.

◆ setDependencies() [1/4]

void Aqua::CalcServer::Tool::setDependencies ( std::vector< InputOutput::Variable * > inputs,
std::vector< InputOutput::Variable * > outputs )
inlineprotected

Set the depedencies of the tool.

The dependencies are the variables that this tool is either reading or writing.

Parameters
inputsInput variables
outputsOutput variables

◆ setDependencies() [2/4]

void Aqua::CalcServer::Tool::setDependencies ( std::vector< InputOutput::Variable * > vars)
inlineprotected

Set the depedencies of the tool.

The dependencies are the variables that this tool is either reading or writing.

Warning
This function will treat all the dependencies as outputs
Parameters
varsOutput variables
Here is the call graph for this function:

◆ setDependencies() [3/4]

void Aqua::CalcServer::Tool::setDependencies ( std::vector< std::string > inputs,
std::vector< std::string > outputs )
inlineprotected

Set the depedencies of the tool.

The dependencies are the variables that this tool is either reading or writing.

Parameters
inputsNames of the input variables
outputsNames of the output variables

◆ setDependencies() [4/4]

void Aqua::CalcServer::Tool::setDependencies ( std::vector< std::string > vars)
inlineprotected

Set the depedencies of the tool.

The dependencies are the variables that this tool is either reading or writing.

Warning
This function will treat all the dependencies as outputs
Parameters
varsOutput variable names
Here is the call graph for this function:

◆ setInputDependencies() [1/2]

void Aqua::CalcServer::Tool::setInputDependencies ( std::vector< InputOutput::Variable * > vars)
inlineprotected

Set the reading depedencies of the tool.

The dependencies are the variables that this tool is either reading or writing.

Parameters
inputsInput variables

◆ setInputDependencies() [2/2]

void Aqua::CalcServer::Tool::setInputDependencies ( std::vector< std::string > vars)
inlineprotected

Set the reading depedencies of the tool.

The dependencies are the variables that this tool is either reading or writing.

Parameters
inputsNames of the input variables

◆ setOutputDependencies() [1/2]

void Aqua::CalcServer::Tool::setOutputDependencies ( std::vector< InputOutput::Variable * > vars)
inlineprotected

Set the writing depedencies of the tool.

The dependencies are the variables that this tool is either reading or writing.

Parameters
inputsOutput variables

◆ setOutputDependencies() [2/2]

void Aqua::CalcServer::Tool::setOutputDependencies ( std::vector< std::string > vars)
inlineprotected

Set the writing depedencies of the tool.

The dependencies are the variables that this tool is either reading or writing.

Parameters
inputsNames of the output variables

◆ setup()

◆ used_times()

unsigned int Aqua::CalcServer::Tool::used_times ( ) const
inline

Get the number of times that this tool has been called.

Returns
Number of times this tool has been called.

◆ varPrefix()

std::string Aqua::CalcServer::Tool::varPrefix ( ) const
inlineprotected

Produce a variable name prefix.

The prefix produced is unique for each instance of this class, granting that the variable will have a unique name, as long as the same name is not used elsewhere on the same class

Here is the call graph for this function:

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