24#ifndef PARTICLES_H_INCLUDED
25#define PARTICLES_H_INCLUDED
75 inline const std::string&
file()
const {
return _output_file; }
80 inline size_t n()
const {
return _bounds.y - _bounds.x; }
102 err_code = clWaitForEvents(1, &_user_event);
103 if (err_code != CL_SUCCESS) {
104 LOG(
L_ERROR,
"Failure waiting for a file writer\n");
106 throw std::runtime_error(
"OpenCL error");
108 err_code = clReleaseEvent(_user_event);
109 if (err_code != CL_SUCCESS) {
110 LOG(
L_ERROR,
"Failure releasing the user event\n");
112 throw std::runtime_error(
"OpenCL error");
121 virtual void save(
float t);
133 err_code = clSetUserEventStatus(_user_event, CL_COMPLETE);
134 if (err_code != CL_SUCCESS) {
135 LOG(
L_ERROR,
"Failure setting the user event as completed.\n");
137 throw std::runtime_error(
"OpenCL error");
139 err_code = clReleaseEvent(_user_event);
140 if (err_code != CL_SUCCESS) {
141 LOG(
L_ERROR,
"Failure releasing the user event.\n");
143 throw std::runtime_error(
"OpenCL error");
157 inline void n(
const size_t&
n)
159 const size_t offset = _bounds.x;
160 _bounds.y = offset +
n;
161 for (
auto const& mem : _data)
175 inline unsigned int setId()
const {
return _iset; }
188 inline void file(
const std::string filename) { _output_file = filename; };
200 unsigned int file(
const std::string basename,
201 unsigned int start_index,
202 unsigned int digits = 5);
207 inline float time()
const {
return _time; }
222 inline std::map<std::string, void*>
data()
const {
return _data; }
235 std::string _output_file;
243 cl_event _user_event;
246 std::map<std::string, void*> _data;
#define ulvec2
Definition LinkList.hcl.in:43
Terminal output, with Log automatic copying. (See Aqua::InputOutput::Logger for details)
#define LOG(level, log)
Definition Logger.hpp:55
Simulation configuration data structures. (See Aqua::InputOutput::ProblemSetup for details)
std::map< std::string, void * > data() const
Get the stored memory objects where the device data has been downloaded.
Definition Particles.hpp:222
void file(const std::string filename)
Set the file name.
Definition Particles.hpp:188
const std::string & file() const
Get the last printed file path.
Definition Particles.hpp:75
virtual void save(float t)
Save the data.
Definition Particles.cpp:82
virtual ~Particles()
Destructor.
Definition Particles.cpp:47
Particles(ProblemSetup &sim_data, unsigned int iset, size_t offset, size_t n=0)
Constructor.
Definition Particles.cpp:34
unsigned int setId() const
Get the "particles set" index associated with this class.
Definition Particles.hpp:175
float time() const
Get the current simulation time to be written.
Definition Particles.hpp:207
const ProblemSetup & simData() const
Get the simulation data structure.
Definition Particles.hpp:152
virtual void waitForSavers()
Wait for the eventual parallel saving threads.
Definition Particles.hpp:97
void n(const size_t &n)
Set the number of particles managed by this instance.
Definition Particles.hpp:157
virtual void print_file()
Print the data to a file.
Definition Particles.hpp:130
cl_event getUserEvent() const
Get the user event to be waited for before the file saving is finished.
Definition Particles.hpp:88
size_t n() const
Get the number of particles managed by this instance.
Definition Particles.hpp:80
const ulvec2 bounds() const
Get the particle index bounds of the "set of particles" managed by this class.
Definition Particles.hpp:170
cl_event download(std::vector< std::string > fields)
Download the data from the device and store it.
Definition Particles.cpp:243
void loadDefault()
Register some default arrays:
Definition Particles.cpp:122
__kernel void fields(__global const unsigned int *iset, __global const uint *isplit, __global const usize *mybuffer, __global const unsigned int *ilevel, __global const float *split_weight, __global float *m0, __global float *m, __global vec *r, __global vec *u, __global vec *dudt, __global float *rho, __global float *drhodt, __constant float *dr_level0, usize N, LINKLIST_LOCAL_PARAMS)
Collect the children, and the seed itself, in order to compute the field values of the buffer partner...
Definition Coalesce.cl:426
Main AQUAgpusph namespace.
Definition ArgumentsManager.cpp:50
@ L_ERROR
Definition Logger.hpp:75
Set of definitions and macros related with the implementation.