BioDynaMo  v1.05.159-3be850bb
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:
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 
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_
cl::Context * GetOpenCLContext()
Returns the OpenCL Context.
void EnableSupportForDouble()
Enable support for double-precision floating point operations.
int ClAssert(int const code, char const *const file, int const line, bool const abort)
std::vector< cl::Device > * GetOpenCLDeviceList()
Returns the OpenCL device (GPU) list.
std::vector< bool > * GetFp64Support()
std::vector< cl::Program > * GetOpenCLProgramList()
Returns the OpenCL program (kernel) list.
const char * GetErrorString(int error)
void SelectGpu(int gpu)
cl::CommandQueue * GetOpenCLCommandQueue()
Returns the OpenCL command queue.
std::unique_ptr< OpenCLImpl, OpenCLImplDestructor > impl_
Definition: opencl_state.h:74
void DisableSupportForDouble()
Disable support for double-precision floating point operations.
bool HasSupportForDouble()
Definition: agent.cc:39