AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
Reduction.h
Go to the documentation of this file.
1/*
2 * This file is part of AQUAgpusph, a free CFD program based on SPH.
3 * Copyright (C) 2012 Jose Luis Cercos Pita <jl.cercos@upm.es>
4 *
5 * AQUAgpusph is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * AQUAgpusph is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with AQUAgpusph. If not, see <http://www.gnu.org/licenses/>.
17 */
18
26#ifndef REDUCTION_H_INCLUDED
27#define REDUCTION_H_INCLUDED
28
29#include <vector>
30#include <CalcServer.h>
31#include <CalcServer/Kernel.h>
32
33namespace Aqua {
34namespace CalcServer {
35
43{
44 public:
68 Reduction(const std::string name,
69 const std::string input_name,
70 const std::string output_name,
71 const std::string operation,
72 const std::string null_val,
73 bool once = false);
74
76 ~Reduction();
77
83 void setup();
84
93 unsigned int nSteps() { return _global_work_sizes.size(); }
94
95 protected:
100 cl_event _execute(const std::vector<cl_event> events);
101
102 private:
107 void variables();
108
111 void setupOpenCL();
112
118 void setVariables();
119
127 const std::string flags(const size_t local_size);
128
130 std::string _input_name;
132 std::string _output_name;
134 std::string _operation;
136 std::string _null_val;
137
139 InputOutput::ArrayVariable* _input_var;
141 InputOutput::Variable* _output_var;
142
144 cl_mem _input;
145
147 std::vector<cl_kernel> _kernels;
148
150 std::vector<size_t> _global_work_sizes;
152 std::vector<size_t> _local_work_sizes;
154 std::vector<size_t> _number_groups;
156 std::vector<size_t> _n;
157
159 std::vector<cl_mem> _mems;
160};
161
162}
163} // namespace
164
165#endif // REDUCTION_H_INCLUDED
The calculation main entry point. (See Aqua::CalcServer::CalcServer for details)
Reductions, like scans, prefix sums, maximum or minimum, etc...
Definition: Reduction.h:43
unsigned int nSteps()
Number of steps needed.
Definition: Reduction.h:93
~Reduction()
Destructor.
Definition: Reduction.cpp:58
void setup()
Initialize the tool.
Definition: Reduction.cpp:75
cl_event _execute(const std::vector< cl_event > events)
Definition: Reduction.cpp:93
Tools base class. The way that AQUAgpusph compute each problem is set through a set of tools that are...
Definition: Tool.h:46
const std::string name()
Definition: Tool.h:66
Definition: Variable.h:700
A generic variable. Almost useless, use the overloaded classes instead of this one.
Definition: Variable.h:52
OpenCL kernel kernel based tool. (see Aqua::CalcServer::Kernel for details)
Main AQUAgpusph namespace.
Definition: ArgumentsManager.cpp:45