#include #include #include "util.hpp" #include #ifdef linux #include #include #elif defined _WIN32 #include #include #include #include #elif defined TARGET_OS_MAC # include # include #endif struct device { cl_device_id id; cl_device_type type; cl_uint clock_frequency; char version[128]; cl_platform_id platform; }; class CL_Wrapper { public: CL_Wrapper(); ~CL_Wrapper(); int acquire_platform_and_device(); int create_shared_context(); int create_command_queue(); int compile_kernel(std::string kernel_source, bool is_path, std::string kernel_name); int set_kernel_arg(cl_kernel kernel, int index, int size, void* buffer, std::string kernel_name); int store_buffer(cl_mem, std::string buffer_name); int run_kernel(std::string kernel_name); cl_device_id getDeviceID(); cl_platform_id getPlatformID(); cl_context getContext(); private: int error = 0; bool initialized = false; bool assert(int error_code, std::string function_name); cl_platform_id platform_id; cl_device_id device_id; cl_context context; cl_command_queue command_queue; std::map kernel_map; std::map buffer_map; };