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>
|
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.
|
|
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:
- A single OpenCL kernel
- A more complex OpenCL tool like Reductions or LinkList
- Python scripts
- Variables set
◆ Tool()
Aqua::CalcServer::Tool::Tool |
( |
const std::string |
tool_name, |
|
|
bool |
once = false |
|
) |
| |
Constructor.
- Parameters
-
tool_name | Name of the tool. Useful to identify errors. |
once | Run this tool just once. Useful to make initializations. |
◆ ~Tool()
Aqua::CalcServer::Tool::~Tool |
( |
| ) |
|
|
virtual |
◆ _execute()
virtual cl_event Aqua::CalcServer::Tool::_execute |
( |
const std::vector< cl_event > |
events | ) |
|
|
inlineprotectedvirtual |
Execute the tool
- Parameters
-
events | List of events that shall be waited before safe execution |
- Returns
- OpenCL event to be waited before accessing the dependencies
Reimplemented in Aqua::CalcServer::Assert, Aqua::CalcServer::Conditional, Aqua::CalcServer::If, Aqua::CalcServer::Copy, Aqua::CalcServer::Kernel, Aqua::CalcServer::LinkList, Aqua::CalcServer::MPISync, Aqua::CalcServer::Python, Aqua::CalcServer::RadixSort, Aqua::CalcServer::Reduction, Aqua::CalcServer::Reports::Performance, Aqua::CalcServer::Reports::Screen, Aqua::CalcServer::Reports::SetTabFile, Aqua::CalcServer::Reports::TabFile, Aqua::CalcServer::Set, Aqua::CalcServer::SetScalar, and Aqua::CalcServer::UnSort.
◆ addElapsedTime()
void Aqua::CalcServer::Tool::addElapsedTime |
( |
float |
elapsed_time | ) |
|
|
protected |
Add new data to the average and squared elapsed times.
- Parameters
-
◆ 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_size | allocated 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
-
source | Source code to be compiled |
names | Function names to be extracted in the kernel |
flags | Additional 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
◆ 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
-
source | Source code to be compiled |
kernel_name | Function name to be extracted in the kernel |
flags | Additional 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
◆ elapsedTime()
float Aqua::CalcServer::Tool::elapsedTime |
( |
bool |
averaged = true | ) |
const |
|
inline |
Get the time consumed by the tool.
- Parameters
-
averaged | true 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.
◆ 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.
◆ getDependencies()
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
◆ 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
-
◆ 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
-
tool | Next 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]
Set the depedencies of the tool.
The dependencies are the variables that this tool is either reading or writing.
- Parameters
-
◆ 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_names | Names of the dependencies |
◆ setup()
void Aqua::CalcServer::Tool::setup |
( |
| ) |
|
|
virtual |
Initialize the tool.
Reimplemented in Aqua::CalcServer::Assert, Aqua::CalcServer::Conditional, Aqua::CalcServer::While, Aqua::CalcServer::If, Aqua::CalcServer::End, Aqua::CalcServer::Copy, Aqua::CalcServer::Kernel, Aqua::CalcServer::LinkList, Aqua::CalcServer::MPISync, Aqua::CalcServer::Python, Aqua::CalcServer::RadixSort, Aqua::CalcServer::Reduction, Aqua::CalcServer::Reports::Performance, Aqua::CalcServer::Reports::Report, Aqua::CalcServer::Reports::Screen, Aqua::CalcServer::Reports::SetTabFile, Aqua::CalcServer::Reports::TabFile, Aqua::CalcServer::Set, Aqua::CalcServer::SetScalar, and Aqua::CalcServer::UnSort.
◆ 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:
- /home/pepe/SPH/Code/aquagpusph/include/CalcServer/Tool.h
- /home/pepe/SPH/Code/aquagpusph/src/CalcServer/Tool.cpp