AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions
Aqua::CalcServer::Tool Class Reference

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: More...

#include <CalcServer/Tool.h>

Inheritance diagram for Aqua::CalcServer::Tool:
Inheritance graph
[legend]

Public Member Functions

 Tool (const std::string tool_name, bool once=false)
 
virtual ~Tool ()
 
void name (const std::string tool_name)
 
const std::string name ()
 
virtual void setup ()
 
virtual void execute ()
 Execute the tool measuring the elapsed time.
 
virtual Toolnext_tool ()
 
size_t allocatedMemory () const
 
unsigned int used_times () const
 
float elapsedTime (bool averaged=true) const
 
float elapsedTimeVariance () const
 
float elapsedTimeDeviation () const
 
virtual const int scope_modifier ()
 

Protected Member Functions

int id_in_pipeline ()
 
void next_tool (Tool *tool)
 
void allocatedMemory (size_t mem_size)
 
virtual cl_event _execute (const std::vector< cl_event > events)
 
void addElapsedTime (float elapsed_time)
 Add new data to the average and squared elapsed times.
 
void setDependencies (std::vector< std::string > var_names)
 Set the depedencies of the tool.
 
void setDependencies (std::vector< InputOutput::Variable * > vars)
 Set the depedencies of the tool.
 
const std::vector< InputOutput::Variable * > getDependencies ()
 Get the depedencies of the tool.
 

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
    1. A more complex OpenCL tool like Reductions or LinkList
    2. Python scripts
    3. Variables set

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.

◆ ~Tool()

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

Destructor

Member Function Documentation

◆ _execute()

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

◆ addElapsedTime()

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

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.

Reimplemented in Aqua::CalcServer::Reports::Performance.

Here is the call graph for this function:

◆ getDependencies()

const std::vector< InputOutput::Variable * > Aqua::CalcServer::Tool::getDependencies ( )
protected

Get the depedencies of the tool.

Returns
Dependencies

◆ id_in_pipeline()

int Aqua::CalcServer::Tool::id_in_pipeline ( )
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:

◆ name() [1/2]

const std::string Aqua::CalcServer::Tool::name ( )
inline

Get the tool name.

Returns
Tool name.

◆ name() [2/2]

void Aqua::CalcServer::Tool::name ( const std::string  tool_name)
inline

Set the tool name.

Parameters
tool_nameTool name.

◆ 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.

◆ 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

◆ scope_modifier()

virtual const int Aqua::CalcServer::Tool::scope_modifier ( )
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/2]

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

Set the depedencies of the tool.

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

Parameters
varsDependencies

◆ setDependencies() [2/2]

void Aqua::CalcServer::Tool::setDependencies ( std::vector< std::string >  var_names)
protected

Set the depedencies of the tool.

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

Parameters
var_namesNames of the dependencies
Here is the call graph for this function:

◆ setup()

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

◆ 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.

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