#ifndef OPENPOSE_PRIVATE_GPU_OPENCL_HPP #define OPENPOSE_PRIVATE_GPU_OPENCL_HPP #include #define MULTI_LINE_STRING(ARG) #ARG #define CL_HPP_ENABLE_EXCEPTIONS #ifdef LOWER_CL_VERSION #define CL_HPP_MINIMUM_OPENCL_VERSION 120 #define CL_HPP_TARGET_OPENCL_VERSION 120 #else #define CL_HPP_MINIMUM_OPENCL_VERSION 120 #define CL_HPP_TARGET_OPENCL_VERSION 120 #endif typedef struct _cl_buffer_region cl_buffer_region; #define CL_DEVICE_TYPE_GPU (1 << 2) namespace cl { class CommandQueue; class Kernel; class Device; class Context; } // Singleton structure // https://stackoverflow.com/questions/1008019/c-singleton-design-pattern namespace op { class OpenCL { public: static std::shared_ptr getInstance(const int deviceId = 0, const int deviceType = CL_DEVICE_TYPE_GPU, bool getFromVienna = false); ~OpenCL(); cl::CommandQueue& getQueue(); cl::Device& getDevice(); cl::Context& getContext(); template bool buildKernelIntoManager(const std::string& kernelName, const std::string& src = "", bool isFile = false); template cl::Kernel& getKernelFromManager(const std::string& kernelName, const std::string& src = "", bool isFile = false); template inline K getKernelFunctorFromManager(const std::string& kernelName, const std::string& src = "", bool isFile = false) { return K(getKernelFromManager(kernelName, src, isFile)); } template static void getBufferRegion(cl_buffer_region& region, const int origin, const int size); int getAlignment(); static std::string clErrorToString(int err); static int getTotalGPU(); private: struct ImplCLManager; std::unique_ptr upImpl; OpenCL(const int deviceId, const int deviceType, bool getFromVienna); DELETE_COPY(OpenCL); }; } #endif // OPENPOSE_PRIVATE_GPU_OPENCL_HPP