AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
CalcServer.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
24#ifndef CALCSERVER_H_INCLUDED
25#define CALCSERVER_H_INCLUDED
26
27#include <vector>
28#include <map>
29#include <string>
30#include <iterator>
31
32#include <sphPrerequisites.h>
33#include <ProblemSetup.h>
34#include <TimeManager.h>
35#include <Variable.h>
36#include <Singleton.h>
37#include <CalcServer/Tool.h>
38
39#ifndef _ITEMS
45#define _ITEMS 128
46#endif
47
48#ifndef _GROUPS
55#define _GROUPS 32
56#endif
57
58namespace Aqua {
60namespace CalcServer {
61
62class UnSort;
63
71class user_interruption : public std::runtime_error
72{
73 public:
75 user_interruption(const std::string msg)
76 : std::runtime_error(msg){};
77};
78
91class CalcServer : public Aqua::Singleton<Aqua::CalcServer::CalcServer>
92{
93 public:
98
100 ~CalcServer();
101
109 void update(InputOutput::TimeManager& t_manager);
110
112
116 void setup();
117
121 InputOutput::Variables* variables() { return &_vars; }
122
126 std::vector<std::string> definitions() const { return _definitions; }
127
131 std::vector<Tool*> tools() const { return _tools; }
132
136 cl_context context() const { return _context; }
137
141 cl_platform_id platform() const { return _platform; }
142
146 cl_device_id device() const { return _device; }
147
163 cl_command_queue command_queue(bool parallel = false) const
164 {
165 if (parallel)
166 return _command_queue_parallel;
167 return _command_queue;
168 }
169
181 cl_event getUnsortedMem(const std::string var_name,
182 size_t offset,
183 size_t cb,
184 void* ptr);
185
189 const std::string base_path() const { return _base_path.c_str(); }
190
195 inline bool debug_mode() const { return _sim_data.settings.debug_tools; }
196 private:
199 void setupOpenCL();
202 void queryOpenCL();
205 void setupPlatform();
208 void setupDevices();
209
211 cl_uint _num_platforms;
213 cl_platform_id* _platforms;
215 cl_uint _num_devices;
217 cl_device_id* _devices;
219 cl_context _context;
221 cl_platform_id _platform;
223 cl_device_id _device;
225 cl_command_queue _command_queue;
229 cl_command_queue _command_queue_parallel;
230
233
235 std::vector<std::string> _definitions;
236
238 std::vector<Tool*> _tools;
239
244 std::string _base_path;
245
254 char* _current_tool_name;
255
259 std::map<std::string, UnSort*> unsorters;
260
261 private:
264};
265
266}
267} // namespace
268
269#endif // CALCSERVER_H_INCLUDED
Simulation configuration data structures. (See Aqua::InputOutput::ProblemSetup for details)
Singleton instance. (See Aqua::Singleton for details)
Simulation time flow events manager. (See Aqua::InputOutput::TimeManager for details)
Tools virtual environment to allow the user to define/manipulate the tools used to carry out the simu...
Virtual variables environment to allow the user define/manipulate the variables used in the simulatio...
Exception raised when the user manually interrupts the simulation.
Definition: CalcServer.h:92
std::vector< std::string > definitions() const
Definition: CalcServer.h:126
void update(InputOutput::TimeManager &t_manager)
Internal time loop.
Definition: CalcServer.cpp:504
cl_device_id device() const
Definition: CalcServer.h:146
std::vector< Tool * > tools() const
Definition: CalcServer.h:131
InputOutput::Variables * variables()
Definition: CalcServer.h:121
const std::string base_path() const
Get the AQUAgpusph root path.
Definition: CalcServer.h:189
cl_context context() const
Definition: CalcServer.h:136
void setup()
Setup some additional simulation data.
Definition: CalcServer.cpp:943
bool debug_mode() const
Report if the tools debug mode is enabled.
Definition: CalcServer.h:195
cl_command_queue command_queue(bool parallel=false) const
Definition: CalcServer.h:163
~CalcServer()
Destructor.
Definition: CalcServer.cpp:473
cl_event getUnsortedMem(const std::string var_name, size_t offset, size_t cb, void *ptr)
Download a unsorted variable from the device.
Definition: CalcServer.cpp:548
cl_platform_id platform() const
Definition: CalcServer.h:141
Definition: CalcServer.h:72
user_interruption(const std::string msg)
Constructor.
Definition: CalcServer.h:75
bool debug_tools
Setup the tools debugging mode.
Definition: ProblemSetup.h:144
Simulation configuration data.
Definition: ProblemSetup.h:91
sphSettings settings
Stored settings.
Definition: ProblemSetup.h:232
Variables manager, which can interpret the types on the fly.
Definition: Variable.h:804
Simple but versatile singleton instance (Meyers singleton).
Definition: Singleton.h:57
Main AQUAgpusph namespace.
Definition: ArgumentsManager.cpp:45
Set of definitions and macros related with the implementation.
Simulation time flow manager.
Definition: TimeManager.h:43