AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
Reduction.hpp
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
25
26#ifndef REDUCTION_H_INCLUDED
27#define REDUCTION_H_INCLUDED
28
29#include <vector>
30#include "CalcServer.hpp"
31#include "Kernel.hpp"
32
33namespace Aqua {
34namespace CalcServer {
35
45{
46 public:
71 Reduction(const std::string name,
72 const std::string input_name,
73 const std::string output_name,
74 const std::string operation,
75 const std::string null_val,
76 bool once = false);
77
79 ~Reduction();
80
86 void setup();
87
96 inline size_t nSteps() const { return _global_work_sizes.size(); }
97
107 inline cl_event getUserEvent() const { return _user_event; }
108
109 protected:
114 cl_event _execute(const std::vector<cl_event> events);
115
116 private:
121 void variables();
122
125 void setupOpenCL();
126
132 void setVariables();
133
141 const std::string flags(const size_t local_size);
142
144 std::string _input_name;
146 std::string _output_name;
148 std::string _operation;
150 std::string _null_val;
151
153 InputOutput::ArrayVariable* _input_var;
155 InputOutput::Variable* _output_var;
156
158 cl_mem _input;
159
161 std::vector<cl_kernel> _kernels;
162
164 std::vector<size_t> _global_work_sizes;
166 std::vector<size_t> _local_work_sizes;
168 std::vector<size_t> _number_groups;
170 std::vector<size_t> _n;
171
173 std::vector<cl_mem> _mems;
174
177 cl_event _user_event;
178};
179
180}
181} // namespace
182
183#endif // REDUCTION_H_INCLUDED
The calculation main entry point. (See Aqua::CalcServer::CalcServer for details)
OpenCL kernel kernel based tool. (see Aqua::CalcServer::Kernel for details)
void name(const std::string tool_name)
Definition Tool.hpp:66
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.
Definition Reduction.cpp:43
cl_event getUserEvent() const
Get the user event generated by this tool to mark when is finished.
Definition Reduction.hpp:107
~Reduction()
Destructor.
Definition Reduction.cpp:60
void setup()
Initialize the tool.
Definition Reduction.cpp:79
size_t nSteps() const
Number of steps needed.
Definition Reduction.hpp:96
cl_event _execute(const std::vector< cl_event > events)
Definition Reduction.cpp:143
Tools base class.
Definition Tool.hpp:176
An array variable.
Definition Variable.hpp:894
A generic variable. Almost useless, use the overloaded classes instead of this one.
Definition Variable.hpp:68
Calculation server name space.
Definition Assert.cpp:32
Main AQUAgpusph namespace.
Definition ArgumentsManager.cpp:50