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

Reductions, like scans, prefix sums, maximum or minimum, etc... More...

#include <CalcServer/Reduction.h>

Inheritance diagram for Aqua::CalcServer::Reduction:
Inheritance graph
[legend]
Collaboration diagram for Aqua::CalcServer::Reduction:
Collaboration graph
[legend]

Public Member Functions

 Reduction (const std::string name, const std::string input_name, const std::string output_name, const std::string operation, const std::string null_val, bool once=false)
 Reduction definition.
 
 ~Reduction ()
 Destructor.
 
void setup ()
 Initialize the tool.
 
unsigned int nSteps ()
 Number of steps needed.
 
- Public Member Functions inherited from Aqua::CalcServer::Tool
 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

cl_event _execute (const std::vector< cl_event > events)
 
- Protected Member Functions inherited from Aqua::CalcServer::Tool
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.
 

Additional Inherited Members

- Static Protected Member Functions inherited from Aqua::CalcServer::Tool
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

Reductions, like scans, prefix sums, maximum or minimum, etc...

See also
Reduction.cl
Note
Hardcoded versions of the files CalcServer/Reduction.cl.in and CalcServer/Reduction.hcl.in are internally included as a text array.

Constructor & Destructor Documentation

◆ Reduction()

Aqua::CalcServer::Reduction::Reduction ( const std::string  name,
const std::string  input_name,
const std::string  output_name,
const std::string  operation,
const std::string  null_val,
bool  once = false 
)

Reduction definition.

Parameters
nameTool name.
input_nameVariable to be reduced name.
output_nameVariable where the reduced value will be stored.
operationThe reduction operation. For instance:
  • "c += b;"
  • "c.x = (a.x < b.x) ? a.x : b.x; a.y = (a.y < b.y) ? a.y : b.y;"
null_valThe value considered as the null one, i.e. INFINITY for float min value reduction, or (vec2)(0.f,0.f) for a 2D vec sum reduction.
onceRun this tool just once. Useful to make initializations.
Note
Some helpers are available for null_val:
  • VEC_ZERO: Zeroes vector.
  • VEC_ONE: Ones vector, in 3D cases the last component will be zero.
  • VEC_ALL_ONE: Equal to VEC_ONE, but in 3D cases the last component will be one as well.
  • VEC_INFINITY: INFINITY components vector, in 3D cases the last component will be zero.
  • VEC_ALL_INFINITY: Equal to VEC_INFINITY, but in 3D cases the last component will be INFINITY as well.
  • VEC_NEG_INFINITY: -VEC_INFINITY
  • VEC_ALL_NEG_INFINITY: -VEC_ALL_INFINITY.

◆ ~Reduction()

Aqua::CalcServer::Reduction::~Reduction ( )

Destructor.

Member Function Documentation

◆ _execute()

cl_event Aqua::CalcServer::Reduction::_execute ( const std::vector< cl_event >  events)
protectedvirtual

Execute the tool

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

Reimplemented from Aqua::CalcServer::Tool.

Here is the call graph for this function:

◆ nSteps()

unsigned int Aqua::CalcServer::Reduction::nSteps ( )
inline

Number of steps needed.

To reduce the array to just one variable several steps may be needed, depending on the number of work groups that should be launched at each pass.

Returns
Number of steps needed.

◆ setup()

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

Initialize the tool.

This method should be called after the constructor, such that it could report errors that the application may handle quitting in a safe way.

Reimplemented from Aqua::CalcServer::Tool.

Here is the call graph for this function:

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