Reductions, like scans, prefix sums, maximum or minimum, etc...
More...
#include <CalcServer/Reduction.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.
|
|
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.
◆ 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
-
name | Tool name. |
input_name | Variable to be reduced name. |
output_name | Variable where the reduced value will be stored. |
operation | The 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_val | The 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. |
once | Run 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 |
( |
| ) |
|
◆ _execute()
cl_event Aqua::CalcServer::Reduction::_execute |
( |
const std::vector< cl_event > |
events | ) |
|
|
protectedvirtual |
Execute the tool
- Parameters
-
events | List of events that shall be waited before safe execution |
- Returns
- OpenCL event to be waited before accesing the dependencies
Reimplemented from Aqua::CalcServer::Tool.
◆ 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.
The documentation for this class was generated from the following files:
- /home/pepe/SPH/Code/aquagpusph/include/CalcServer/Reduction.h
- /home/pepe/SPH/Code/aquagpusph/src/CalcServer/Reduction.cpp