Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Francesco Brarda
stan-math-petsc
Commits
98537579
Unverified
Commit
98537579
authored
7 years ago
by
Steve Bronder
Browse files
Options
Download
Email Patches
Plain Diff
singleton rewrite
parent
5daf423d
stan-petsc
ChrisChiasson-feature/issue-123-complex-numbers-with-vars
bugfix/1063-std-lgamma
bugfix/1152-algebra_solver-lambdas
bugfix/issue-1250-lgamma
bugfix/issue-1270-add-check-for-meta-includes
bugfix/issue-2708-map-rect-fail
bugfix/issue-968-value-of-const-ref
bugfix/issue-995-fix-bernoulli-glm-test
bugfix/issues-935-933-integrate-1d
build/config-device-id
build/errwarns
code-cleanup/chain-final
code-cleanup/issue-937-flatten
develop
feature/1258-ad-test-core
feature/adjoint-ode
feature/automatic-autodiff-testing
feature/concept-chainable-allocator
feature/daniel-windows
feature/eigen-aligned-malloc
feature/faster-ad-tls
feature/faster-ad-tls-v2
feature/faster-ad-tls-v3
feature/faster-ad-tls-v4
feature/faster-ad-tls-v4-windows
feature/faster-ad-tls-v6
feature/github-doc-updates-aug-1-2018
feature/intel-tbb-lib
feature/issue-1012-binorm-copula-cdf
feature/issue-1022-integrate-1d-templating
feature/issue-1115-newton_solver
feature/issue-123-complex
feature/issue-1257-diff_algebra_solver
feature/issue-202-vectorize-all-binary
feature/issue-38-multi_normal_sufficient
feature/issue-565-vari-dealloc
feature/issue-755-laplace
feature/issue-838-linseq
feature/issue-876-adj-jac
feature/issue-876-ordered-constraints
feature/issue-888-quadratic_optimizer
feature/issue-937-flatten-meta-again
feature/issue-937-flatten-meta-the-third
feature/issue-937-flatten-meta-third
feature/issue-962-bivar-norm
feature/issue-989-rev-mat-eig
feature/lambertw
feature/map_rect-cpp17
feature/map_rect-fail-windows
feature/matrix_sqrt
feature/openMP
feature/operands_partials_less_copies
feature/parallel_for_each
feature/python-test-math-dependencies
feature/refactor-nested
feature/sparse-cholesky
gpu_matrix_multiply
gpu_performance_tests
integrate_1d-improvements
internal/no-assert
issue-static-init-order
kcl
master
mpi_errors
new_complex_var
parallel-ad-tape-3
perf/operands_and_partials_deux
perf/runtime_matrix_check_flags
release/v2.18.0
release/v2.18.1
release/v2.19.0
release/v2.19.1
release/v2.20.0
seantest/faster-ad-tls-v3
stancon/syclik
syclik/forward-mode
v2.20.0
v2.19.1
v2.19.0
v2.18.1
v2.18.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stan/math/gpu/opencl_context.hpp
+75
-91
stan/math/gpu/opencl_context.hpp
with
75 additions
and
91 deletions
+75
-91
stan/math/gpu/opencl_context.hpp
View file @
98537579
...
...
@@ -64,40 +64,13 @@ class opencl_context {
// - command_queue(): returns the command_queue; it should be one per device
// - get_kernel(const char* name): returns the appropriate kernel
private:
const
char
*
description_
;
size_t
max_workgroup_size_
;
std
::
string
platform_name_
;
cl
::
Device
device_
;
std
::
string
device_name_
;
cl
::
Context
context_
;
cl
::
CommandQueue
command_queue_
;
// const char* description_;
// size_t max_workgroup_size_;
// typedef std::map<const char*, const char*> map_string;
// typedef std::map<const char*, cl::Kernel> map_kernel;
// typedef std::map<const char*, bool> map_bool;
// public:
// std::map<const char*, std::tuple<bool, char*, cl::Kernel>> kernels_;
// map_string kernel_groups;
// map_string kernel_strings;
// map_kernel kernels;
// map_bool compiled_kernels;
// const char* dummy_kernel;
// void init_kernel_groups();
// void init_platforms();
// void init_devices();
// void init_context_queue();
// void init_program();
// void compile_kernel_group(const char* group);
// cl::Kernel get_kernel(const char* name);
public:
void
debug
(
std
::
ostream
&
s
)
{
s
<<
"inside opencl_context"
<<
std
::
endl
;
s
<<
" - platform_name_: "
<<
platform_name_
<<
std
::
endl
;
}
/**
* Construct the opencl_context by initializing the
* OpenCL context, devices, command queues, and kernel
...
...
@@ -119,77 +92,89 @@ class opencl_context {
"No OpenCL devices found on the selected platform: "
);
}
device_
=
all_devices
[
0
];
std
::
ostringstream
description_message
;
device_
.
getInfo
<
size_t
>
(
CL_DEVICE_MAX_WORK_GROUP_SIZE
,
&
max_workgroup_size_
);
device_name_
=
device_
.
getInfo
<
CL_DEVICE_NAME
>
();
description_message
<<
"Device "
<<
device_name_
<<
" on the platform "
<<
platform_name_
;
description_
=
description_message
.
str
().
c_str
();
context_
=
cl
::
Context
(
device_
);
command_queue_
=
cl
::
CommandQueue
(
context_
,
CL_QUEUE_PROFILING_ENABLE
,
nullptr
);
// std::ostringstream message;
// // hack to remove -Waddress, -Wnonnull-compare warnings from GCC 6
// message << "Device " << oclDevice_.getInfo<CL_DEVICE_NAME>() <<
// " on the platform " << oclPlatform_.getInfo<CL_PLATFORM_NAME>();
// std::string description_ = message.str();
}
catch
(
const
cl
::
Error
&
e
)
{
check_ocl_error
(
"build"
,
e
);
}
}
// opencl_context() {
// dummy_kernel =
// "__kernel void dummy(__global const int* foo) { };";
// try {
// init_kernel_groups();
// init_platforms();
// init_devices();
// init_context_queue();
// init_program();
// } catch (const cl::Error &e) {
// check_ocl_error("build", e);
// }
// }
// const char* description_;
// size_t max_workgroup_size_;
// typedef std::map<const char*, const char*> map_string;
// typedef std::map<const char*, cl::Kernel> map_kernel;
// typedef std::map<const char*, bool> map_bool;
// public:
// std::map<const char*, std::tuple<bool, char*, cl::Kernel>> kernels_;
// map_string kernel_groups;
// map_string kernel_strings;
// map_kernel kernels;
// map_bool compiled_kernels;
// const char* dummy_kernel;
// void compile_kernel_group(const char* group);
// cl::Kernel get_kernel(const char* name);
// /*!
// The copy and move constructors and assign operators are
// disabled
// */
// opencl_context(opencl_context const&) = delete;
// opencl_context(opencl_context&&) = delete;
// opencl_context& operator = (opencl_context const&) = delete;
// opencl_context& operator = (opencl_context &&) = delete;
public:
void
debug
(
std
::
ostream
&
s
)
{
s
<<
"inside opencl_context"
<<
std
::
endl
;
s
<<
" - platform_name_: "
<<
platform_name_
<<
std
::
endl
;
}
static
opencl_context
&
getInstance
()
{
static
opencl_context
instance
;
return
instance
;
}
/*!
The copy and move constructors and assign operators are
disabled
*/
//opencl_context(opencl_context const&) = delete;
//opencl_context(opencl_context&&) = delete;
//opencl_context& operator = (opencl_context const&) = delete;
//opencl_context& operator = (opencl_context &&) = delete;
//
/**
//
* Returns the description of the OpenCL
//
* platform and device that is used.
//
*
//
*/
//
inline const char* description() const {
//
return description_;
//
}
/**
* Returns the description of the OpenCL
* platform and device that is used.
*
*/
inline
const
char
*
description
()
const
{
return
description_
;
}
//
/**
//
* Returns the reference to the
//
* OpenCL context. If no context was created,
//
* a new context is created.
//
*
//
*/
//
inline cl::Context &context() {
//
return
oclC
ontext_;
//
}
//
/**
//
* Returns the reference to the active
//
* OpenCL command queue. If no context
//
* and queue were created,
//
* a new context and queue are created and
//
* the reference to the new queue is returned.
//
*
//
*/
//
inline cl::CommandQueue &queue() {
//
return
oclQ
ueue_;
//
}
//
/**
//
* Returns the maximum workgroup size for the
//
* device in the context.
//
*/
//
inline int maxWorkgroupSize() { return max_workgroup_size_; }
/**
* Returns the reference to the
* OpenCL context. If no context was created,
* a new context is created.
*
*/
inline
cl
::
Context
&
context
()
{
return
c
ontext_
;
}
/**
* Returns the reference to the active
* OpenCL command queue. If no context
* and queue were created,
* a new context and queue are created and
* the reference to the new queue is returned.
*
*/
inline
cl
::
CommandQueue
&
queue
()
{
return
command_q
ueue_
;
}
/**
* Returns the maximum workgroup size for the
* device in the context.
*/
inline
int
maxWorkgroupSize
()
{
return
max_workgroup_size_
;
}
};
// /**
// * Retrieves the OpenCL platforms on the system and
...
...
@@ -394,9 +379,8 @@ class opencl_context {
// return kernels[name];
// }
static
opencl_context
opencl_context
;
static
opencl_context
opencl_context
=
stan
::
math
::
opencl_context
::
getInstance
();
}
// namespace math
}
// namespace stan
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help