BioDynaMo  v1.05.119-a4ff3934
opencl_state.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #ifndef PIMPL_HELPERS_OPENCL_
16 #define PIMPL_HELPERS_OPENCL_
17 namespace cl {
18 class Context;
19 class CommandQueue;
20 class Device;
21 class Program;
22 }; // namespace cl
23 #endif // PIMPL_HELPERS_OPENCL_
24 
25 #ifndef CORE_GPU_OPENCL_STATE_H_
26 #define CORE_GPU_OPENCL_STATE_H_
27 
28 #include <memory>
29 #include <vector>
30 
31 namespace bdm {
32 
33 class OpenCLState {
34  public:
35  OpenCLState();
36 
38  cl::Context* GetOpenCLContext();
39 
41  cl::CommandQueue* GetOpenCLCommandQueue();
42 
44  std::vector<cl::Device>* GetOpenCLDeviceList();
45 
47  std::vector<cl::Program>* GetOpenCLProgramList();
48 
49  std::vector<bool>* GetFp64Support();
50 
51  void SelectGpu(int gpu);
52 
55  bool HasSupportForDouble();
56 
59 
62 
63  const char* GetErrorString(int error);
64 
65  int ClAssert(int const code, char const* const file, int const line,
66  bool const abort);
67 
68  private:
69  struct OpenCLImpl;
70  // We need a destructor implementation because OpenCLImpl is forward declared
72  void operator()(OpenCLImpl* p);
73  };
74  std::unique_ptr<OpenCLImpl, OpenCLImplDestructor> impl_;
75 };
76 
77 } // namespace bdm
78 
79 #endif // CORE_GPU_OPENCL_STATE_H_
bdm::OpenCLState::OpenCLImplDestructor::operator()
void operator()(OpenCLImpl *p)
Definition: opencl_state.cc:268
bdm
Definition: agent.cc:39
bdm::OpenCLState::impl_
std::unique_ptr< OpenCLImpl, OpenCLImplDestructor > impl_
Definition: opencl_state.h:74
bdm::OpenCLState::GetOpenCLProgramList
std::vector< cl::Program > * GetOpenCLProgramList()
Returns the OpenCL program (kernel) list.
Definition: opencl_state.cc:257
bdm::OpenCLState::GetOpenCLContext
cl::Context * GetOpenCLContext()
Returns the OpenCL Context.
Definition: opencl_state.cc:254
bdm::OpenCLState::GetOpenCLDeviceList
std::vector< cl::Device > * GetOpenCLDeviceList()
Returns the OpenCL device (GPU) list.
Definition: opencl_state.cc:256
bdm::OpenCLState::HasSupportForDouble
bool HasSupportForDouble()
bdm::OpenCLState::OpenCLImplDestructor
Definition: opencl_state.h:71
bdm::OpenCLState::DisableSupportForDouble
void DisableSupportForDouble()
Disable support for double-precision floating point operations.
cl
Definition: opencl_state.h:17
bdm::OpenCLState::SelectGpu
void SelectGpu(int gpu)
bdm::OpenCLState
Definition: opencl_state.h:33
bdm::OpenCLState::GetErrorString
const char * GetErrorString(int error)
Definition: opencl_state.cc:260
bdm::OpenCLState::GetFp64Support
std::vector< bool > * GetFp64Support()
bdm::OpenCLState::OpenCLImpl
Definition: opencl_state.cc:252
bdm::OpenCLState::EnableSupportForDouble
void EnableSupportForDouble()
Enable support for double-precision floating point operations.
bdm::OpenCLState::OpenCLState
OpenCLState()
bdm::OpenCLState::GetOpenCLCommandQueue
cl::CommandQueue * GetOpenCLCommandQueue()
Returns the OpenCL command queue.
Definition: opencl_state.cc:255
bdm::OpenCLState::ClAssert
int ClAssert(int const code, char const *const file, int const line, bool const abort)
Definition: opencl_state.cc:261