Virtual Testbed
Ship dynamics simulator for extreme conditions
src
vtestbed
opencl
opencl.hh
1
#ifndef VTESTBED_OPENCL_OPENCL_HH
2
#define VTESTBED_OPENCL_OPENCL_HH
3
4
#include <iosfwd>
5
#include <string>
6
#include <unordered_map>
7
#include <vector>
8
9
#include <openclx/svm_block>
10
11
#include <openclx/command_queue>
12
#include <openclx/command_stack>
13
#include <openclx/compiler>
14
#include <openclx/context>
15
#include <openclx/device>
16
#include <openclx/kernel>
17
#include <openclx/program>
18
19
#include <vtestbed/opencl/cl.hh>
20
#include <vtestbed/opencl/device_type.hh>
21
#include <vtestbed/opencl/pipeline.hh>
22
23
namespace
vtb
{
24
28
namespace
opencl {
29
30
class
Context
{
31
32
private
:
33
using
queue_array
=
std::vector<clx::command_queue>
;
34
35
private
:
36
clx::platform _platform;
37
clx::context _context;
38
Pipeline
_pipeline{clx::command_queue{}};
39
clx::compiler _compiler{clx::context{}};
40
std::string
_flags;
41
void
* _glcontext =
nullptr
;
42
void
* _glxdisplay =
nullptr
;
43
bool
_glsharing =
false
;
44
45
public
:
46
47
Context
() =
default
;
48
49
inline
explicit
50
Context
(
std::string
filename) {
51
this->open(filename);
52
}
53
54
void
open(
std::string
filename);
55
void
close();
56
void
read(
std::string
filename,
std::istream
& in);
57
58
inline
clx::context context() {
return
this->_context; }
59
inline
clx::platform platform() {
return
this->_platform; }
60
inline
Pipeline
& pipeline() {
return
this->_pipeline; }
61
inline
clx::compiler compiler_copy() {
return
this->_compiler; }
62
inline
clx::compiler& compiler() {
return
this->_compiler; }
63
64
inline
void
65
opengl_context(
void
* rhs) noexcept {
66
this->_glcontext = rhs;
67
}
68
69
inline
void
70
display(
void
* rhs) noexcept {
71
this->_glxdisplay = rhs;
72
}
73
75
inline
bool
76
opengl_sharing
() const noexcept {
77
return
this->_glsharing;
78
}
79
80
inline
81
operator
clx::context() {
82
return
this->context();
83
}
84
85
void
platform(
std::string
suffix);
86
void
context(Device_type type);
87
void
devices(
std::string
name);
88
void
flags(
std::string
rhs);
89
90
void
platform(clx::platform rhs);
91
92
};
93
94
class
Context_base
{
95
private
:
96
Context
* _context =
nullptr
;
97
public
:
98
Context_base
() =
default
;
99
virtual
~
Context_base
() =
default
;
100
virtual
void
context(
Context
* rhs) { this->_context = rhs; }
101
inline
Context
* context() {
return
this->_context; }
102
inline
const
Context
* context()
const
{
return
this->_context; }
103
};
104
105
const
char
* real_type_flags();
106
107
template
<
class
T>
const
char
* real_type_flags();
108
109
template
<>
inline
const
char
*
110
real_type_flags<float>() {
111
return
" -DVTB_REAL_TYPE=float -DVTB_REAL_TYPE_FLOAT"
;
112
}
113
114
template
<>
inline
const
char
*
115
real_type_flags<double>() {
116
return
" -DVTB_REAL_TYPE=double -DVTB_REAL_TYPE_DOUBLE"
;
117
}
118
119
}
120
121
}
122
123
#endif // vim:filetype=cpp
std::istream
vtb::opencl::Context::opengl_sharing
bool opengl_sharing() const noexcept
OpenCL/OpenGL sharing initialised successfully.
Definition:
opencl.hh:76
std::string
vtb::opencl::Context_base
Definition:
opencl.hh:94
vtb
Main namespace.
Definition:
convert.hh:9
std::vector
vtb::opencl::Pipeline
Definition:
pipeline.hh:69
vtb::opencl::Context
Definition:
opencl.hh:30
Generated by
1.8.15