AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
Kernel.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 KERNEL_H_INCLUDED
25#define KERNEL_H_INCLUDED
26
27#include <sphPrerequisites.h>
28
29#include <vector>
30#if __APPLE__
31#include <OpenCL/cl.h>
32#else
33#include <CL/cl.h>
34#endif
35#include <CalcServer/Tool.h>
36
37namespace Aqua {
38namespace CalcServer {
39
45{
46 public:
53 Kernel(const std::string tool_name,
54 const std::string kernel_path,
55 const std::string entry_point = "entry",
56 const std::string n = "N",
57 bool once = false);
58
61 virtual ~Kernel();
62
66 void setup();
67
71 const std::string path() { return (const std::string)_path; }
72
76 size_t workGroupSize() const { return _work_group_size; }
77
81 size_t globalWorkSize() const { return _global_work_size; }
82
83 protected:
88 cl_event _execute(const std::vector<cl_event> events);
89
90 protected:
97 void make(const std::string entry_point = "entry",
98 const std::string flags = "",
99 const std::string header = "");
100
105 void variables(const std::string entry_point = "main");
106
112 void setVariables();
113
117
118 private:
120 std::string _path;
121
123 std::string _entry_point;
124
126 std::string _n;
127
129 cl_kernel _kernel;
130
132 size_t _work_group_size;
133
135 size_t _global_work_size;
136
138 std::vector<std::string> _var_names;
140 std::vector<void*> _var_values;
141};
142
143}
144} // namespace
145
146#endif // KERNEL_H_INCLUDED
Tools virtual environment to allow the user to define/manipulate the tools used to carry out the simu...
A tool consisting in an OpenCL kernel execution. The variables used in the OpenCL kernel are automati...
Definition: Kernel.h:45
void setVariables()
Set the variables to the OpenCL kernel.
Definition: Kernel.cpp:361
size_t workGroupSize() const
Definition: Kernel.h:76
void variables(const std::string entry_point="main")
Definition: Kernel.cpp:265
cl_event _execute(const std::vector< cl_event > events)
Definition: Kernel.cpp:76
void make(const std::string entry_point="entry", const std::string flags="", const std::string header="")
Definition: Kernel.cpp:109
size_t globalWorkSize() const
Definition: Kernel.h:81
const std::string path()
Definition: Kernel.h:71
void computeGlobalWorkSize()
Definition: Kernel.cpp:400
void setup()
Definition: Kernel.cpp:61
virtual ~Kernel()
Definition: Kernel.cpp:49
Tools base class. The way that AQUAgpusph compute each problem is set through a set of tools that are...
Definition: Tool.h:46
Main AQUAgpusph namespace.
Definition: ArgumentsManager.cpp:45
Set of definitions and macros related with the implementation.